diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy index a75fc3124aae2..4ac35b4617d5b 100644 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy +++ b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/ServiceAPITest.groovy @@ -3,6 +3,7 @@ package com.azure.storage.blob +import com.azure.core.http.rest.Response import com.azure.core.util.paging.ContinuablePage import com.azure.core.util.Context import com.azure.identity.DefaultAzureCredentialBuilder @@ -500,6 +501,29 @@ class ServiceAPITest extends APISpec { primaryBlobServiceClient.setPropertiesWithResponse(serviceProperties, null, null).getStatusCode() == 202 } + def "Set props static website"() { + setup: + def serviceProperties = primaryBlobServiceClient.getProperties() + def errorDocument404Path = "error/404.html" + def defaultIndexDocumentPath = "index.html" + + serviceProperties.setStaticWebsite(new StaticWebsite() + .setEnabled(true) + .setErrorDocument404Path(errorDocument404Path) + .setDefaultIndexDocumentPath(defaultIndexDocumentPath) + ) + + when: + Response resp = primaryBlobServiceClient.setPropertiesWithResponse(serviceProperties, null, null) + + then: + resp.getStatusCode() == 202 + def staticWebsite = primaryBlobServiceClient.getProperties().getStaticWebsite() + staticWebsite.isEnabled() + staticWebsite.getErrorDocument404Path() == errorDocument404Path + staticWebsite.getDefaultIndexDocumentPath() == defaultIndexDocumentPath + } + def "Set props error"() { when: getServiceClient(primaryCredential, "https://error.blob.core.windows.net") diff --git a/sdk/storage/azure-storage-blob/src/test/resources/session-records/ServiceAPITestsetpropsstaticwebsite.json b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ServiceAPITestsetpropsstaticwebsite.json new file mode 100644 index 0000000000000..01b7ac19d9f06 --- /dev/null +++ b/sdk/storage/azure-storage-blob/src/test/resources/session-records/ServiceAPITestsetpropsstaticwebsite.json @@ -0,0 +1,167 @@ +{ + "networkCallRecords" : [ { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcsetpropsstaticwebsite06467780c979b3ddde4c08?restype=container", + "Headers" : { + "x-ms-version" : "2019-12-12", + "User-Agent" : "azsdk-java-azure-storage-blob/12.8.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "a0237929-2fc2-48d2-9d36-3198897ec00c" + }, + "Response" : { + "x-ms-version" : "2019-12-12", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "ETag" : "0x8D829CE333287C4", + "Last-Modified" : "Thu, 16 Jul 2020 21:21:27 GMT", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "201", + "x-ms-request-id" : "cf0ec229-401e-00a9-6ab7-5b50f0000000", + "Date" : "Thu, 16 Jul 2020 21:21:26 GMT", + "x-ms-client-request-id" : "a0237929-2fc2-48d2-9d36-3198897ec00c" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2019-12-12", + "User-Agent" : "azsdk-java-azure-storage-blob/12.8.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e4c40973-f03d-4fbf-ac76-4297d9b09b8f", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "x-ms-version" : "2019-12-12", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "3497f8a0-601e-0081-01b7-5b3158000000", + "Date" : "Thu, 16 Jul 2020 21:21:27 GMT", + "x-ms-client-request-id" : "e4c40973-f03d-4fbf-ac76-4297d9b09b8f" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.blob.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2019-12-12", + "User-Agent" : "azsdk-java-azure-storage-blob/12.8.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "14d580fc-168a-4a74-bca7-67fe450e9893" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-12-12", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "e89856b4-001e-003e-58b7-5b06fd000000", + "Body" : "1.0falsefalsefalsefalse1.0falsefalse1.0falsefalsefalsefalse2018-03-28", + "Date" : "Thu, 16 Jul 2020 21:21:27 GMT", + "x-ms-client-request-id" : "14d580fc-168a-4a74-bca7-67fe450e9893", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2019-12-12", + "User-Agent" : "azsdk-java-azure-storage-blob/12.8.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "e292e018-e57e-4c22-96c5-02348cd8e47f", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "x-ms-version" : "2019-12-12", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "26455ead-d01e-0084-5db7-5be383000000", + "Date" : "Thu, 16 Jul 2020 21:21:29 GMT", + "x-ms-client-request-id" : "e292e018-e57e-4c22-96c5-02348cd8e47f" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.blob.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2019-12-12", + "User-Agent" : "azsdk-java-azure-storage-blob/12.8.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "2408daa9-7769-4e53-8d73-480700f09b0f" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-12-12", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "a6f24a4d-d01e-002d-16b7-5b22f1000000", + "Body" : "1.0falsefalsefalsefalse1.0falsefalse1.0falsefalsefalsetrueerror/404.htmlindex.html2018-03-28", + "Date" : "Thu, 16 Jul 2020 21:21:29 GMT", + "x-ms-client-request-id" : "2408daa9-7769-4e53-8d73-480700f09b0f", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "PUT", + "Uri" : "https://REDACTED.blob.core.windows.net?restype=service&comp=properties", + "Headers" : { + "x-ms-version" : "2019-12-12", + "User-Agent" : "azsdk-java-azure-storage-blob/12.8.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "13ed5fe5-53a8-4cff-8eaa-afac0bbaf0aa", + "Content-Type" : "application/xml; charset=utf-8" + }, + "Response" : { + "x-ms-version" : "2019-12-12", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "c6b6e441-e01e-0026-6bb7-5bd99a000000", + "Date" : "Thu, 16 Jul 2020 21:21:30 GMT", + "x-ms-client-request-id" : "13ed5fe5-53a8-4cff-8eaa-afac0bbaf0aa" + }, + "Exception" : null + }, { + "Method" : "GET", + "Uri" : "https://REDACTED.blob.core.windows.net?prefix=jtcsetpropsstaticwebsite&comp=list", + "Headers" : { + "x-ms-version" : "2019-12-12", + "User-Agent" : "azsdk-java-azure-storage-blob/12.8.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "0ac05704-d967-4655-b38a-e1a7afd8b863" + }, + "Response" : { + "Transfer-Encoding" : "chunked", + "x-ms-version" : "2019-12-12", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "StatusCode" : "200", + "x-ms-request-id" : "df03d5c0-801e-0030-29b7-5b2f4d000000", + "Body" : "jtcsetpropsstaticwebsitejtcsetpropsstaticwebsite06467780c979b3ddde4c08Thu, 16 Jul 2020 21:21:27 GMT\"0x8D829CE333287C4\"unlockedavailable$account-encryption-keyfalsefalsefalse", + "Date" : "Thu, 16 Jul 2020 21:21:30 GMT", + "x-ms-client-request-id" : "0ac05704-d967-4655-b38a-e1a7afd8b863", + "Content-Type" : "application/xml" + }, + "Exception" : null + }, { + "Method" : "DELETE", + "Uri" : "https://REDACTED.blob.core.windows.net/jtcsetpropsstaticwebsite06467780c979b3ddde4c08?restype=container", + "Headers" : { + "x-ms-version" : "2019-12-12", + "User-Agent" : "azsdk-java-azure-storage-blob/12.8.0-beta.2 (11.0.7; Windows 10; 10.0)", + "x-ms-client-request-id" : "6adf86fc-027e-4ddb-95dc-80d2006a978f" + }, + "Response" : { + "x-ms-version" : "2019-12-12", + "Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", + "retry-after" : "0", + "Content-Length" : "0", + "StatusCode" : "202", + "x-ms-request-id" : "61ba550b-201e-0029-11b7-5baff6000000", + "Date" : "Thu, 16 Jul 2020 21:21:30 GMT", + "x-ms-client-request-id" : "6adf86fc-027e-4ddb-95dc-80d2006a978f" + }, + "Exception" : null + } ], + "variables" : [ "jtcsetpropsstaticwebsite06467780c979b3ddde4c08" ] +} \ No newline at end of file