diff --git a/.spi.yml b/.spi.yml index cfd18808248..a0b84a53a52 100644 --- a/.spi.yml +++ b/.spi.yml @@ -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 diff --git a/IntegrationTests/Services/AWSMediaConvertIntegrationTests/AWSMediaConvertTests.swift b/IntegrationTests/Services/AWSMediaConvertIntegrationTests/AWSMediaConvertTests.swift index 387c569e43b..5bca0f3ce4d 100644 --- a/IntegrationTests/Services/AWSMediaConvertIntegrationTests/AWSMediaConvertTests.swift +++ b/IntegrationTests/Services/AWSMediaConvertIntegrationTests/AWSMediaConvertTests.swift @@ -88,7 +88,8 @@ class AWSMediaConvertTests: XCTestCase { let input2 = GetJobTemplateInput(name: name) let output2 = try await client.getJobTemplate(input: input2) - // Verify the name of the retrieved template is the same as the - XCTAssertEqual(output2.jobTemplate?.name, name) + // Verify the name of the created & retrieved templates is the same as the original + XCTAssertEqual(output1.jobTemplate?.name, name) + XCTAssertEqual(output1.jobTemplate?.name, output2.jobTemplate?.name) } } diff --git a/IntegrationTests/Services/AWSS3IntegrationTests/S3ErrorIn200Test.swift b/IntegrationTests/Services/AWSS3IntegrationTests/S3ErrorIn200Test.swift index d2fa2f078a4..7c2791581c2 100644 --- a/IntegrationTests/Services/AWSS3IntegrationTests/S3ErrorIn200Test.swift +++ b/IntegrationTests/Services/AWSS3IntegrationTests/S3ErrorIn200Test.swift @@ -12,7 +12,7 @@ import AWSClientRuntime import AwsCommonRuntimeKit import ClientRuntime -public class MockHttpClientEngine: HttpClientEngine { +public class MockHttpClientEngine: HTTPClient { // Public initializer public init() {} @@ -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) } } diff --git a/IntegrationTests/Services/AWSS3IntegrationTests/S3StreamTests.swift b/IntegrationTests/Services/AWSS3IntegrationTests/S3StreamTests.swift index 03d22402d92..83864750e18 100644 --- a/IntegrationTests/Services/AWSS3IntegrationTests/S3StreamTests.swift +++ b/IntegrationTests/Services/AWSS3IntegrationTests/S3StreamTests.swift @@ -7,7 +7,7 @@ import XCTest import AWSS3 -import ClientRuntime +@testable import ClientRuntime final class S3StreamTests: S3XCTestCase { let objectName = "hello-world" @@ -43,7 +43,7 @@ final class S3StreamTests: S3XCTestCase { func test_putObject_givenStreamBody() async throws { let audioURL = Bundle.module.url(forResource: objectName, withExtension: nil)! let fileHandle = FileHandle(forReadingAtPath: audioURL.relativePath)! - let fileByteStream = try ByteStream.data(try fileHandle.readToEnd() ?? Data()) + let fileByteStream = ByteStream.stream(FileStream(fileHandle: fileHandle)) let input = PutObjectInput(body: fileByteStream, bucket: bucketName, key: objectName) let output = try await client.putObject(input: input) XCTAssertNotNil(output) diff --git a/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift b/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift index bf9a005b677..13af83cf57c 100644 --- a/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift +++ b/IntegrationTests/Services/AWSTranscribeStreamingIntegrationTests/TranscribeStreamingTests.swift @@ -12,11 +12,20 @@ import AWSTranscribeStreaming final class TranscribeStreamingTests: XCTestCase { func testStartStreamTranscription() async throws { + + // The heelo-swift.wav resource is an audio file that contains an automated voice + // saying the words "Hello transcribed streaming from Swift S. D. K.". + // It is 2.976 seconds in duration. let audioURL = Bundle.module.url(forResource: "hello-swift", withExtension: "wav")! let audioData = try Data(contentsOf: audioURL) + // A delay will be imposed between chunks to keep the audio streaming to the Teranscribe + // service at approximately real-time. + let duration = 2.976 let chunkSize = 4096 let audioDataSize = audioData.count + let dataRate = Double(audioDataSize) / duration + let delay = Double(chunkSize) / dataRate let client = try TranscribeStreamingClient(region: "us-west-2") @@ -26,6 +35,7 @@ final class TranscribeStreamingTests: XCTestCase { var currentEnd = min(chunkSize, audioDataSize - currentStart) while currentStart < audioDataSize { + if currentStart != 0 { try await Task.sleep(nanoseconds: UInt64(delay * 1_000_000_000)) } let dataChunk = audioData[currentStart ..< currentEnd] let audioEvent = TranscribeStreamingClientTypes.AudioStream.audioevent(.init(audioChunk: dataChunk)) diff --git a/Package.swift b/Package.swift index c253bb9cdc2..cde570ac269 100644 --- a/Package.swift +++ b/Package.swift @@ -230,8 +230,8 @@ func addResolvedTargets() { // MARK: - Generated addDependencies( - clientRuntimeVersion: "0.37.0", - crtVersion: "0.20.0" + clientRuntimeVersion: "0.38.0", + crtVersion: "0.22.0" ) // Uncomment this line to exclude runtime unit tests diff --git a/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift b/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift index 9008a28f6ca..9de3c811d82 100644 --- a/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift +++ b/Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift @@ -30,10 +30,12 @@ public class AWSClientConfiguration @@ -134,13 +131,8 @@ public class AWSClientConfiguration: 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): @@ -66,8 +66,8 @@ public struct Sha256TreeHashMiddleware: 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 @@ -87,7 +87,7 @@ public struct Sha256TreeHashMiddleware: 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]) diff --git a/Sources/Core/AWSClientRuntime/Regions/BundleRegionProvider.swift b/Sources/Core/AWSClientRuntime/Regions/BundleRegionProvider.swift deleted file mode 100644 index 68b3efd0a20..00000000000 --- a/Sources/Core/AWSClientRuntime/Regions/BundleRegionProvider.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright Amazon.com Inc. or its affiliates. -// All Rights Reserved. -// -// SPDX-License-Identifier: Apache-2.0 -// -import AwsCommonRuntimeKit -import ClientRuntime - -public struct BundleRegionProvider: RegionProvider { - private let logger: SwiftLogger - private let bundle: Bundle - private let regionKey: String - private let maxSizeRegion = 38 - - public init(bundle: Bundle = Bundle.main, regionKey: String = "AWS_REGION") { - self.logger = SwiftLogger(label: "BundleRegionProvider") - self.bundle = bundle - self.regionKey = regionKey - } - - public func getRegion() async throws -> String? { - #if os(iOS) || os(watchOS) || os(tvOS) - guard let region = region() else { - return nil - } - - if region.count > maxSizeRegion { - return String(region.prefix(maxSizeRegion)) - } else { - return region - } - #else - return nil - #endif - } - - func region() -> String? { - do { - return try BundleConfiguration.value(bundle: self.bundle, for: regionKey) - } catch { - logger.debug("\(error)") - } - return nil - } -} diff --git a/Sources/Core/AWSClientRuntime/Regions/DefaultRegionResolver.swift b/Sources/Core/AWSClientRuntime/Regions/DefaultRegionResolver.swift index fe75f01c61d..a331ab3b895 100644 --- a/Sources/Core/AWSClientRuntime/Regions/DefaultRegionResolver.swift +++ b/Sources/Core/AWSClientRuntime/Regions/DefaultRegionResolver.swift @@ -13,7 +13,6 @@ public struct DefaultRegionResolver: RegionResolver { public init(fileBasedConfigurationProvider: @escaping FileBasedConfigurationProviding) throws { self.providers = [ - BundleRegionProvider(), EnvironmentRegionProvider(), ProfileRegionProvider(fileBasedConfigurationProvider: fileBasedConfigurationProvider), try IMDSRegionProvider() diff --git a/Tests/Core/AWSClientRuntimeTests/AWSClientConfigurationTests.swift b/Tests/Core/AWSClientRuntimeTests/AWSClientConfigurationTests.swift index 1a6769ab5fb..e7fcda6a3f0 100644 --- a/Tests/Core/AWSClientRuntimeTests/AWSClientConfigurationTests.swift +++ b/Tests/Core/AWSClientRuntimeTests/AWSClientConfigurationTests.swift @@ -63,14 +63,6 @@ class AWSClientConfigurationTests: XCTestCase { let subject = try await Subject(region: region, appID: appID) XCTAssertEqual(subject.appID, appID) } - - // MARK: - Timeout - - func test_sync_configureTimeoutOptionsFromParams() throws { - let customTimeout: UInt32 = 10_000 - let subject = try Subject(region: region, connectTimeoutMs: customTimeout) - XCTAssertEqual(subject.connectTimeoutMs, customTimeout) - } } struct TestAWSServiceSpecificConfiguration: AWSServiceSpecificConfiguration { diff --git a/Tests/Core/AWSClientRuntimeTests/Sigv4/SigV4SigningTests.swift b/Tests/Core/AWSClientRuntimeTests/Sigv4/SigV4SigningTests.swift index d65b719e92f..986616b525d 100644 --- a/Tests/Core/AWSClientRuntimeTests/Sigv4/SigV4SigningTests.swift +++ b/Tests/Core/AWSClientRuntimeTests/Sigv4/SigV4SigningTests.swift @@ -77,7 +77,7 @@ class Sigv4SigningTests: XCTestCase { let signingConfig = try! await context.makeEventStreamSigningConfig(date: epoch.withoutFractionalSeconds()) - let prevSignature = try! "last message sts".data(using: .utf8)!.sha256().encodeToHexString() + let prevSignature = try! "last message sts".data(using: .utf8)!.computeSHA256().encodeToHexString() let messagePayload = try! encoder.encode(message: message) diff --git a/packageDependencies.plist b/packageDependencies.plist index 3efe633b81f..b67f81567a9 100644 --- a/packageDependencies.plist +++ b/packageDependencies.plist @@ -5,10 +5,10 @@ awsCRTSwiftBranch main awsCRTSwiftVersion - 0.20.0 + 0.22.0 clientRuntimeBranch main clientRuntimeVersion - 0.37.0 + 0.38.0