Skip to content

Commit 00c4e98

Browse files
authored
[Storage] Deprecated SAS version fix. (Azure#22321)
* fix live tests. * remember about blobs.
1 parent 1a92fbe commit 00c4e98

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/sas/BlobServiceSasSignatureValues.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ private String stringToSign(String canonicalName) {
707707
this.identifier == null ? "" : this.identifier,
708708
this.sasIpRange == null ? "" : this.sasIpRange.toString(),
709709
this.protocol == null ? "" : this.protocol.toString(),
710-
VERSION_DEPRECATED_STRING_TO_SIGN, /* Pin down to version so old string to sign works. */
710+
VERSION, /* Pin down to version so old string to sign works. */
711711
resource,
712712
this.snapshotId == null ? "" : this.snapshotId,
713713
this.cacheControl == null ? "" : this.cacheControl,

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/SasClientTests.groovy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,4 +1047,22 @@ class SasClientTests extends APISpec {
10471047
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"
10481048
}
10491049

1050+
/**
1051+
* If this test fails it means that non-deprecated string to sign has new components.
1052+
* In that case we should hardcode version used for deprecated string to sign like we did for user delegation sas.
1053+
*/
1054+
def "Remember about string to sign deprecation"() {
1055+
setup:
1056+
def client = sasClient
1057+
def values = new BlobServiceSasSignatureValues(namer.getUtcNow(), new BlobSasPermission())
1058+
values.setContainerName(sasClient.containerName)
1059+
values.setBlobName(sasClient.blobName)
1060+
1061+
when:
1062+
def deprecatedStringToSign = values.generateSasQueryParameters(env.primaryAccount.credential).encode()
1063+
def stringToSign = client.generateSas(values)
1064+
1065+
then:
1066+
deprecatedStringToSign == stringToSign
1067+
}
10501068
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"networkCallRecords" : [ {
3+
"Method" : "PUT",
4+
"Uri" : "https://REDACTED.blob.core.windows.net/b42ece0b0b42ece0b9ee39361ac816bd27b5a41c888b?restype=container",
5+
"Headers" : {
6+
"x-ms-version" : "2020-08-04",
7+
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
8+
"x-ms-client-request-id" : "1b262853-8df9-4b1c-bc1b-008f06123c87"
9+
},
10+
"Response" : {
11+
"content-length" : "0",
12+
"x-ms-version" : "2020-08-04",
13+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
14+
"eTag" : "0x8D930DC6D95B38C",
15+
"Last-Modified" : "Wed, 16 Jun 2021 15:35:53 GMT",
16+
"retry-after" : "0",
17+
"StatusCode" : "201",
18+
"x-ms-request-id" : "b56ba961-b01e-005c-3ec5-629fe9000000",
19+
"x-ms-client-request-id" : "1b262853-8df9-4b1c-bc1b-008f06123c87",
20+
"Date" : "Wed, 16 Jun 2021 15:35:53 GMT"
21+
},
22+
"Exception" : null
23+
}, {
24+
"Method" : "PUT",
25+
"Uri" : "https://REDACTED.blob.core.windows.net/b42ece0b0b42ece0b9ee39361ac816bd27b5a41c888b/b42ece0b1b42ece0b9ee4800196aa4fe2648d4fbc958",
26+
"Headers" : {
27+
"x-ms-version" : "2020-08-04",
28+
"User-Agent" : "azsdk-java-azure-storage-blob/12.13.0-beta.1 (11; Windows 10; 10.0)",
29+
"x-ms-client-request-id" : "046df0da-f10e-4a49-b96a-758f1fa1f561",
30+
"Content-Type" : "application/octet-stream"
31+
},
32+
"Response" : {
33+
"content-length" : "0",
34+
"x-ms-version" : "2020-08-04",
35+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
36+
"x-ms-content-crc64" : "6RYQPwaVsyQ=",
37+
"Last-Modified" : "Wed, 16 Jun 2021 15:35:54 GMT",
38+
"retry-after" : "0",
39+
"StatusCode" : "201",
40+
"x-ms-request-server-encrypted" : "true",
41+
"Date" : "Wed, 16 Jun 2021 15:35:53 GMT",
42+
"Content-MD5" : "wh+Wm18D0z1D4E+PE252gg==",
43+
"eTag" : "0x8D930DC6DC49B79",
44+
"x-ms-request-id" : "b56baaeb-b01e-005c-27c5-629fe9000000",
45+
"x-ms-client-request-id" : "046df0da-f10e-4a49-b96a-758f1fa1f561"
46+
},
47+
"Exception" : null
48+
} ],
49+
"variables" : [ "b42ece0b0b42ece0b9ee39361ac816bd27b5a41c888b", "b42ece0b1b42ece0b9ee4800196aa4fe2648d4fbc958", "2021-06-16T15:35:54.361036200Z" ]
50+
}

0 commit comments

Comments
 (0)