Skip to content

Commit

Permalink
feat!: SRA Identity & Auth (#1343)
Browse files Browse the repository at this point in the history
* chore: Refactor existing identity structure to use new identity protocols in smithy-swift (#1150)

* Refactor existing structure to use new identity protocols in smithy-swift.
---------

Co-authored-by: Sichan Yoo <[email protected]>

* feat: Move over signing flow from SigV4Middleware into AWSSigV4Signer (#1167)

* Add signer changes.
---------

Co-authored-by: Sichan Yoo <[email protected]>

* feat: auth scheme changes (#1174)

* Add signer changes.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* feat: middleware changes (#1180)

* Add signing properties customization hook implementation to sigv4 auth scheme, used via polymorphism in AuthSchemeMiddleware.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* feat: codegen changes (#1190)

* Replace SigV4Middleware with SigningMiddleware for normal request signing flow codegen, add in auth scheme resolver generator and auth scheme middleware usage to codegen flow, and add auth schem and auth scheme resolver to service specific config construction call.

* Update test cases to include auth schemes & auth scheme resolver in middleware context construction, and to include auth scheme middleware and signer middleware in operation stack.

* Update sdkId source.

* Move region in middleware context from sdk to smithy.

* Make auth scheme resolver associated type of service specific config oject.

* Move auth schemes from service specific config to general AWS config.
---------

Co-authored-by: Sichan Yoo <[email protected]>

* chore: update epic branch with new changes in main (#1220)

* chore!: Require Swift 5.7, fix deprecation warnings (#1173)

* feat: support initial-response in RPC based event streams (#1165)

* chore: bump models (#1178)

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Updates version to 0.28.0

* add visionOS support to useragent (#1182)

* chore: Remove all models before copying in latest versions (#1185)

* chore: update models (#1187)

* chore: Update to aws-crt-swift 0.15.0 (#1188)

* chore: Updates version to 0.29.0

* chore: Update swiftlint to 0.53.0 (#1192)

* chore: End the SDK package manifest with a newline (#1203)

* fix: Update CRT dependency to 0.17.0 (#1210)

* chore: Updates version to 0.30.0

* chore: Clean up unnecessary TODOs + move test functions to a better location (#1209)

* feat: expose presign / presignURL methods in Models.swift to service client object (#1198)

* Add codegen to expose presign / presignURL methods on service client object.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Bump models in prep for release 0.31.0 (#1218)

* chore: Updates version to 0.31.0

* fix: add s3 control to list of service clients that should have useSignedBodyHeader (#1219)

---------

Co-authored-by: Josh Elkins <[email protected]>
Co-authored-by: David Yaffe <[email protected]>
Co-authored-by: Sichan Yoo <[email protected]>
Co-authored-by: AWS SDK Swift Automation <[email protected]>

* feat: customizations (#1221)

* Add customizations to auth resolve process.

Rules-based auth scheme resolver work wrap-up.

Wrap-up rules-based resolver customization and presign / presign-url flow refactors.

Refactor eventstream signing.

Update test cases to include auth schemes & auth scheme resolver in middleware context construction, and to include auth scheme middleware and signer middleware in operation stack.

Move requestSignature getter, setter, and attribute key to generic middleware context in smithy-swift.

Update event stream test cases.

Move setting signing algorithm property from auth scheme resolver to auth scheme customization hook.

Add necessary enum import for rules based auth scheme resolver codegen.

Add codegen test for rules based auth scheme resolver generation.

* Refactor setUpBidirectionalStreaming in HttpContext extension to make it more readable.

* Add SigV4Util and refactor signing properties customization of SigV4 and SigV4A AuthSchemes to make it more scalable.

* Refactor eventstream message signing to accept any custom signer that conforms to ClientRuntime.Signer protocol.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* chore: merge most recent main into I&A project branch (#1293)

* chore!: Require Swift 5.7, fix deprecation warnings (#1173)

* feat: support initial-response in RPC based event streams (#1165)

* chore: bump models (#1178)

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Updates version to 0.28.0

* add visionOS support to useragent (#1182)

* chore: Remove all models before copying in latest versions (#1185)

* chore: update models (#1187)

* chore: Update to aws-crt-swift 0.15.0 (#1188)

* chore: Updates version to 0.29.0

* chore: Update swiftlint to 0.53.0 (#1192)

* chore: End the SDK package manifest with a newline (#1203)

* fix: Update CRT dependency to 0.17.0 (#1210)

* chore: Updates version to 0.30.0

* chore: Clean up unnecessary TODOs + move test functions to a better location (#1209)

* feat: expose presign / presignURL methods in Models.swift to service client object (#1198)

* Add codegen to expose presign / presignURL methods on service client object.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Bump models in prep for release 0.31.0 (#1218)

* chore: Updates version to 0.31.0

* fix: add s3 control to list of service clients that should have useSignedBodyHeader (#1219)

* update SQS to latest model that uses aws json protocol + add integration test (#1233)

* fix: Fix tests related to operation doc header (#1231)

* fix: Codegen issues re: recursion, Swift keywords in unions (#1237)

* fix: Integration test crashes on failure, build warning (#1239)

* feat!: Replace the XML encoder with a custom Smithy implementation (#1224)

* chore: Modernize the codegen-build-test CI workflow (#1240)

* chore: Modernize the codegen-build-test-on-comment CI workflow (#1243)

* fix: Fix ref used for smithy-swift checkout in codegen-build-test-on-comment (#1244)

* feat!: Use closures for processing HTTP response (#1242)

* add IsTruncated pagination customization for S3 ListParts (#1245)

* feat: Publish documentation to public distribution (#1232)

* fix: Fix script for extracting version from GH ref (#1247)

* chore: Codegen dev script takes args for manifest generator (#1246)

* fix: Use bash to run doc generator version step (#1248)

* chore: Update models (#1252)

* chore: Updates version to 0.32.0

* fix: DocC post-testing fixes (#1249)

* chore: Run tvOS old & new in CI (#1253)

* feat: Package manifest generator improvements (#1250)

* fix: Use new manifest generator options to run protocol & unit tests in CI (#1257)

* chore: remove use of HttpBody and replace with ByteStream (#1254)

* fix: Remove codegen-build-test-on-comment workflow (#1262)

* chore: update smithy to 1.42.0 (#1261)

* feat: Add codegen-build-test workflow to pull requests (#1263)

* fix: codegen-build-test with workflow dispatch & custom branch names (#1265)

* fix integration tests (#1268)

* chore: bump models (#1270)

* chore: Updates version to 0.33.0

* fix: Batch documentation modules properly (#1274)

* chore: Update to aws-crt-swift 0.20.0 (#1275)

* fix: update partitions to latest fixes failing endpoints tests (#1277)

* feat: handle errors in 200 response from S3 (#1266)

* chore: Use Xcode 15.1 as CI latest version (#1286)

* Delete unnecessary TODO item. (#1288)

Co-authored-by: Sichan Yoo <[email protected]>

* Update models.

* feat!: Use Foundation-based HTTP client on Apple platforms (#1282)

* Fix models.

* Fix test cases to reflect I&A codegen changes.

---------

Co-authored-by: Josh Elkins <[email protected]>
Co-authored-by: David Yaffe <[email protected]>
Co-authored-by: Sichan Yoo <[email protected]>
Co-authored-by: AWS SDK Swift Automation <[email protected]>

* feat: tie up some loose ends (#1300)

* Add S3 control to list of services that use signed body & fix wrong method name in SigV4Util.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Merge updates from main into project epic branch (#1325)

* chore!: Require Swift 5.7, fix deprecation warnings (#1173)

* feat: support initial-response in RPC based event streams (#1165)

* chore: bump models (#1178)

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Updates version to 0.28.0

* add visionOS support to useragent (#1182)

* chore: Remove all models before copying in latest versions (#1185)

* chore: update models (#1187)

* chore: Update to aws-crt-swift 0.15.0 (#1188)

* chore: Updates version to 0.29.0

* chore: Update swiftlint to 0.53.0 (#1192)

* chore: End the SDK package manifest with a newline (#1203)

* fix: Update CRT dependency to 0.17.0 (#1210)

* chore: Updates version to 0.30.0

* chore: Clean up unnecessary TODOs + move test functions to a better location (#1209)

* feat: expose presign / presignURL methods in Models.swift to service client object (#1198)

* Add codegen to expose presign / presignURL methods on service client object.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Bump models in prep for release 0.31.0 (#1218)

* chore: Updates version to 0.31.0

* fix: add s3 control to list of service clients that should have useSignedBodyHeader (#1219)

* update SQS to latest model that uses aws json protocol + add integration test (#1233)

* fix: Fix tests related to operation doc header (#1231)

* fix: Codegen issues re: recursion, Swift keywords in unions (#1237)

* fix: Integration test crashes on failure, build warning (#1239)

* feat!: Replace the XML encoder with a custom Smithy implementation (#1224)

* chore: Modernize the codegen-build-test CI workflow (#1240)

* chore: Modernize the codegen-build-test-on-comment CI workflow (#1243)

* fix: Fix ref used for smithy-swift checkout in codegen-build-test-on-comment (#1244)

* feat!: Use closures for processing HTTP response (#1242)

* add IsTruncated pagination customization for S3 ListParts (#1245)

* feat: Publish documentation to public distribution (#1232)

* fix: Fix script for extracting version from GH ref (#1247)

* chore: Codegen dev script takes args for manifest generator (#1246)

* fix: Use bash to run doc generator version step (#1248)

* chore: Update models (#1252)

* chore: Updates version to 0.32.0

* fix: DocC post-testing fixes (#1249)

* chore: Run tvOS old & new in CI (#1253)

* feat: Package manifest generator improvements (#1250)

* fix: Use new manifest generator options to run protocol & unit tests in CI (#1257)

* chore: remove use of HttpBody and replace with ByteStream (#1254)

* fix: Remove codegen-build-test-on-comment workflow (#1262)

* chore: update smithy to 1.42.0 (#1261)

* feat: Add codegen-build-test workflow to pull requests (#1263)

* fix: codegen-build-test with workflow dispatch & custom branch names (#1265)

* fix integration tests (#1268)

* chore: bump models (#1270)

* chore: Updates version to 0.33.0

* fix: Batch documentation modules properly (#1274)

* chore: Update to aws-crt-swift 0.20.0 (#1275)

* fix: update partitions to latest fixes failing endpoints tests (#1277)

* feat: handle errors in 200 response from S3 (#1266)

* chore: Use Xcode 15.1 as CI latest version (#1286)

* Delete unnecessary TODO item. (#1288)

Co-authored-by: Sichan Yoo <[email protected]>

* feat!: Use Foundation-based HTTP client on Apple platforms (#1282)

* fix integration tests to conform to latest HTTPClient change (#1295)

* chore: update to CRT 0.22.0 (#1296)

* chore: Update smithy-swift to 0.38.0 (#1298)

* chore: Update .spi.yml (#1297)

* Delete bundle region provider. (#1290)

Co-authored-by: Sichan Yoo <[email protected]>

* fix!: Refactor resolveRegion method name to getRegion for consistency. (#1291)

* Refactor resolveRegion method name to getRegion for consistency.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Update models (#1301)

* fix: Preserve data after reading response body stream in S3/200 middleware (#1303)

* chore: Updates version to 0.34.0

* feat: Add integration tests to CI (#1308)

* feat!: Provide HTTP request components by closure instead of protocol (#1317)

* Update models with latest from main.

* Add needed fix for making integration tests pass.

* Fix input to private init of AWSClientConfig.

---------

Co-authored-by: Josh Elkins <[email protected]>
Co-authored-by: David Yaffe <[email protected]>
Co-authored-by: Sichan Yoo <[email protected]>
Co-authored-by: AWS SDK Swift Automation <[email protected]>
Co-authored-by: Sven A. Schmidt <[email protected]>

* feat: test-suite (#1315)

* chore!: Require Swift 5.7, fix deprecation warnings (#1173)

* feat: support initial-response in RPC based event streams (#1165)

* chore: bump models (#1178)

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Updates version to 0.28.0

* add visionOS support to useragent (#1182)

* chore: Remove all models before copying in latest versions (#1185)

* chore: update models (#1187)

* chore: Update to aws-crt-swift 0.15.0 (#1188)

* chore: Updates version to 0.29.0

* chore: Update swiftlint to 0.53.0 (#1192)

* chore: End the SDK package manifest with a newline (#1203)

* fix: Update CRT dependency to 0.17.0 (#1210)

* chore: Updates version to 0.30.0

* chore: Clean up unnecessary TODOs + move test functions to a better location (#1209)

* feat: expose presign / presignURL methods in Models.swift to service client object (#1198)

* Add codegen to expose presign / presignURL methods on service client object.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Bump models in prep for release 0.31.0 (#1218)

* chore: Updates version to 0.31.0

* fix: add s3 control to list of service clients that should have useSignedBodyHeader (#1219)

* Add customizations to auth resolve process.

Rules-based auth scheme resolver work wrap-up.

Wrap-up rules-based resolver customization and presign / presign-url flow refactors.

Refactor eventstream signing.

Update test cases to include auth schemes & auth scheme resolver in middleware context construction, and to include auth scheme middleware and signer middleware in operation stack.

Move requestSignature getter, setter, and attribute key to generic middleware context in smithy-swift.

Update event stream test cases.

Move setting signing algorithm property from auth scheme resolver to auth scheme customization hook.

Add necessary enum import for rules based auth scheme resolver codegen.

Add codegen test for rules based auth scheme resolver generation.

* Fix swiftlint.

* Fix swiftlint.

* Refactor setUpBidirectionalStreaming in HttpContext extension to make it more readable.

* Add SigV4Util and refactor signing properties customization of SigV4 and SigV4A AuthSchemes to make it more scalable.

* Remove duplicate presign flag logic.

* Refactor eventstream message signing to accept any custom signer that conforms to ClientRuntime.Signer protocol.

* Fix swiftlint.

* Fix method name in SigV4Util and update usage in auth schemes accordingly. Also, remove duplicate AttributeKey (expiration) from AWS's HttpContext extension.

* Add tests for SigV4AuthScheme signing properties customization, as well as SigV4Util.

* Refactor or delete deprecated signing components and tests.

- Rename `AWSSigningMiddleware.kt` to `SigV4Utils.kt` and delete generator code for `SigV4Middleware`. Update companion object method calls and import statements in other files accordingly.
- Refactor tests for `AWSSigningMiddlewareTests.kt` and change name to `SigV4UtilsTests.kt` to only test for companion object methods.
- Delete `AWSSigningParams.kt` and all of its tests, including tests for `SigV4Configurator`. These tests have been moved to Swift side, in tests for auth schemes.

* Delete SigV4Config and SigV4Middleware.

* SigV4Signer tests - wip.

* update SQS to latest model that uses aws json protocol + add integration test (#1233)

* fix: Fix tests related to operation doc header (#1231)

* fix: Codegen issues re: recursion, Swift keywords in unions (#1237)

* fix: Integration test crashes on failure, build warning (#1239)

* feat!: Replace the XML encoder with a custom Smithy implementation (#1224)

* chore: Modernize the codegen-build-test CI workflow (#1240)

* chore: Modernize the codegen-build-test-on-comment CI workflow (#1243)

* fix: Fix ref used for smithy-swift checkout in codegen-build-test-on-comment (#1244)

* feat!: Use closures for processing HTTP response (#1242)

* add IsTruncated pagination customization for S3 ListParts (#1245)

* feat: Publish documentation to public distribution (#1232)

* fix: Fix script for extracting version from GH ref (#1247)

* chore: Codegen dev script takes args for manifest generator (#1246)

* fix: Use bash to run doc generator version step (#1248)

* chore: Update models (#1252)

* chore: Updates version to 0.32.0

* fix: DocC post-testing fixes (#1249)

* chore: Run tvOS old & new in CI (#1253)

* feat: Package manifest generator improvements (#1250)

* fix: Use new manifest generator options to run protocol & unit tests in CI (#1257)

* chore: remove use of HttpBody and replace with ByteStream (#1254)

* fix: Remove codegen-build-test-on-comment workflow (#1262)

* chore: update smithy to 1.42.0 (#1261)

* feat: Add codegen-build-test workflow to pull requests (#1263)

* fix: codegen-build-test with workflow dispatch & custom branch names (#1265)

* fix integration tests (#1268)

* chore: bump models (#1270)

* chore: Updates version to 0.33.0

* fix: Batch documentation modules properly (#1274)

* chore: Update to aws-crt-swift 0.20.0 (#1275)

* fix: update partitions to latest fixes failing endpoints tests (#1277)

* feat: handle errors in 200 response from S3 (#1266)

* chore: Use Xcode 15.1 as CI latest version (#1286)

* Delete unnecessary TODO item. (#1288)

Co-authored-by: Sichan Yoo <[email protected]>

* feat!: Use Foundation-based HTTP client on Apple platforms (#1282)

* fix integration tests to conform to latest HTTPClient change (#1295)

* chore: update to CRT 0.22.0 (#1296)

* chore: Update smithy-swift to 0.38.0 (#1298)

* chore: Update .spi.yml (#1297)

* Delete bundle region provider. (#1290)

Co-authored-by: Sichan Yoo <[email protected]>

* fix!: Refactor resolveRegion method name to getRegion for consistency. (#1291)

* Refactor resolveRegion method name to getRegion for consistency.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* Add tests for SigV4Util::setS3SpecificFlags method.

* Add do-catch to tests for changed method header.

* Add in missing try keyword.

* Add a way to fix a date for AWSSigV4Signer::signRequest, and add tests for AWSSigV4Signer::signRequest.

* Add SigV4 x Presigned Request integration tests using STS::getCallerIdentity and S3::putObject.

* Rename integration test directory and file for STS to be more specific.

* Update S3ErrorWith200 middleware to fix S3XCTestCase::tearDown(). Delete tearDown() from presigned request integration test now that it is redundant.

* chore: Update models (#1301)

* fix: Preserve data after reading response body stream in S3/200 middleware (#1303)

* chore: Updates version to 0.34.0

* Add EventStream Sigv4A integration test & add a test target dependency to Package.Base.swift.

* Improve comments and variable names on the EventBridge integration test.

* Update documentation comment to mention correct description of the test class.

* Remove unncessary string literal in code.

* Increase pause timer to prevent spurious failures.

* Add SigV4A integration test that uses S3's multi-region access point.

* feat: Add integration tests to CI (#1308)

* Finish SigV4A integration tests that use S3 MRAP.

* Add SigV4A signing flow integration test that uses CloudFrontKeyValueStore.

* Fix SQS interation test that wasn't working in main branch either; client initializer needed a region specified.

* Add auth scheme resolving step for convenience inits of client config in case they aren't provided.

* Fix ktlint.

* feat!: Provide HTTP request components by closure instead of protocol (#1317)

* Address PR comments from Josh.

* Update models to match ones in main branch.

* Add newly necessary services to integration test sdk.properties.

* Fix undefined variable.

* Add conditional import for URLRequest.

* Fix SigV4A EventBridge integration test.

* Add time buffer between MRAP deletion completion and deleting buckets. Integ test fails in CI saying bucket has MRAP associated, but MRAP is deleted when checked in console. Perhaps attempting to delete bucket as soon as MRAP deletion completes is causing this error.

* Fix data type.

* Fix method used to check MRAP deletion completion from checking against a literal integer 1, to checking against list ofMRAP names existing on account.

* Copy generated SDK code from feat/sra-identity-and-auth so it doesn't show up in github diff.

* Address Josh's PR comments.

* Fix typo on variable name.

* Fix swiftlint.

* Merge updated CRT version from main into feat/test-suite.

---------

Co-authored-by: Josh Elkins <[email protected]>
Co-authored-by: David Yaffe <[email protected]>
Co-authored-by: Sichan Yoo <[email protected]>
Co-authored-by: AWS SDK Swift Automation <[email protected]>
Co-authored-by: Sven A. Schmidt <[email protected]>

* chore: Merge latest changes from main into SRA I&A (#1340)

* chore!: Require Swift 5.7, fix deprecation warnings (#1173)

* feat: support initial-response in RPC based event streams (#1165)

* chore: bump models (#1178)

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Updates version to 0.28.0

* add visionOS support to useragent (#1182)

* chore: Remove all models before copying in latest versions (#1185)

* chore: update models (#1187)

* chore: Update to aws-crt-swift 0.15.0 (#1188)

* chore: Updates version to 0.29.0

* chore: Update swiftlint to 0.53.0 (#1192)

* chore: End the SDK package manifest with a newline (#1203)

* fix: Update CRT dependency to 0.17.0 (#1210)

* chore: Updates version to 0.30.0

* chore: Clean up unnecessary TODOs + move test functions to a better location (#1209)

* feat: expose presign / presignURL methods in Models.swift to service client object (#1198)

* Add codegen to expose presign / presignURL methods on service client object.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Bump models in prep for release 0.31.0 (#1218)

* chore: Updates version to 0.31.0

* fix: add s3 control to list of service clients that should have useSignedBodyHeader (#1219)

* update SQS to latest model that uses aws json protocol + add integration test (#1233)

* fix: Fix tests related to operation doc header (#1231)

* fix: Codegen issues re: recursion, Swift keywords in unions (#1237)

* fix: Integration test crashes on failure, build warning (#1239)

* feat!: Replace the XML encoder with a custom Smithy implementation (#1224)

* chore: Modernize the codegen-build-test CI workflow (#1240)

* chore: Modernize the codegen-build-test-on-comment CI workflow (#1243)

* fix: Fix ref used for smithy-swift checkout in codegen-build-test-on-comment (#1244)

* feat!: Use closures for processing HTTP response (#1242)

* add IsTruncated pagination customization for S3 ListParts (#1245)

* feat: Publish documentation to public distribution (#1232)

* fix: Fix script for extracting version from GH ref (#1247)

* chore: Codegen dev script takes args for manifest generator (#1246)

* fix: Use bash to run doc generator version step (#1248)

* chore: Update models (#1252)

* chore: Updates version to 0.32.0

* fix: DocC post-testing fixes (#1249)

* chore: Run tvOS old & new in CI (#1253)

* feat: Package manifest generator improvements (#1250)

* fix: Use new manifest generator options to run protocol & unit tests in CI (#1257)

* chore: remove use of HttpBody and replace with ByteStream (#1254)

* fix: Remove codegen-build-test-on-comment workflow (#1262)

* chore: update smithy to 1.42.0 (#1261)

* feat: Add codegen-build-test workflow to pull requests (#1263)

* fix: codegen-build-test with workflow dispatch & custom branch names (#1265)

* fix integration tests (#1268)

* chore: bump models (#1270)

* chore: Updates version to 0.33.0

* fix: Batch documentation modules properly (#1274)

* chore: Update to aws-crt-swift 0.20.0 (#1275)

* fix: update partitions to latest fixes failing endpoints tests (#1277)

* feat: handle errors in 200 response from S3 (#1266)

* chore: Use Xcode 15.1 as CI latest version (#1286)

* Delete unnecessary TODO item. (#1288)

Co-authored-by: Sichan Yoo <[email protected]>

* feat!: Use Foundation-based HTTP client on Apple platforms (#1282)

* fix integration tests to conform to latest HTTPClient change (#1295)

* chore: update to CRT 0.22.0 (#1296)

* chore: Update smithy-swift to 0.38.0 (#1298)

* chore: Update .spi.yml (#1297)

* Delete bundle region provider. (#1290)

Co-authored-by: Sichan Yoo <[email protected]>

* fix!: Refactor resolveRegion method name to getRegion for consistency. (#1291)

* Refactor resolveRegion method name to getRegion for consistency.

---------

Co-authored-by: Sichan Yoo <[email protected]>

* chore: Update models (#1301)

* fix: Preserve data after reading response body stream in S3/200 middleware (#1303)

* chore: Updates version to 0.34.0

* feat: Add integration tests to CI (#1308)

* feat!: Provide HTTP request components by closure instead of protocol (#1317)

* chore: Updated codegen (#1320)

* chore: Remove several unneeded services from codegen for integration tests (#1316)

* feat!: Eliminate service client protocols (#1322)

* chore: Update generated code (#1326)

* feat: add support for flexible checksums on Normal payloads (#1304)

* chore: Update aws-crt-swift to 0.26.0 (#1335)

* chore: Use Apple Silicon for codegen-build-test on CI (#1336)

* Checkout main branch's Sources/Services/ and Tests/Services/ into chore/merge-changes-from-main.

* Attempt #2.

* Edit the new flexible checksum codegen test to include I&A stuff.

* Add back accidentally removed list of services for new integration tests to sdk.properties.

---------

Co-authored-by: Josh Elkins <[email protected]>
Co-authored-by: David Yaffe <[email protected]>
Co-authored-by: Sichan Yoo <[email protected]>
Co-authored-by: AWS SDK Swift Automation <[email protected]>
Co-authored-by: Sven A. Schmidt <[email protected]>

* Reflect removal of IdentityKind enum.

* Add defaults provider for auth schemes. Delete AWS runtime types for auth that are no longer used. Add codegen for authSchemes and authSchemeResolver config properties. Update config codegen test accordingly.

* Update codegen tests following removal of unused generic from auth scheme & signer middlewares.

* Fix erros found from inspecting generated SDK code.

* Fix swiftlint.

* Fix ktlint.

* XMLDecoder was removed; update integration test that uses it.

* Fix region on STSWebIdentityCredentialsProviderTests.

* Address David's comments.

* Delete old config files that are replaced with SRA config work.

* Delete tests for old config structs.

* Move default auth scheme resolve logic for client config from runtime to codegen following Steven's feedback.

* Fix codegen test.

* Fix ktlint.

* Refactor how service specific signing properties are set. Refactor it out to CustomSigningPropertiesSetter, which used to called SigV4Util. Delete obsolte tests.

* Remove obsolte variable.

* Update comments & add service specific signing properties setter to SigV4A as well.

* Add unit tests for custom signing properties setter.

* Fix swiftlint.

* Address Josh's PR comments.

* In runtime code and runtime tests: Refactor names of auth related things & update and organize comments.

* In codegen & runtime integration tests: reflect naming changes in auth things made to runtime library.

* Fix swiftlint & update remaining few references to credentials provider.

* Checkout generated SDK & Tests from main to hide from github PR diff.

* Fix constructor call to Credentials() to AWSCredentialIdentity() in an integration test.

* Include codegen output for S3 and DynamoDB clients for future reference.

---------

Co-authored-by: Sichan Yoo <[email protected]>
Co-authored-by: Josh Elkins <[email protected]>
Co-authored-by: David Yaffe <[email protected]>
Co-authored-by: AWS SDK Swift Automation <[email protected]>
Co-authored-by: Sven A. Schmidt <[email protected]>
  • Loading branch information
6 people authored Feb 28, 2024
1 parent 44834c4 commit cb136c5
Show file tree
Hide file tree
Showing 109 changed files with 2,818 additions and 56,169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ func addIntegrationTestTarget(_ name: String) {
"Resources/ECSIntegTestApp/"
]
case "AWSS3":
additionalDependencies = ["AWSSSOAdmin"]
additionalDependencies = ["AWSSSOAdmin", "AWSS3Control", "AWSSTS"]
case "AWSEventBridge":
additionalDependencies = ["AWSRoute53"]
case "AWSCloudFrontKeyValueStore":
additionalDependencies = ["AWSCloudFront"]
case "AWSSTS":
additionalDependencies = ["AWSIAM", "AWSCognitoIdentity"]
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import XCTest
import ClientRuntime
import AWSClientRuntime
import AWSCloudFront
import AWSCloudFrontKeyValueStore

/// Tests SigV4a signing flow using CloudFrontKeyValueStore.
class CloudFrontKeyValueStoreSigV4ATests: XCTestCase {
// The CloudFront client to create / delete key value store (KVS)
private var client: CloudFrontClient!
// The sig4a-only KVS client to call CloudFrontKeyValueStore::listKeys
private var kvsClient: CloudFrontKeyValueStoreClient!
private var kvsConfig: CloudFrontKeyValueStoreClient.CloudFrontKeyValueStoreClientConfiguration!
// Region to use for clients
private let region = "us-east-1"

// Temporary name of the KVS to use for the test
private let kvsName = "sigv4a-test-kvs-" + UUID().uuidString.split(separator: "-").first!.lowercased()

// The Etag to use to call CloudFront::deletKeyValueStore
private var cfEtag: String!
// The Etag to use to call CloudFrontKeyValueStore::putKey
private var cfKvsEtag: String!

// The ARN of the KVS
private var kvsArn: String!
// String status of the KVS while it's being created
private let wipStatus = "PROVISIONING"

// Key-value pair to pass into CloudFrontKeyValueStore::putKey
private let key = "kvs-sigv4a-integration-test"
private let value = "{}"

private let NSEC_PER_SEC = 1_000_000_000

override func setUp() async throws {
// Initialize CloudFront client
client = try CloudFrontClient(region: region)
// Initiailize KVS client with only SigV4A enabled
kvsConfig = try await CloudFrontKeyValueStoreClient.CloudFrontKeyValueStoreClientConfiguration(region: region)
kvsConfig.authSchemes = [SigV4AAuthScheme()]
kvsClient = CloudFrontKeyValueStoreClient(config: kvsConfig)

// Create a key value store (KVS) and save its ARN
kvsArn = try await client.createKeyValueStore(input: CreateKeyValueStoreInput(name: kvsName)).keyValueStore?.arn

// Wait until KVS is provisioned & ready
var status: String? = wipStatus
repeat {
status = try await client.describeKeyValueStore(input: DescribeKeyValueStoreInput(name: kvsName)).keyValueStore?.status
let seconds = 20.0
try await Task.sleep(nanoseconds: UInt64(seconds * Double(NSEC_PER_SEC)))
} while status == wipStatus

// Fetch Etag of the KVS that was just created for both CF and CFKVS clients
cfEtag = try await client.describeKeyValueStore(input: DescribeKeyValueStoreInput(name: kvsName)).eTag
cfKvsEtag = try await kvsClient.describeKeyValueStore(input: DescribeKeyValueStoreInput(kvsARN: kvsArn)).eTag
}

override func tearDown() async throws {
// Delete the key value store
_ = try await client.deleteKeyValueStore(input: DeleteKeyValueStoreInput(
ifMatch: cfEtag,
name: kvsName
))
}

func testKeyValueStoreSigV4A() async throws {
// Put a dummy key onto KVS
_ = try await kvsClient.putKey(input: PutKeyInput(
ifMatch: cfKvsEtag,
key: key,
kvsARN: kvsArn,
value: value
))
// Confirm that the key was uploaded successfully using SigV4A signing flow
let keys = try await kvsClient.listKeys(input: ListKeysInput(kvsARN: kvsArn))
let items = try XCTUnwrap(keys.items)
XCTAssertEqual(items[0].key, key)
XCTAssertEqual(items[0].value, value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import AWSIAM
import AWSSTS
import ClientRuntime

class ECSCredentialsProviderTests: XCTestCase {
class ECSAWSCredentialIdentityResolverTests: XCTestCase {

private let taskRoleName = "ecs_integ_test_task_role"
private let executionRoleName = "ecs_integ_test_execution_role"
Expand All @@ -38,7 +38,7 @@ class ECSCredentialsProviderTests: XCTestCase {
}

// TODO: Re-enable this test once CI is configured to run it. See https://github.com/awslabs/aws-sdk-swift/issues/1310
func xtest_ecsCredentialsProvider() async throws {
func xtest_ecsAWSCredentialIdentityResolver() async throws {
let ecsClient = try await ECSClient()

// create cluster
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/Services/AWSECSIntegrationTests/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AWSECSIntegrationTests Description

- ECSCredentialsProviderTests will launch all configuration needed to run a dockerized Swift package as a task inside of a Fargate ARM64 ECS cluster.
- ECSAWSCredentialIdentityResolverTests will launch all configuration needed to run a dockerized Swift package as a task inside of a Fargate ARM64 ECS cluster.
- The test will poll the task every X seconds (30) to see if it is completed.
- Upon task completion, the latest log stream will be scanned to look for keyword 'Success!' which the Swift program running inside of the cluster will emit if successful.
- ECS resources are cleaned up but cloudwatch logs and IAM roles remain so that the test can be re-run.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import AWSSTS

func executeSTSTask() async throws {
let clientConfig = try await STSClient.STSClientConfiguration(
credentialsProvider: ECSCredentialsProvider()
awsCredentialIdentityResolver: ECSAWSCredentialIdentityResolver()
)
let client = STSClient(config: clientConfig)
let response = try await client.getCallerIdentity(input: GetCallerIdentityInput())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import XCTest
import AWSEventBridge
import ClientRuntime
import AWSClientRuntime
import AWSRoute53

/// Tests SigV4a signing flow using EventBridge's global endpoint.
class EventBridgeSigV4ATests: XCTestCase {
// The custom event bridge client with only sigv4a auth scheme configured (w/o SigV4)
private var sigv4aEventBridgeClient: EventBridgeClient!
// The primary event bridge client used to create an event bus in primary region
private var primaryRegionEventBridgeClient: EventBridgeClient!
// The secondary event bridge client used to create an event bus in secondary region
private var secondaryRegionEventBridgeClient: EventBridgeClient!
// The Route 53 client used to create a healthcheck, a parameter to EventBridge::createEndpoint
private var route53Client: Route53Client!

private var eventBridgeConfig: EventBridgeClient.EventBridgeClientConfiguration!
private let primaryRegion = "us-west-2"
private let secondaryRegion = "us-east-1"

// Name for the EventBridge global endpoint
private let endpointName = "sigv4a-test-global-endpoint"
private let eventBusName = "sigv4a-integ-test-eventbus"
private var endpointId: String!

private var healthCheckId: String!
private let route53HealthCheckArnPrefix = "arn:aws:route53:::healthcheck/"

private let NSEC_PER_SEC = 1_000_000_000

override func setUp() async throws {
// Create the clients
primaryRegionEventBridgeClient = try EventBridgeClient(region: primaryRegion)
secondaryRegionEventBridgeClient = try EventBridgeClient(region: secondaryRegion)

eventBridgeConfig = try await EventBridgeClient.EventBridgeClientConfiguration(region: primaryRegion)
eventBridgeConfig.authSchemes = [SigV4AAuthScheme()]
sigv4aEventBridgeClient = EventBridgeClient(config: eventBridgeConfig)

route53Client = try Route53Client(region: secondaryRegion)

// Create two event buses with identical names but in two different regions for the global endpoint
let eventBusArn1 = try await primaryRegionEventBridgeClient.createEventBus(input: CreateEventBusInput(name: eventBusName)).eventBusArn
let eventBusArn2 = try await secondaryRegionEventBridgeClient.createEventBus(input: CreateEventBusInput(name: eventBusName)).eventBusArn

// Create Route 53 Healthcheck
let healthCheckConfig = Route53ClientTypes.HealthCheckConfig(
fullyQualifiedDomainName: "www.amazon.com",
type: .https
)
let createHealthCheckInput = CreateHealthCheckInput(
callerReference: UUID().uuidString.split(separator: "-").first!.lowercased(),
healthCheckConfig: healthCheckConfig
)
let healthCheck = try await route53Client.createHealthCheck(input: createHealthCheckInput)
healthCheckId = (healthCheck.healthCheck?.id)!
let healthCheckArn = route53HealthCheckArnPrefix + healthCheckId

// Construct routingConfig object to use for global endpoint creation
let primary = EventBridgeClientTypes.Primary(healthCheck: healthCheckArn)
let secondary = EventBridgeClientTypes.Secondary(route: secondaryRegion)
let failoverConfig = EventBridgeClientTypes.FailoverConfig(primary: primary, secondary: secondary)
let routingConfig = EventBridgeClientTypes.RoutingConfig(failoverConfig: failoverConfig)

// Construct replicationConfig object to use for global endpoint creation
let replicationState = EventBridgeClientTypes.ReplicationState.disabled
let replicationConfig = EventBridgeClientTypes.ReplicationConfig(state: replicationState)

// Create the global endpoint with the two endpoint event buses and the routing config (healthcheck).
let endpointEventBus1 = EventBridgeClientTypes.EndpointEventBus(eventBusArn: eventBusArn1)
let endpointEventBus2 = EventBridgeClientTypes.EndpointEventBus(eventBusArn: eventBusArn2)
_ = try await primaryRegionEventBridgeClient.createEndpoint(input: CreateEndpointInput(
eventBuses: [endpointEventBus1, endpointEventBus2],
name: endpointName,
replicationConfig: replicationConfig,
routingConfig: routingConfig
))

// Pause program execution briefly.
// This is needed bc it takes some time for newly created global endpoint to configure itself
let seconds = 20.0
try await Task.sleep(nanoseconds: UInt64(seconds * Double(NSEC_PER_SEC)))

endpointId = try await primaryRegionEventBridgeClient.describeEndpoint(input: DescribeEndpointInput(name: endpointName)).endpointId
}

override func tearDown() async throws {
// Delete the endpoint
_ = try await primaryRegionEventBridgeClient.deleteEndpoint(input: DeleteEndpointInput(name: endpointName))
// Delete the event buses
_ = try await primaryRegionEventBridgeClient.deleteEventBus(input: DeleteEventBusInput(name: eventBusName))
_ = try await secondaryRegionEventBridgeClient.deleteEventBus(input: DeleteEventBusInput(name: eventBusName))
// Delete the Route 53 Healthcheck
_ = try await route53Client.deleteHealthCheck(input: DeleteHealthCheckInput(healthCheckId: healthCheckId))
}

func testEventBridgeSigV4A() async throws {
// Call putEvents with EventBridge client that only has SigV4a auth scheme configured
let event = EventBridgeClientTypes.PutEventsRequestEntry(
detail: "{}",
detailType: "test",
eventBusName: eventBusName,
source: "test"
)
let response = try await sigv4aEventBridgeClient.putEvents(input: PutEventsInput(
endpointId: endpointId,
entries: [event]
))
// Confirm that returned response has 0 failed entries
let count = response.failedEntryCount
XCTAssertEqual(count, 0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ class ProcessCredentialProviderTests: XCTestCase {
var client: S3Client!

override func setUp() async throws {
// Setup ProcessCredentialsProvider
let processCredentialsProvider = try ProcessCredentialsProvider(
// Setup ProcessAWSCredentialIdentityResolver
let processAWSCredentialIdentityResolver = try ProcessAWSCredentialIdentityResolver(
configFilePath: Bundle.module.path(forResource: "config", ofType: nil)!,
credentialsFilePath: Bundle.module.path(forResource: "credentials", ofType: nil)!
)

// Setup S3ClientConfiguration to use ProcessCredentialsProvider
// Setup S3ClientConfiguration to use ProcessAWSCredentialIdentityResolver
let testConfig = try await S3Client.S3ClientConfiguration()
testConfig.credentialsProvider = processCredentialsProvider
testConfig.awsCredentialIdentityResolver = processAWSCredentialIdentityResolver

// Initialize our S3 client with the specified configuration
client = S3Client(config: testConfig)
}

// This test calls listBuckets() and forces S3Client to use ProcessCredentialsProvider
// This test calls listBuckets() and forces S3Client to use ProcessAWSCredentialIdentityResolver
// TODO: Re-enable this test once CI is configured to run it. See https://github.com/awslabs/aws-sdk-swift/issues/1309
func xtest_listBuckets() async throws {
_ = try await client.listBuckets(input: ListBucketsInput())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class S3ErrorTests: S3XCTestCase {

func test_InvalidAccessKeyID_isThrownWhenAppropriate() async throws {
do {
let credentials = Credentials(accessKey: "AKIDEXAMPLE", secret: "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY")
let credentialsProvider = try StaticCredentialsProvider(credentials)
let config = try await S3Client.S3ClientConfiguration(credentialsProvider: credentialsProvider, region: region)
let credentials = AWSCredentialIdentity(accessKey: "AKIDEXAMPLE", secret: "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY")
let awsCredentialIdentityResolver = try StaticAWSCredentialIdentityResolver(credentials)
let config = try await S3Client.S3ClientConfiguration(awsCredentialIdentityResolver: awsCredentialIdentityResolver, region: region)
let input = GetObjectInput(bucket: bucketName, key: UUID().uuidString)
_ = try await S3Client(config: config).getObject(input: input)
XCTFail("Request should not have succeeded")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import XCTest
import AWSS3
import ClientRuntime
import AWSClientRuntime

/// Tests presigned request using S3.
class S3PresignedRequestTests: S3XCTestCase {
private var s3Config: S3Client.S3ClientConfiguration!
private let key = "test.txt"

override func setUp() async throws {
try await super.setUp()
s3Config = try await S3Client.S3ClientConfiguration(region: region)
s3Config.authSchemes = [SigV4AuthScheme()]
}

func testS3PresignedRequest() async throws {
let putObjectInput = PutObjectInput(
body: .noStream,
bucket: bucketName,
key: key,
metadata: ["filename": key]
)

let presignedRequest = try await putObjectInput.presign(
config: s3Config,
expiration: 60
)
guard let presignedRequest else {
XCTFail("Presigning PutObjectInput failed.")
// return added for compiler to not complain.
return
}

_ = try await s3Config.httpClientEngine.send(request: presignedRequest)

let getObjectInput = GetObjectInput(bucket: bucketName, key: key)
let fetchedObject = try await client.getObject(input: getObjectInput)

XCTAssertNotNil(fetchedObject.metadata)
let metadata = try XCTUnwrap(fetchedObject.metadata)
XCTAssertEqual(metadata["filename"], key)
}
}
Loading

0 comments on commit cb136c5

Please sign in to comment.