Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Protocol tests set their own AWS credentials #1784

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ jobs:
set -o pipefail && \
NSUnbufferedIO=YES xcodebuild \
-scheme aws-sdk-swift-protocol-tests-Package \
-testPlan ProtocolTestPlan \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This protocol test plan is deleted (see below). Its only purpose was to get credentials into Xcode test runs, now this is done in protocol test setup.

-destination '${{ matrix.destination }}' \
test 2>&1 \
| xcbeautify
Expand Down Expand Up @@ -183,18 +182,6 @@ jobs:
run: ./scripts/ci_steps/install_native_linux_dependencies.sh
- name: Tools Versions
run: ./scripts/ci_steps/log_tool_versions.sh
# Configure fake credentials using profiles
- name: (Credentials 1/3) Create AWS config directory
run: mkdir -p ~/.aws
- name: (Credentials 2/3) Create AWS config file
run: |
echo "[default]" > ~/.aws/config
echo "region=us-west-2" >> ~/.aws/config
- name: (Credentials 3/3) Create AWS credentials file
run: |
echo "[default]" > ~/.aws/credentials
echo "aws_access_key_id = test-key-id" >> ~/.aws/credentials
echo "aws_secret_access_key = test-secret-access-key" >> ~/.aws/credentials
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code above is deleted since credentials are now provided statically at protocol test client creation.

- name: Prepare Protocol & Unit Tests
run: |
./scripts/ci_steps/prepare_protocol_and_unit_tests.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ClientRuntime
import Smithy
import SmithyTestUtil
import XCTest
import func SmithyTestUtil.dummyIdentityResolver
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 4 tests below demonstrate the code changes to protocol tests.

The SmithyTestUtil.dummyIdentityResolver function provides a static identity resolver with some dummy AWS credentials.



class DeleteObjectTaggingRequestTest: HttpRequestTestBase {
Expand All @@ -28,10 +29,13 @@ class DeleteObjectTaggingRequestTest: HttpRequestTestBase {
resolvedHost: "mybucket.s3.us-west-2.amazonaws.com"
)

let config = try await S3Client.S3ClientConfiguration()
config.region = "us-west-2"
config.httpClientEngine = ProtocolTestClient()
config.idempotencyTokenGenerator = ProtocolTestIdempotencyTokenGenerator()
let config = try await S3Client.Config(
awsCredentialIdentityResolver: try SmithyTestUtil.dummyIdentityResolver(),
region: "us-west-2",
signingRegion: "us-west-2",
idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(),
httpClientEngine: ProtocolTestClient()
)
let client = S3Client(config: config)

let input = DeleteObjectTaggingInput(
Expand All @@ -57,10 +61,13 @@ class DeleteObjectTaggingRequestTest: HttpRequestTestBase {
resolvedHost: "mybucket.s3.us-west-2.amazonaws.com"
)

let config = try await S3Client.S3ClientConfiguration()
config.region = "us-west-2"
config.httpClientEngine = ProtocolTestClient()
config.idempotencyTokenGenerator = ProtocolTestIdempotencyTokenGenerator()
let config = try await S3Client.Config(
awsCredentialIdentityResolver: try SmithyTestUtil.dummyIdentityResolver(),
region: "us-west-2",
signingRegion: "us-west-2",
idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(),
httpClientEngine: ProtocolTestClient()
)
let client = S3Client(config: config)

let input = DeleteObjectTaggingInput(
Expand Down
23 changes: 15 additions & 8 deletions Sources/Services/AWSS3/Tests/AWSS3Tests/GetObjectRequestTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Foundation
import Smithy
import SmithyTestUtil
import XCTest
import func SmithyTestUtil.dummyIdentityResolver


class GetObjectRequestTest: HttpRequestTestBase {
Expand All @@ -26,10 +27,13 @@ class GetObjectRequestTest: HttpRequestTestBase {
resolvedHost: "mybucket.s3.us-west-2.amazonaws.com"
)

let config = try await S3Client.S3ClientConfiguration()
config.region = "us-west-2"
config.httpClientEngine = ProtocolTestClient()
config.idempotencyTokenGenerator = ProtocolTestIdempotencyTokenGenerator()
let config = try await S3Client.Config(
awsCredentialIdentityResolver: try SmithyTestUtil.dummyIdentityResolver(),
region: "us-west-2",
signingRegion: "us-west-2",
idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(),
httpClientEngine: ProtocolTestClient()
)
let client = S3Client(config: config)

let input = GetObjectInput(
Expand All @@ -52,10 +56,13 @@ class GetObjectRequestTest: HttpRequestTestBase {
resolvedHost: "mybucket.s3.us-west-2.amazonaws.com"
)

let config = try await S3Client.S3ClientConfiguration()
config.region = "us-west-2"
config.httpClientEngine = ProtocolTestClient()
config.idempotencyTokenGenerator = ProtocolTestIdempotencyTokenGenerator()
let config = try await S3Client.Config(
awsCredentialIdentityResolver: try SmithyTestUtil.dummyIdentityResolver(),
region: "us-west-2",
signingRegion: "us-west-2",
idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(),
httpClientEngine: ProtocolTestClient()
)
let client = S3Client(config: config)

let input = GetObjectInput(
Copy link
Contributor Author

@jbelkins jbelkins Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .xcscheme and .xctestplan files below are deleted because they are unnecessary.

  • The .xctestplan was only used to inject credentials in environment vars, those credentials are now supplied via static identity resolver.
  • The .xcscheme is auto-generated by Xcode on demand, with all targets in the package included. Having a hard-coded .xcscheme makes it necessary to add new tests to the scheme as they are added; this results in skipped tests if not done. Not a problem with the auto-generated scheme since it auto-generates for every test run. The auto-generated scheme has the same name as the now-deleted .xcscheme file, so no change to scheme name where it is referenced.

Expand Down
Loading
Loading