-
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.
fix: Correct query items in presigned URLs, add integration tests (#1573
- Loading branch information
Showing
4 changed files
with
66 additions
and
28 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
IntegrationTests/Services/AWSS3IntegrationTests/S3PresignedURLTests.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,36 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#if canImport(FoundationNetworking) | ||
import FoundationNetworking | ||
#endif | ||
import XCTest | ||
import AWSS3 | ||
|
||
class S3PresignedURLTests: S3XCTestCase { | ||
|
||
func test_getObject_getsObjectWithPresignedURL() async throws { | ||
let originalData = UUID().uuidString | ||
let key = UUID().uuidString | ||
try await putObject(body: originalData, key: key) | ||
let input = GetObjectInput(bucket: bucketName, key: key) | ||
let url = try await client.presignedURLForGetObject(input: input, expiration: 600.0) | ||
let data = try await perform(urlRequest: URLRequest(url: url)) | ||
XCTAssertEqual(Data(originalData.utf8), data) | ||
} | ||
|
||
func test_getObject_urlEncodesInputMembers() async throws { | ||
let key = UUID().uuidString | ||
let originalIfMatch = UUID().uuidString | ||
let originalIfNoneMatch = UUID().uuidString | ||
let input = GetObjectInput(bucket: bucketName, ifMatch: originalIfMatch, ifNoneMatch: originalIfNoneMatch, key: key) | ||
let url = try await client.presignedURLForGetObject(input: input, expiration: 600.0) | ||
let components = URLComponents(url: url, resolvingAgainstBaseURL: false) | ||
XCTAssertNotNil(components?.queryItems?.first(where: { $0.name == "IfMatch" && $0.value == originalIfMatch })) | ||
XCTAssertNotNil(components?.queryItems?.first(where: { $0.name == "IfNoneMatch" && $0.value == originalIfNoneMatch })) | ||
} | ||
} |
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