Skip to content

Commit

Permalink
chore: Merge updates from main into project epic branch (#1325)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
6 people authored Feb 6, 2024
1 parent 4069b54 commit 5137a69
Show file tree
Hide file tree
Showing 623 changed files with 155,245 additions and 2,538 deletions.
159 changes: 159 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Integration Tests

on:
pull_request:
workflow_dispatch:

env:
AWS_SWIFT_SDK_USE_LOCAL_DEPS: 1

permissions:
id-token: write

jobs:
apple:
runs-on: ${{ matrix.runner }}
environment: Integration-Test
env:
DEVELOPER_DIR: /Applications/${{ matrix.xcode }}.app/Contents/Developer
strategy:
fail-fast: false
matrix:
# This matrix runs tests on Mac, on oldest & newest supported Xcodes
runner:
- macos-12
- macos-13
xcode:
- Xcode_14.0.1
- Xcode_15.2
exclude:
# Don't run old macOS with new Xcode
- runner: macos-12
xcode: Xcode_15.2
# Don't run new macOS with old Xcode
- runner: macos-13
xcode: Xcode_14.0.1
steps:
- name: Configure AWS Credentials for Integration Tests
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.INTEGRATION_TEST_ROLE_ARN }}
aws-region: us-west-2
- name: Checkout aws-sdk-swift
uses: actions/checkout@v3
- name: Select smithy-swift branch
run: |
ORIGINAL_REPO_HEAD_REF="$GITHUB_HEAD_REF" \
DEPENDENCY_REPO_URL="https://github.com/smithy-lang/smithy-swift.git" \
./scripts/ci_steps/select_dependency_branch.sh
- name: Checkout smithy-swift
uses: actions/checkout@v3
with:
repository: smithy-lang/smithy-swift
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: smithy-swift
- name: Move smithy-swift into place
run: mv smithy-swift ..
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: 1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
1-${{ runner.os }}-gradle-
- name: Cache Swift
uses: actions/cache@v3
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/.cache/org.swift.swiftpm
key: 1-${{ runner.os }}-${{ matrix.xcode }}-${{ hashFiles('Package.swift', 'AWSSDKSwiftCLI/Package.swift') }}
restore-keys: |
1-${{ runner.os }}-${{ matrix.xcode }}-${{ hashFiles('Package.swift', 'AWSSDKSwiftCLI/Package.swift') }}
1-${{ runner.os }}-${{ matrix.xcode }}-
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 17
- name: Tools Versions
run: ./scripts/ci_steps/log_tool_versions.sh
- name: Prepare Integration Tests
run: ./scripts/ci_steps/prepare_integration_tests.sh
- name: Build Integration Tests
run: swift build --build-tests
- name: Run Integration Tests
run: swift test

linux:
runs-on: ubuntu-latest
environment: Integration-Test
container: swift:${{ matrix.version }}-${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- focal
#- amazonlinux2
version:
- 5.7
- 5.9
steps:
- name: Configure AWS Credentials for Integration Tests
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.INTEGRATION_TEST_ROLE_ARN }}
aws-region: us-west-2
- name: Checkout aws-sdk-swift
uses: actions/checkout@v3
- name: Select smithy-swift branch
run: |
ORIGINAL_REPO_HEAD_REF="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-main}}" \
DEPENDENCY_REPO_URL="https://github.com/smithy-lang/smithy-swift.git" \
./scripts/ci_steps/select_dependency_branch.sh
- name: Checkout smithy-swift
uses: actions/checkout@v3
with:
repository: smithy-lang/smithy-swift
ref: ${{ env.DEPENDENCY_REPO_SHA }}
path: smithy-swift
- name: Move smithy-swift into place
run: mv smithy-swift ..
- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: 1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
1-${{ runner.os }}-gradle-${{ hashFiles('settings.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
1-${{ runner.os }}-gradle-
- name: Cache Swift
uses: actions/cache@v3
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/.cache/org.swift.swiftpm
key: 1-${{ runner.os }}-swift-${{ matrix.version }}-spm-${{ hashFiles('Package.swift', 'AWSSDKSwiftCLI/Package.swift') }}
restore-keys: |
1-${{ runner.os }}-swift-${{ matrix.version }}-spm-${{ hashFiles('Package.swift', 'AWSSDKSwiftCLI/Package.swift') }}
1-${{ runner.os }}-swift-${{ matrix.version }}-spm-
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 17
- name: Install OpenSSL (all OS) and which (AL2 only)
run: ./scripts/ci_steps/install_native_linux_dependencies.sh
- name: Tools Versions
run: ./scripts/ci_steps/log_tool_versions.sh
- name: Prepare Integration Tests
run: ./scripts/ci_steps/prepare_integration_tests.sh
- name: Build Integration Tests
run: swift build --build-tests
- name: Run Integration Tests
run: swift test
19 changes: 2 additions & 17 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
version: 1
builder:
configs:
- platform: macosXcodebuild
target: AWSSTS
- platform: ios
target: AWSSTS
- platform: linux
swift_version: '5.7'
image: registry.gitlab.com/finestructure/spi-images:basic-5.7-latest
target: AWSSTS
- platform: linux
swift_version: '5.8'
image: registry.gitlab.com/finestructure/spi-images:basic-5.8-latest
target: AWSSTS
- platform: linux
swift_version: '5.9'
image: registry.gitlab.com/finestructure/spi-images:basic-5.9-latest
target: AWSSTS

- target: AWSSTS
scheme: AWSSTS
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class ECSCredentialsProviderTests: XCTestCase {
)
}

func test_ecsCredentialsProvider() async throws {
// 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 {
let ecsClient = try await ECSClient()

// create cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class ProcessCredentialProviderTests: XCTestCase {
}

// This test calls listBuckets() and forces S3Client to use ProcessCredentialsProvider
func test_listBuckets() async throws {
// 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())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import AWSClientRuntime
import AwsCommonRuntimeKit
import ClientRuntime

public class MockHttpClientEngine: HttpClientEngine {
public class MockHttpClientEngine: HTTPClient {

// Public initializer
public init() {}
Expand All @@ -33,7 +33,7 @@ public class MockHttpClientEngine: HttpClientEngine {
)
}

public func execute(request: SdkHttpRequest) async throws -> HttpResponse {
public func send(request: SdkHttpRequest) async throws -> HttpResponse {
return successHttpResponse(request: request)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// SPDX-License-Identifier: Apache-2.0
//

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
import XCTest
import AWSS3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// SPDX-License-Identifier: Apache-2.0
//

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
import XCTest
import AWSS3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class SSOCredentialsProviderTests : XCTestCase {
}

// The test calls listBuckets() and forces S3Client to use SSOCredentialsProvider
func test_listBuckets() async throws {
// TODO: Re-enable this test once CI is configured to run it. See https://github.com/awslabs/aws-sdk-swift/issues/1311
func xtest_listBuckets() async throws {
_ = try await client.listBuckets(input: ListBucketsInput())
}

Expand Down
10 changes: 4 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ func addResolvedTargets() {
// MARK: - Generated

addDependencies(
clientRuntimeVersion: "0.37.0",
crtVersion: "0.20.0"
clientRuntimeVersion: "0.39.0",
crtVersion: "0.22.0"
)

// Uncomment this line to exclude runtime unit tests
Expand Down Expand Up @@ -488,6 +488,7 @@ let serviceTargets: [String] = [
"AWSNeptunedata",
"AWSNetworkFirewall",
"AWSNetworkManager",
"AWSNetworkMonitor",
"AWSNimble",
"AWSOAM",
"AWSOSIS",
Expand Down Expand Up @@ -584,6 +585,7 @@ let serviceTargets: [String] = [
"AWSSnowball",
"AWSSsmSap",
"AWSStorageGateway",
"AWSSupplyChain",
"AWSSupport",
"AWSSupportApp",
"AWSSynthetics",
Expand Down Expand Up @@ -632,8 +634,4 @@ let servicesWithIntegrationTests: [String] = [
// Uncomment this line to enable protocol tests
// addProtocolTests()

<<<<<<< HEAD
=======
addResolvedTargets()

>>>>>>> main
2 changes: 1 addition & 1 deletion Package.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.33.0
0.34.0
26 changes: 23 additions & 3 deletions Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ extension AWSClientConfiguration {
if let region = region {
resolvedRegion = region
} else {
resolvedRegion = await resolvedRegionResolver.resolveRegion()
resolvedRegion = await resolvedRegionResolver.getRegion()
}
let resolvedCredentialsProvider: any AWSClientRuntime.CredentialsProviding
if let credentialsProvider = credentialsProvider {
Expand All @@ -210,10 +210,20 @@ extension AWSClientConfiguration {
profileName: nil,
fileBasedConfig: fileBasedConfig
)
var resolvedAuthSchemes: [ClientRuntime.AuthScheme] = []
if let authSchemes = authSchemes {
resolvedAuthSchemes = authSchemes
} else {
resolvedAuthSchemes.append(SigV4AuthScheme())
// These AWS services use SigV4A auth scheme.
if ["S3", "EventBridge", "CloudFront KeyValueStore"].contains(serviceSpecific?.serviceName) {
resolvedAuthSchemes.append(SigV4AAuthScheme())
}
}
let resolvedAppID = AppIDConfig.appID(configValue: appID, profileName: nil, fileBasedConfig: fileBasedConfig)
try self.init(
resolvedCredentialsProvider,
authSchemes,
resolvedAuthSchemes,
endpoint,
serviceSpecific,
resolvedRegion,
Expand Down Expand Up @@ -259,10 +269,20 @@ extension AWSClientConfiguration {
profileName: nil,
fileBasedConfig: fileBasedConfig
)
var resolvedAuthSchemes: [ClientRuntime.AuthScheme] = []
if let authSchemes = authSchemes {
resolvedAuthSchemes = authSchemes
} else {
resolvedAuthSchemes.append(SigV4AuthScheme())
// These AWS services use SigV4A auth scheme.
if ["S3", "EventBridge", "CloudFront KeyValueStore"].contains(serviceSpecific?.serviceName) {
resolvedAuthSchemes.append(SigV4AAuthScheme())
}
}
let resolvedAppID = AppIDConfig.appID(configValue: appID, profileName: nil, fileBasedConfig: fileBasedConfig)
try self.init(
resolvedCredentialsProvider,
authSchemes,
resolvedAuthSchemes,
endpoint,
serviceSpecific,
region,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ public struct AWSS3ErrorWith200StatusXMLMiddleware<OperationStackOutput>: Middle
return response
}

response.httpResponse.body = .data(data)

let xmlString = String(data: data, encoding: .utf8) ?? ""
if xmlString.contains("<Error>") {
// Handle the error as a 500 Internal Server Error
var modifiedResponse = response
let modifiedResponse = response
modifiedResponse.httpResponse.statusCode = .internalServerError
return modifiedResponse
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct Sha256TreeHashMiddleware<OperationStackOutput>: Middleware {
return try await next.handle(context: context, input: input)
}
if !request.headers.exists(name: X_AMZ_CONTENT_SHA256_HEADER_NAME) {
let sha256 = try data.sha256().encodeToHexString()
let sha256 = try data.computeSHA256().encodeToHexString()
input.withHeader(name: X_AMZ_CONTENT_SHA256_HEADER_NAME, value: sha256)
}
case .stream(let stream):
Expand Down Expand Up @@ -66,8 +66,8 @@ public struct Sha256TreeHashMiddleware<OperationStackOutput>: Middleware {
/// See http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html for more information.
private func computeHashes(data: Data) throws -> (String?, String?) {
let ONE_MB = 1024 * 1024
let hashes: [[UInt8]] = try data.chunked(size: ONE_MB).map { try $0.sha256().bytes() }
return try (data.sha256().encodeToHexString(), computeTreeHash(hashes: hashes))
let hashes: [[UInt8]] = try data.chunked(size: ONE_MB).map { try $0.computeSHA256().bytes() }
return try (data.computeSHA256().encodeToHexString(), computeTreeHash(hashes: hashes))
}

/// Builds a tree hash root node given a slice of hashes. Glacier tree hash to be derived from SHA256 hashes
Expand All @@ -87,7 +87,7 @@ public struct Sha256TreeHashMiddleware<OperationStackOutput>: Middleware {
concatenatedLevelHash.append(contentsOf: previousLevelHashes[index])
concatenatedLevelHash.append(contentsOf: previousLevelHashes[index + 1])
let data = Data(concatenatedLevelHash)
currentLevelHashes.append(try data.sha256().bytes())
currentLevelHashes.append(try data.computeSHA256().bytes())

} else {
currentLevelHashes.append(previousLevelHashes[index])
Expand Down
Loading

0 comments on commit 5137a69

Please sign in to comment.