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

Commit 5c1111d

Browse files
committed
Get vanilla empty query: key.
1 parent 6dfcbae commit 5c1111d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Tests/AWSTests/SignatureTestSuite.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class SignatureTestSuite: XCTestCase {
1515
("testGetUnreserved", testGetUnreserved),
1616
("testGetUTF8", testGetUTF8),
1717
("testGetVanilla", testGetVanilla),
18+
("testGetVanillaQuery", testGetVanillaQuery),
19+
("testGetVanillaEmptyQueryKey", testGetVanillaEmptyQueryKey),
1820
("testPostVanilla", testPostVanilla),
1921
("testPostVanillaQuery", testPostVanillaQuery),
2022
("testPostVanillaQueryNonunreserved", testPostVanillaQueryNonunreserved)
@@ -84,6 +86,44 @@ class SignatureTestSuite: XCTestCase {
8486
)
8587
}
8688

89+
//duplicate as `testGetVanilla`, but is in Amazon Test Suite
90+
//will keep until I figure out why there's a duplicate test
91+
func testGetVanillaQuery() {
92+
let expectedCanonicalRequest = "GET\n/\n\nhost:example.amazonaws.com\nx-amz-date:20150830T123600Z\n\nhost;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
93+
94+
let expectedCredentialScope = "20150830/us-east-1/service/aws4_request"
95+
96+
let expectedCanonicalHeaders: [HeaderKey : String] = [
97+
"X-Amz-Date": "20150830T123600Z",
98+
"Authorization": "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31"
99+
]
100+
101+
let result = sign(method: .get, path: "/")
102+
result.expect(
103+
canonicalRequest: expectedCanonicalRequest,
104+
credentialScope: expectedCredentialScope,
105+
canonicalHeaders: expectedCanonicalHeaders
106+
)
107+
}
108+
109+
func testGetVanillaEmptyQueryKey() {
110+
let expectedCanonicalRequest = "GET\n/\nParam1=value1\nhost:example.amazonaws.com\nx-amz-date:20150830T123600Z\n\nhost;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
111+
112+
let expectedCredentialScope = "20150830/us-east-1/service/aws4_request"
113+
114+
let expectedCanonicalHeaders: [HeaderKey : String] = [
115+
"X-Amz-Date": "20150830T123600Z",
116+
"Authorization": "AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;x-amz-date, Signature=a67d582fa61cc504c4bae71f336f98b97f1ea3c7a6bfe1b6e45aec72011b9aeb"
117+
]
118+
119+
let result = sign(method: .get, path: "/", requestParam: "Param1=value1")
120+
result.expect(
121+
canonicalRequest: expectedCanonicalRequest,
122+
credentialScope: expectedCredentialScope,
123+
canonicalHeaders: expectedCanonicalHeaders
124+
)
125+
}
126+
87127
func testPostVanilla() {
88128
let expectedCanonicalRequest = "POST\n/\n\nhost:example.amazonaws.com\nx-amz-date:20150830T123600Z\n\nhost;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
89129

0 commit comments

Comments
 (0)