From a5335a4cdc1ad2a0abc6fffa80f3a783fb5e18b8 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 9 Oct 2024 00:24:51 -0500 Subject: [PATCH 1/3] fix: Protocol tests set their own AWS credentials --- .../DeleteObjectTaggingRequestTest.swift | 34 +- .../AWSS3Tests/GetObjectRequestTest.swift | 34 +- ...-sdk-swift-protocol-tests-Package.xcscheme | 472 ------------------ codegen/Package.swift | 2 +- .../XCTestPlans/ProtocolTestPlan.xctestplan | 143 ------ 5 files changed, 53 insertions(+), 632 deletions(-) delete mode 100644 codegen/.swiftpm/xcode/xcshareddata/xcschemes/aws-sdk-swift-protocol-tests-Package.xcscheme delete mode 100644 codegen/XCTestPlans/ProtocolTestPlan.xctestplan diff --git a/Sources/Services/AWSS3/Tests/AWSS3Tests/DeleteObjectTaggingRequestTest.swift b/Sources/Services/AWSS3/Tests/AWSS3Tests/DeleteObjectTaggingRequestTest.swift index c0f8f183e4a..9bb989a367d 100644 --- a/Sources/Services/AWSS3/Tests/AWSS3Tests/DeleteObjectTaggingRequestTest.swift +++ b/Sources/Services/AWSS3/Tests/AWSS3Tests/DeleteObjectTaggingRequestTest.swift @@ -12,6 +12,8 @@ import ClientRuntime import Smithy import SmithyTestUtil import XCTest +import struct SmithyIdentity.AWSCredentialIdentity +import struct SmithyIdentity.StaticAWSCredentialIdentityResolver class DeleteObjectTaggingRequestTest: HttpRequestTestBase { @@ -28,10 +30,18 @@ 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 SmithyIdentity.StaticAWSCredentialIdentityResolver( + SmithyIdentity.AWSCredentialIdentity( + accessKey: "ASIAIOSFODNN7EXAMPLE", + secret: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" + ) + ), + httpClientEngine: ProtocolTestClient(), + idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + region: "us-west-2", + signingRegion: "us-west-2" + ) let client = S3Client(config: config) let input = DeleteObjectTaggingInput( @@ -57,10 +67,18 @@ 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 SmithyIdentity.StaticAWSCredentialIdentityResolver( + SmithyIdentity.AWSCredentialIdentity( + accessKey: "ASIAIOSFODNN7EXAMPLE", + secret: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" + ) + ), + httpClientEngine: ProtocolTestClient(), + idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + region: "us-west-2", + signingRegion: "us-west-2" + ) let client = S3Client(config: config) let input = DeleteObjectTaggingInput( diff --git a/Sources/Services/AWSS3/Tests/AWSS3Tests/GetObjectRequestTest.swift b/Sources/Services/AWSS3/Tests/AWSS3Tests/GetObjectRequestTest.swift index a43940bfa8a..a83bf3a0f1a 100644 --- a/Sources/Services/AWSS3/Tests/AWSS3Tests/GetObjectRequestTest.swift +++ b/Sources/Services/AWSS3/Tests/AWSS3Tests/GetObjectRequestTest.swift @@ -13,6 +13,8 @@ import Foundation import Smithy import SmithyTestUtil import XCTest +import struct SmithyIdentity.AWSCredentialIdentity +import struct SmithyIdentity.StaticAWSCredentialIdentityResolver class GetObjectRequestTest: HttpRequestTestBase { @@ -26,10 +28,18 @@ 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 SmithyIdentity.StaticAWSCredentialIdentityResolver( + SmithyIdentity.AWSCredentialIdentity( + accessKey: "ASIAIOSFODNN7EXAMPLE", + secret: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" + ) + ), + httpClientEngine: ProtocolTestClient(), + idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + region: "us-west-2", + signingRegion: "us-west-2" + ) let client = S3Client(config: config) let input = GetObjectInput( @@ -52,10 +62,18 @@ 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 SmithyIdentity.StaticAWSCredentialIdentityResolver( + SmithyIdentity.AWSCredentialIdentity( + accessKey: "ASIAIOSFODNN7EXAMPLE", + secret: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" + ) + ), + httpClientEngine: ProtocolTestClient(), + idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + region: "us-west-2", + signingRegion: "us-west-2" + ) let client = S3Client(config: config) let input = GetObjectInput( diff --git a/codegen/.swiftpm/xcode/xcshareddata/xcschemes/aws-sdk-swift-protocol-tests-Package.xcscheme b/codegen/.swiftpm/xcode/xcshareddata/xcschemes/aws-sdk-swift-protocol-tests-Package.xcscheme deleted file mode 100644 index b7f82e739ce..00000000000 --- a/codegen/.swiftpm/xcode/xcshareddata/xcschemes/aws-sdk-swift-protocol-tests-Package.xcscheme +++ /dev/null @@ -1,472 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/codegen/Package.swift b/codegen/Package.swift index 0ba7930d874..bb55c495080 100644 --- a/codegen/Package.swift +++ b/codegen/Package.swift @@ -164,7 +164,7 @@ func addProtocolTests() { ) let testTarget = protocolTest.buildOnly ? nil : Target.testTarget( name: "\(protocolTest.name)Tests", - dependencies: [.smithyTestUtils, .smithyStreams, .smithyWaitersAPI, .byNameItem(name: protocolTest.name, condition: nil)], + dependencies: [.smithyTestUtils, .smithyStreams, .smithyWaitersAPI, .smithyIdentity, .byNameItem(name: protocolTest.name, condition: nil)], path: "\(protocolTest.testPath ?? protocolTest.sourcePath)/swift-codegen/Tests/\(protocolTest.name)Tests" ) package.targets += [target, testTarget].compactMap { $0 } diff --git a/codegen/XCTestPlans/ProtocolTestPlan.xctestplan b/codegen/XCTestPlans/ProtocolTestPlan.xctestplan deleted file mode 100644 index ecb6ac3d0a0..00000000000 --- a/codegen/XCTestPlans/ProtocolTestPlan.xctestplan +++ /dev/null @@ -1,143 +0,0 @@ -{ - "configurations" : [ - { - "id" : "13F35EEE-6A97-4B33-90EE-D251A1D42E6F", - "name" : "Test Scheme Action", - "options" : { - - } - } - ], - "defaultOptions" : { - "environmentVariableEntries" : [ - { - "key" : "AWS_DEFAULT_REGION", - "value" : "us-west-2" - }, - { - "key" : "AWS_REGION", - "value" : "us-west-2" - }, - { - "key" : "AWS_ACCESS_KEY_ID", - "value" : "your-access-key-id" - }, - { - "key" : "AWS_SECRET_ACCESS_KEY", - "value" : "your-secret-access-key" - }, - { - "key" : "AWS_SESSION_TOKEN", - "value" : "your-session-token" - }, - ] - }, - "testTargets" : [ - { - "target" : { - "containerPath" : "container:", - "identifier" : "APIGatewayTestSDKTests", - "name" : "APIGatewayTestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "AWSJson1_0TestSDKTests", - "name" : "AWSJson1_0TestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "AWSJson1_1TestSDKTests", - "name" : "AWSJson1_1TestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "AWSQueryTestSDKTests", - "name" : "AWSQueryTestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "AWSRestJsonTestSDKTests", - "name" : "AWSRestJsonTestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "AWSRestJsonValidationTestSDKTests", - "name" : "AWSRestJsonValidationTestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "AwsQueryExtrasTests", - "name" : "AwsQueryExtrasTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "Ec2QueryTestSDKTests", - "name" : "Ec2QueryTestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "GlacierTestSDKTests", - "name" : "GlacierTestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "MachineLearningTestSDKTests", - "name" : "MachineLearningTestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "RestXmlTestSDKTests", - "name" : "RestXmlTestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "RestXmlWithNamespaceTestSDKTests", - "name" : "RestXmlWithNamespaceTestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "S3TestSDKTests", - "name" : "S3TestSDKTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "WaitersTests", - "name" : "WaitersTests" - } - }, - { - "target" : { - "containerPath" : "container:", - "identifier" : "rest_json_extrasTests", - "name" : "rest_json_extrasTests" - } - } - ], - "version" : 1 -} From 46e775d7256f8e09df894be7c51ea346e5aa6811 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 9 Oct 2024 00:32:21 -0500 Subject: [PATCH 2/3] Remove unneeded protocol test config --- .github/workflows/continuous-integration.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d0ee0317357..efb96d01253 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -118,7 +118,6 @@ jobs: set -o pipefail && \ NSUnbufferedIO=YES xcodebuild \ -scheme aws-sdk-swift-protocol-tests-Package \ - -testPlan ProtocolTestPlan \ -destination '${{ matrix.destination }}' \ test 2>&1 \ | xcbeautify @@ -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 - name: Prepare Protocol & Unit Tests run: | ./scripts/ci_steps/prepare_protocol_and_unit_tests.sh From f73483507aacb070b5a291571939c21ace2be657 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Wed, 9 Oct 2024 01:09:00 -0500 Subject: [PATCH 3/3] Use premade dummy identity provider --- .../DeleteObjectTaggingRequestTest.swift | 29 ++++++------------- .../AWSS3Tests/GetObjectRequestTest.swift | 29 ++++++------------- codegen/Package.swift | 2 +- 3 files changed, 19 insertions(+), 41 deletions(-) diff --git a/Sources/Services/AWSS3/Tests/AWSS3Tests/DeleteObjectTaggingRequestTest.swift b/Sources/Services/AWSS3/Tests/AWSS3Tests/DeleteObjectTaggingRequestTest.swift index 9bb989a367d..8c645e32d2b 100644 --- a/Sources/Services/AWSS3/Tests/AWSS3Tests/DeleteObjectTaggingRequestTest.swift +++ b/Sources/Services/AWSS3/Tests/AWSS3Tests/DeleteObjectTaggingRequestTest.swift @@ -12,8 +12,7 @@ import ClientRuntime import Smithy import SmithyTestUtil import XCTest -import struct SmithyIdentity.AWSCredentialIdentity -import struct SmithyIdentity.StaticAWSCredentialIdentityResolver +import func SmithyTestUtil.dummyIdentityResolver class DeleteObjectTaggingRequestTest: HttpRequestTestBase { @@ -31,16 +30,11 @@ class DeleteObjectTaggingRequestTest: HttpRequestTestBase { ) let config = try await S3Client.Config( - awsCredentialIdentityResolver: try SmithyIdentity.StaticAWSCredentialIdentityResolver( - SmithyIdentity.AWSCredentialIdentity( - accessKey: "ASIAIOSFODNN7EXAMPLE", - secret: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" - ) - ), - httpClientEngine: ProtocolTestClient(), - idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + awsCredentialIdentityResolver: try SmithyTestUtil.dummyIdentityResolver(), region: "us-west-2", - signingRegion: "us-west-2" + signingRegion: "us-west-2", + idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + httpClientEngine: ProtocolTestClient() ) let client = S3Client(config: config) @@ -68,16 +62,11 @@ class DeleteObjectTaggingRequestTest: HttpRequestTestBase { ) let config = try await S3Client.Config( - awsCredentialIdentityResolver: try SmithyIdentity.StaticAWSCredentialIdentityResolver( - SmithyIdentity.AWSCredentialIdentity( - accessKey: "ASIAIOSFODNN7EXAMPLE", - secret: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" - ) - ), - httpClientEngine: ProtocolTestClient(), - idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + awsCredentialIdentityResolver: try SmithyTestUtil.dummyIdentityResolver(), region: "us-west-2", - signingRegion: "us-west-2" + signingRegion: "us-west-2", + idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + httpClientEngine: ProtocolTestClient() ) let client = S3Client(config: config) diff --git a/Sources/Services/AWSS3/Tests/AWSS3Tests/GetObjectRequestTest.swift b/Sources/Services/AWSS3/Tests/AWSS3Tests/GetObjectRequestTest.swift index a83bf3a0f1a..47008932ec8 100644 --- a/Sources/Services/AWSS3/Tests/AWSS3Tests/GetObjectRequestTest.swift +++ b/Sources/Services/AWSS3/Tests/AWSS3Tests/GetObjectRequestTest.swift @@ -13,8 +13,7 @@ import Foundation import Smithy import SmithyTestUtil import XCTest -import struct SmithyIdentity.AWSCredentialIdentity -import struct SmithyIdentity.StaticAWSCredentialIdentityResolver +import func SmithyTestUtil.dummyIdentityResolver class GetObjectRequestTest: HttpRequestTestBase { @@ -29,16 +28,11 @@ class GetObjectRequestTest: HttpRequestTestBase { ) let config = try await S3Client.Config( - awsCredentialIdentityResolver: try SmithyIdentity.StaticAWSCredentialIdentityResolver( - SmithyIdentity.AWSCredentialIdentity( - accessKey: "ASIAIOSFODNN7EXAMPLE", - secret: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" - ) - ), - httpClientEngine: ProtocolTestClient(), - idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + awsCredentialIdentityResolver: try SmithyTestUtil.dummyIdentityResolver(), region: "us-west-2", - signingRegion: "us-west-2" + signingRegion: "us-west-2", + idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + httpClientEngine: ProtocolTestClient() ) let client = S3Client(config: config) @@ -63,16 +57,11 @@ class GetObjectRequestTest: HttpRequestTestBase { ) let config = try await S3Client.Config( - awsCredentialIdentityResolver: try SmithyIdentity.StaticAWSCredentialIdentityResolver( - SmithyIdentity.AWSCredentialIdentity( - accessKey: "ASIAIOSFODNN7EXAMPLE", - secret: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" - ) - ), - httpClientEngine: ProtocolTestClient(), - idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + awsCredentialIdentityResolver: try SmithyTestUtil.dummyIdentityResolver(), region: "us-west-2", - signingRegion: "us-west-2" + signingRegion: "us-west-2", + idempotencyTokenGenerator: ProtocolTestIdempotencyTokenGenerator(), + httpClientEngine: ProtocolTestClient() ) let client = S3Client(config: config) diff --git a/codegen/Package.swift b/codegen/Package.swift index bb55c495080..0ba7930d874 100644 --- a/codegen/Package.swift +++ b/codegen/Package.swift @@ -164,7 +164,7 @@ func addProtocolTests() { ) let testTarget = protocolTest.buildOnly ? nil : Target.testTarget( name: "\(protocolTest.name)Tests", - dependencies: [.smithyTestUtils, .smithyStreams, .smithyWaitersAPI, .smithyIdentity, .byNameItem(name: protocolTest.name, condition: nil)], + dependencies: [.smithyTestUtils, .smithyStreams, .smithyWaitersAPI, .byNameItem(name: protocolTest.name, condition: nil)], path: "\(protocolTest.testPath ?? protocolTest.sourcePath)/swift-codegen/Tests/\(protocolTest.name)Tests" ) package.targets += [target, testTarget].compactMap { $0 }