Skip to content

Commit

Permalink
[Storage] Deprecated SAS version fix. (Azure#22321)
Browse files Browse the repository at this point in the history
* fix live tests.

* remember about blobs.
  • Loading branch information
kasobol-msft authored Jun 16, 2021
1 parent 1a92fbe commit 00c4e98
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ private String stringToSign(String canonicalName) {
this.identifier == null ? "" : this.identifier,
this.sasIpRange == null ? "" : this.sasIpRange.toString(),
this.protocol == null ? "" : this.protocol.toString(),
VERSION_DEPRECATED_STRING_TO_SIGN, /* Pin down to version so old string to sign works. */
VERSION, /* Pin down to version so old string to sign works. */
resource,
this.snapshotId == null ? "" : this.snapshotId,
this.cacheControl == null ? "" : this.cacheControl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1047,4 +1047,22 @@ class SasClientTests extends APISpec {
null | null | SasProtocol.HTTPS_ONLY || "%s" + "\nr\nb\no\n\n" + Constants.ISO_8601_UTC_DATE_FORMATTER.format(OffsetDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC)) + "\n\n" + SasProtocol.HTTPS_ONLY + "\n" + Constants.SAS_SERVICE_VERSION + "\n"
}

/**
* If this test fails it means that non-deprecated string to sign has new components.
* In that case we should hardcode version used for deprecated string to sign like we did for user delegation sas.
*/
def "Remember about string to sign deprecation"() {
setup:
def client = sasClient
def values = new BlobServiceSasSignatureValues(namer.getUtcNow(), new BlobSasPermission())
values.setContainerName(sasClient.containerName)
values.setBlobName(sasClient.blobName)

when:
def deprecatedStringToSign = values.generateSasQueryParameters(env.primaryAccount.credential).encode()
def stringToSign = client.generateSas(values)

then:
deprecatedStringToSign == stringToSign
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"networkCallRecords" : [ {
"Method" : "PUT",
"Uri" : "https://REDACTED.blob.core.windows.net/b42ece0b0b42ece0b9ee39361ac816bd27b5a41c888b?restype=container",
"Headers" : {
"x-ms-version" : "2020-08-04",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
"x-ms-client-request-id" : "1b262853-8df9-4b1c-bc1b-008f06123c87"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-08-04",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"eTag" : "0x8D930DC6D95B38C",
"Last-Modified" : "Wed, 16 Jun 2021 15:35:53 GMT",
"retry-after" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "b56ba961-b01e-005c-3ec5-629fe9000000",
"x-ms-client-request-id" : "1b262853-8df9-4b1c-bc1b-008f06123c87",
"Date" : "Wed, 16 Jun 2021 15:35:53 GMT"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://REDACTED.blob.core.windows.net/b42ece0b0b42ece0b9ee39361ac816bd27b5a41c888b/b42ece0b1b42ece0b9ee4800196aa4fe2648d4fbc958",
"Headers" : {
"x-ms-version" : "2020-08-04",
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
"x-ms-client-request-id" : "046df0da-f10e-4a49-b96a-758f1fa1f561",
"Content-Type" : "application/octet-stream"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-08-04",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-content-crc64" : "6RYQPwaVsyQ=",
"Last-Modified" : "Wed, 16 Jun 2021 15:35:54 GMT",
"retry-after" : "0",
"StatusCode" : "201",
"x-ms-request-server-encrypted" : "true",
"Date" : "Wed, 16 Jun 2021 15:35:53 GMT",
"Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==",
"eTag" : "0x8D930DC6DC49B79",
"x-ms-request-id" : "b56baaeb-b01e-005c-27c5-629fe9000000",
"x-ms-client-request-id" : "046df0da-f10e-4a49-b96a-758f1fa1f561"
},
"Exception" : null
} ],
"variables" : [ "b42ece0b0b42ece0b9ee39361ac816bd27b5a41c888b", "b42ece0b1b42ece0b9ee4800196aa4fe2648d4fbc958", "2021-06-16T15:35:54.361036200Z" ]
}

0 comments on commit 00c4e98

Please sign in to comment.