public async Task CloudBlobContainerPublicAccessAsync() { CloudBlockBlob testBlockBlob = this.testContainer.GetBlockBlobReference("blockblob"); await UploadTextAsync(testBlockBlob, "blob", Encoding.UTF8); CloudPageBlob testPageBlob = this.testContainer.GetPageBlobReference("pageblob"); await UploadTextAsync(testPageBlob, "blob", Encoding.UTF8); BlobContainerPermissions permissions = new BlobContainerPermissions(); permissions.PublicAccess = BlobContainerPublicAccessType.Container; await this.testContainer.SetPermissionsAsync(permissions); await Task.Delay(30 * 1000); await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Read, null, this.testContainer, testBlockBlob); await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Read, null, this.testContainer, testPageBlob); permissions.PublicAccess = BlobContainerPublicAccessType.Blob; await this.testContainer.SetPermissionsAsync(permissions); await Task.Delay(30 * 1000); await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.Read, null, this.testContainer, testBlockBlob); await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.Read, null, this.testContainer, testPageBlob); }
public async Task CloudBlobContainerPublicAccessAsync() { CloudBlockBlob testBlockBlob = this.testContainer.GetBlockBlobReference("blockblob"); await UploadTextAsync(testBlockBlob, "blob", Encoding.UTF8); CloudPageBlob testPageBlob = this.testContainer.GetPageBlobReference("pageblob"); await UploadTextAsync(testPageBlob, "blob", Encoding.UTF8); BlobContainerPermissions permissions = new BlobContainerPermissions(); permissions.PublicAccess = BlobContainerPublicAccessType.Container; await this.testContainer.SetPermissionsAsync(permissions); await Task.Delay(30 * 1000); await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Read, null, this.testContainer, testBlockBlob, setBlobMetadataWhileSasExpectedStatusCode : HttpStatusCode.NotFound, deleteBlobWhileSasExpectedStatusCode : HttpStatusCode.NotFound); await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.List | SharedAccessBlobPermissions.Read, null, this.testContainer, testPageBlob, setBlobMetadataWhileSasExpectedStatusCode : HttpStatusCode.NotFound, deleteBlobWhileSasExpectedStatusCode : HttpStatusCode.NotFound); permissions.PublicAccess = BlobContainerPublicAccessType.Blob; await this.testContainer.SetPermissionsAsync(permissions); await Task.Delay(30 * 1000); await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.Read, null, this.testContainer, testBlockBlob, setBlobMetadataWhileSasExpectedStatusCode : HttpStatusCode.NotFound, deleteBlobWhileSasExpectedStatusCode : HttpStatusCode.NotFound, listBlobWhileSasExpectedStatusCode : HttpStatusCode.NotFound); await SASTests.TestAccessAsync(null, SharedAccessBlobPermissions.Read, null, this.testContainer, testPageBlob, setBlobMetadataWhileSasExpectedStatusCode : HttpStatusCode.NotFound, deleteBlobWhileSasExpectedStatusCode : HttpStatusCode.NotFound, listBlobWhileSasExpectedStatusCode : HttpStatusCode.NotFound); }
private static async Task TestBlobSASAsync(ICloudBlob testBlob, SharedAccessBlobPermissions permissions) { await UploadTextAsync(testBlob, "blob", Encoding.UTF8); SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy() { SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5), SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30), Permissions = permissions, }; string sasToken = testBlob.GetSharedAccessSignature(policy); await SASTests.TestAccessAsync(sasToken, permissions, null, testBlob); }
public async Task CloudBlobContainerSASCombinationsAsync() { for (int i = 1; i < 16; i++) { SharedAccessBlobPermissions permissions = (SharedAccessBlobPermissions)i; SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy() { SharedAccessStartTime = DateTimeOffset.UtcNow.AddMinutes(-5), SharedAccessExpiryTime = DateTimeOffset.UtcNow.AddMinutes(30), Permissions = permissions, }; string sasToken = this.testContainer.GetSharedAccessSignature(policy); CloudBlockBlob testBlockBlob = this.testContainer.GetBlockBlobReference("blockblob" + i); await UploadTextAsync(testBlockBlob, "blob", Encoding.UTF8); await SASTests.TestAccessAsync(sasToken, permissions, null, this.testContainer, testBlockBlob); CloudPageBlob testPageBlob = this.testContainer.GetPageBlobReference("pageblob" + i); await UploadTextAsync(testPageBlob, "blob", Encoding.UTF8); await SASTests.TestAccessAsync(sasToken, permissions, null, this.testContainer, testPageBlob); } }