Skip to content

Commit ab15067

Browse files
Add integration tests workflow (#136)
*Issue #, if available:* *Description of changes:* - Add GitHub Actions workflow with OIDC authentication and secure fork testing - Remove `#[ignore]` annotations and enable all 6 integration tests to run in CI - Use `pull_request_target` with team member detection and `safe-to-test` label requirement for external contributors - COLLABORATOR: automatic test execution - Others: require 'safe to test' label for manual approval **Testing** - All integration tests pass in both sequential and parallel execution - OIDC authentication tested and working By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Signed-off-by: Simon Marty <simon.marty@protonmail.com> Co-authored-by: Simon Marty <simon.marty@protonmail.com>
1 parent bad0177 commit ab15067

File tree

5 files changed

+66
-18
lines changed

5 files changed

+66
-18
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Integration Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: ["main"]
7+
pull_request_target:
8+
types: [opened, synchronize, reopened, ready_for_review, labeled]
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
integration-tests:
15+
runs-on: ubuntu-latest
16+
17+
# Run if:
18+
# 1. Manual trigger or push to main, OR
19+
# 2. PR from trusted author (COLLABORATOR), OR
20+
# 3. PR from untrusted author with "safe to test" label
21+
if: |
22+
github.event_name != 'pull_request_target' ||
23+
github.event.pull_request.author_association == 'COLLABORATOR' ||
24+
contains(github.event.pull_request.labels.*.name, 'safe-to-test')
25+
26+
permissions:
27+
id-token: write
28+
contents: read
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v5
33+
with:
34+
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
35+
36+
- name: Install Rust
37+
uses: actions-rs/toolchain@v1
38+
with:
39+
toolchain: stable
40+
override: true
41+
42+
- name: Configure AWS credentials
43+
uses: aws-actions/configure-aws-credentials@v5
44+
with:
45+
role-to-assume: ${{ secrets.ROLE_ARN }}
46+
role-session-name: secrets-manager-agent-ci-${{ github.run_id }}
47+
aws-region: us-east-1
48+
49+
- name: Build agent binary
50+
run: cargo build
51+
52+
- name: Run integration tests
53+
run: |
54+
cd integration-tests
55+
cargo test -- --test-threads=1

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ jobs:
4848
- name: Build
4949
run: cargo build --verbose
5050
- name: Run tests
51-
run: cargo test --verbose --all-features --no-fail-fast
51+
run: cargo test --verbose --all-features --no-fail-fast --workspace --exclude integration-tests
5252
- name: Code Coverage
53-
run: cargo llvm-cov --all-features --workspace --codecov --output-path ./codecov.json
53+
run: cargo llvm-cov --all-features --workspace --exclude integration-tests --codecov --output-path ./codecov.json
5454
- name: Publish Code Coverage
5555
uses: codecov/codecov-action@v5
5656
with:

integration-tests/tests/common.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,12 @@ impl TestSecrets {
192192
}
193193

194194
pub async fn setup() -> Self {
195-
let test_prefix = format!(
196-
"aws-sm-agent-test-{}",
197-
std::time::SystemTime::now()
198-
.duration_since(std::time::UNIX_EPOCH)
199-
.unwrap()
200-
.as_secs()
201-
);
195+
let timestamp = std::time::SystemTime::now()
196+
.duration_since(std::time::UNIX_EPOCH)
197+
.unwrap()
198+
.as_nanos();
199+
200+
let test_prefix = format!("aws-sm-agent-test-{}", timestamp);
202201

203202
let config = aws_config::load_defaults(aws_config::BehaviorVersion::latest()).await;
204203
let client = aws_sdk_secretsmanager::Client::new(&config);

integration-tests/tests/secret_retrieval.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ mod common;
33
use common::*;
44

55
#[tokio::test]
6-
#[ignore = "integration test - requires AWS credentials"]
76
async fn test_secret_retrieval_by_name() {
87
let secrets = TestSecrets::setup().await;
98
let secret_name = secrets.secret_name(SecretType::Basic);
@@ -23,7 +22,6 @@ async fn test_secret_retrieval_by_name() {
2322
}
2423

2524
#[tokio::test]
26-
#[ignore = "integration test - requires AWS credentials"]
2725
async fn test_secret_retrieval_by_arn() {
2826
let secrets = TestSecrets::setup().await;
2927
let secret_name = secrets.secret_name(SecretType::Basic);
@@ -52,7 +50,6 @@ async fn test_secret_retrieval_by_arn() {
5250
}
5351

5452
#[tokio::test]
55-
#[ignore = "integration test - requires AWS credentials"]
5653
async fn test_binary_secret_retrieval() {
5754
let secrets = TestSecrets::setup().await;
5855
let secret_name = secrets.secret_name(SecretType::Binary);
@@ -72,7 +69,6 @@ async fn test_binary_secret_retrieval() {
7269
}
7370

7471
#[tokio::test]
75-
#[ignore = "integration test - requires AWS credentials"]
7672
async fn test_version_stage_retrieval() {
7773
let secrets = TestSecrets::setup().await;
7874
let secret_name = secrets.secret_name(SecretType::Versioned);
@@ -124,7 +120,6 @@ async fn test_version_stage_retrieval() {
124120
}
125121

126122
#[tokio::test]
127-
#[ignore = "integration test - requires AWS credentials"]
128123
async fn test_version_id_retrieval() {
129124
let secrets = TestSecrets::setup().await;
130125
let secret_name = secrets.secret_name(SecretType::Versioned);
@@ -174,7 +169,6 @@ async fn test_version_id_retrieval() {
174169
}
175170

176171
#[tokio::test]
177-
#[ignore = "integration test - requires AWS credentials"]
178172
async fn test_large_secret_retrieval() {
179173
let secrets = TestSecrets::setup().await;
180174
let secret_name = secrets.secret_name(SecretType::Large);

test-local.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ cargo build
1515
echo "Running integration tests..."
1616
cd integration-tests
1717

18-
# Run integration tests (including ignored ones)
19-
# Tests now handle their own setup and cleanup
20-
cargo test -- --test-threads=1 --ignored
18+
# Run integration tests sequentially (matches CI behavior)
19+
# Tests handle their own setup and cleanup
20+
cargo test -- --test-threads=1
2121

2222
cd ..
2323

0 commit comments

Comments
 (0)