Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit 7ce7269

Browse files
committed
Get vanilla query unreserved.
1 parent 5c1111d commit 7ce7269

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Sources/Driver/Authentication/Authentication.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct Authentication {
2525
var unitTestDate: Date?
2626

2727
static let awsQueryAllowed = CharacterSet(
28-
charactersIn: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ="
28+
charactersIn: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-._~="
2929
)
3030

3131
var amzDate: String {

Tests/AWSTests/SignatureTestSuite.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,28 @@ class SignatureTestSuite: XCTestCase {
124124
)
125125
}
126126

127+
func testGetVanillaQueryUnreserved() {
128+
let expectedCanonicalRequest = "GET\n/\n-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\nhost:example.amazonaws.com\nx-amz-date:20150830T123600Z\n\nhost;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
129+
130+
let expectedCredentialScope = "20150830/us-east-1/service/aws4_request"
131+
132+
let expectedCanonicalHeaders: [HeaderKey : String] = [
133+
"X-Amz-Date": "20150830T123600Z",
134+
"Authorization": "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=9c3e54bfcdf0b19771a7f523ee5669cdf59bc7cc0884027167c21bb143a40197"
135+
]
136+
137+
let result = sign(
138+
method: .get,
139+
path: "/",
140+
requestParam:"-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz=-._~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
141+
)
142+
result.expect(
143+
canonicalRequest: expectedCanonicalRequest,
144+
credentialScope: expectedCredentialScope,
145+
canonicalHeaders: expectedCanonicalHeaders
146+
)
147+
}
148+
127149
func testPostVanilla() {
128150
let expectedCanonicalRequest = "POST\n/\n\nhost:example.amazonaws.com\nx-amz-date:20150830T123600Z\n\nhost;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
129151

0 commit comments

Comments
 (0)