-
Notifications
You must be signed in to change notification settings - Fork 74
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/fix_modifiedContext_compile_warning
- Loading branch information
Showing
897 changed files
with
409,966 additions
and
551,478 deletions.
There are no files selected for viewing
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
88 changes: 88 additions & 0 deletions
88
IntegrationTests/Services/AWSS3IntegrationTests/S3ErrorTests.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,88 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Foundation | ||
import XCTest | ||
import AWSS3 | ||
import AWSClientRuntime | ||
|
||
class S3ErrorTests: S3XCTestCase { | ||
|
||
func test_noSuchKey_throwsNoSuchKeyWhenUnknownKeyIsUsed() async throws { | ||
do { | ||
let input = GetObjectInput(bucket: bucketName, key: UUID().uuidString) | ||
_ = try await client.getObject(input: input) | ||
XCTFail("Request should not have succeeded") | ||
} catch let error as NoSuchKey { | ||
XCTAssertEqual(error.httpResponse.statusCode, .notFound) | ||
XCTAssertEqual(error.message, "The specified key does not exist.") | ||
} catch { | ||
XCTFail("Unexpected error thrown: \(error)") | ||
} | ||
} | ||
|
||
func test_noSuchBucket_throwsNoSuchBucketWhenUnknownBucketIsUsed() async throws { | ||
do { | ||
let input = ListObjectsV2Input(bucket: bucketName + "x") | ||
_ = try await client.listObjectsV2(input: input) | ||
XCTFail("Request should not have succeeded") | ||
} catch let error as NoSuchBucket { | ||
XCTAssertEqual(error.httpResponse.statusCode, .notFound) | ||
XCTAssertEqual(error.message, "The specified bucket does not exist") | ||
} catch { | ||
XCTFail("Unexpected error thrown: \(error)") | ||
} | ||
} | ||
|
||
func test_requestID_hasARequestIDAndRequestID2() async throws { | ||
do { | ||
let input = GetObjectInput(bucket: bucketName, key: UUID().uuidString) | ||
_ = try await client.getObject(input: input) | ||
XCTFail("Request should not have succeeded") | ||
} catch let error as NoSuchKey { | ||
let requestID = try XCTUnwrap(error.requestID) | ||
let requestID2 = try XCTUnwrap(error.requestID2) | ||
XCTAssertFalse(requestID.isEmpty) | ||
XCTAssertFalse(requestID2.isEmpty) | ||
} catch { | ||
XCTFail("Unexpected error thrown: \(error)") | ||
} | ||
} | ||
|
||
func test_InvalidObjectState_hasReadableProperties() async throws { | ||
do { | ||
let key = UUID().uuidString + ".txt" | ||
let putInput = PutObjectInput(bucket: bucketName, key: key, storageClass: .glacier) | ||
_ = try await client.putObject(input: putInput) | ||
let getInput = GetObjectInput(bucket: bucketName, key: key) | ||
_ = try await client.getObject(input: getInput) | ||
XCTFail("Request should not have succeeded") | ||
} catch let error as InvalidObjectState { | ||
XCTAssertEqual(error.properties.accessTier, nil) | ||
XCTAssertEqual(error.properties.storageClass, .glacier) | ||
XCTAssertEqual(error.message, "The operation is not valid for the object\'s storage class") | ||
} catch { | ||
XCTFail("Unexpected error thrown: \(error)") | ||
} | ||
} | ||
|
||
func test_InvalidAccessKeyID_isThrownWhenAppropriate() async throws { | ||
do { | ||
let credentials = Credentials(accessKey: "AKIDEXAMPLE", secret: "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY") | ||
let credentialsProvider = try StaticCredentialsProvider(credentials) | ||
let config = try S3Client.S3ClientConfiguration(region: region, credentialsProvider: credentialsProvider) | ||
let input = GetObjectInput(bucket: bucketName, key: UUID().uuidString) | ||
_ = try await S3Client(config: config).getObject(input: input) | ||
XCTFail("Request should not have succeeded") | ||
} catch let error as InvalidAccessKeyId { | ||
XCTAssertEqual(error.httpResponse.statusCode, .forbidden) | ||
XCTAssertEqual(error.message, "The AWS Access Key Id you provided does not exist in our records.") | ||
} catch { | ||
XCTFail("Unexpected error thrown: \(error)") | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.17.0 | ||
0.18.0 |
Oops, something went wrong.