-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jbe/better_bridge
- Loading branch information
Showing
429 changed files
with
17,886 additions
and
920 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
IntegrationTests/AWSIntegrationTestUtils/GenerateDataHelper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Foundation | ||
|
||
public func generateRandomTextData(ofSizeInBytes byteCount: Int) -> Data { | ||
let allowedCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".utf8 | ||
let allowedBytes = Array(allowedCharacters) | ||
let randomBytes = (0..<byteCount).map { _ in allowedBytes.randomElement()! } | ||
return Data(randomBytes) | ||
} | ||
|
||
public func generateRandomTextData(ofSizeInMB megabytes: Double) -> Data { | ||
let byteCount = Int(megabytes * 1024 * 1024) // Convert megabytes to bytes | ||
return generateRandomTextData(ofSizeInBytes: byteCount) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
IntegrationTests/Services/AWSS3IntegrationTests/S3ToggleUnsignedPayloadTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import AWSSDKHTTPAuth | ||
import XCTest | ||
import AWSS3 | ||
import ClientRuntime | ||
import AWSClientRuntime | ||
import SmithyHTTPAPI | ||
import AWSIntegrationTestUtils | ||
import class SmithyStreams.BufferedStream | ||
|
||
/// Tests toggle unsigned payload using S3. | ||
class S3ToggleUnsignedPayloadTests: S3XCTestCase { | ||
private var s3Config: S3Client.S3ClientConfiguration! | ||
|
||
override func setUp() async throws { | ||
try await super.setUp() | ||
s3Config = try await S3Client.S3ClientConfiguration(region: region) | ||
s3Config.authSchemes = [SigV4AuthScheme(requestUnsignedBody: true)] | ||
} | ||
|
||
class CheckUnsignedPayloadHeader<InputType, OutputType>: Interceptor { | ||
typealias RequestType = HTTPRequest | ||
typealias ResponseType = HTTPResponse | ||
|
||
func readBeforeTransmit(context: some AfterSerialization<InputType, RequestType>) async throws { | ||
XCTAssertTrue( | ||
context.getRequest().headers.value(for: "x-amz-content-sha256") == "UNSIGNED-PAYLOAD" | ||
) | ||
} | ||
} | ||
|
||
class CheckStreamingUnsignedPayloadHeader<InputType, OutputType>: Interceptor { | ||
typealias RequestType = HTTPRequest | ||
typealias ResponseType = HTTPResponse | ||
|
||
func readBeforeTransmit(context: some AfterSerialization<InputType, RequestType>) async throws { | ||
XCTAssertTrue( | ||
context.getRequest().headers.value(for: "x-amz-content-sha256") == "STREAMING-UNSIGNED-PAYLOAD-TRAILER" | ||
) | ||
} | ||
} | ||
|
||
class CheckUnsignedPayloadHeaderProvider: HttpInterceptorProvider { | ||
func create<InputType, OutputType>() -> any Interceptor<InputType, OutputType, HTTPRequest, HTTPResponse> { | ||
return CheckUnsignedPayloadHeader() | ||
} | ||
} | ||
|
||
class CheckStreamingUnsignedPayloadHeaderProvider: HttpInterceptorProvider { | ||
func create<InputType, OutputType>() -> any Interceptor<InputType, OutputType, HTTPRequest, HTTPResponse> { | ||
return CheckStreamingUnsignedPayloadHeader() | ||
} | ||
} | ||
|
||
func testS3ToggleUnsignedPayloadNonStreaming() async throws { | ||
let key = "test.txt" | ||
let putObjectInput = PutObjectInput( | ||
body: .noStream, | ||
bucket: bucketName, | ||
key: key, | ||
metadata: ["filename": key] | ||
) | ||
|
||
// Upload | ||
s3Config.addInterceptorProvider(CheckUnsignedPayloadHeaderProvider()) | ||
let s3Client = S3Client(config: s3Config) | ||
_ = try await s3Client.putObject(input: putObjectInput) | ||
|
||
// Get | ||
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) | ||
} | ||
|
||
func testS3ToggleUnsignedPayloadStreaming() async throws { | ||
let key = "test-streaming.txt" | ||
let data = generateRandomTextData(ofSizeInMB: 1) | ||
let bufferedStream = BufferedStream(data: data, isClosed: true) | ||
let putObjectInput = PutObjectInput( | ||
body: .stream(bufferedStream), | ||
bucket: bucketName, | ||
key: key, | ||
metadata: ["filename": key] | ||
) | ||
|
||
// Upload | ||
s3Config.addInterceptorProvider(CheckStreamingUnsignedPayloadHeaderProvider()) | ||
let s3Client = S3Client(config: s3Config) | ||
_ = try await s3Client.putObject(input: putObjectInput) | ||
|
||
// Get | ||
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.41 | ||
1.0.42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.42 | ||
1.0.43 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.