-
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.
add unit test, integration test, and fix swiftlint
- Loading branch information
Showing
3 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
IntegrationTests/Services/AWSS3IntegrationTests/S3ToggleUnsignedTests.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,45 @@ | ||
// | ||
// 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 | ||
|
||
/// Tests toggle unsigned request using S3. | ||
class S3ToggleUnsignedTests: 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(requestUnsignedBody: true)] | ||
} | ||
|
||
func testS3PresignedRequest() async throws { | ||
let putObjectInput = PutObjectInput( | ||
body: .noStream, | ||
bucket: bucketName, | ||
key: key, | ||
metadata: ["filename": key] | ||
) | ||
|
||
// Upload | ||
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