Exemple #1
0
        public async Task ListStorageAccountSAS()
        {
            //create storage account
            string accountName = await CreateValidAccountNameAsync(namePrefix);

            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountContainer        storageAccountContainer = _resourceGroup.GetStorageAccounts();
            StorageAccountCreateParameters parameters = GetDefaultStorageAccountParameters();
            StorageAccount account = (await storageAccountContainer.CreateOrUpdateAsync(accountName, parameters)).Value;

            AccountSasParameters accountSasParameters = new AccountSasParameters(services: "b", resourceTypes: "sco", permissions: "rl", sharedAccessExpiryTime: Recording.UtcNow.AddHours(1))
            {
                Protocols             = HttpProtocol.HttpsHttp,
                SharedAccessStartTime = Recording.UtcNow,
                KeyToSign             = "key1"
            };
            Response <ListAccountSasResponse> result = await account.GetAccountSASAsync(accountSasParameters);

            AccountSasParameters resultCredentials = ParseAccountSASToken(result.Value.AccountSasToken);

            Assert.AreEqual(accountSasParameters.Services, resultCredentials.Services);
            Assert.AreEqual(accountSasParameters.ResourceTypes, resultCredentials.ResourceTypes);
            Assert.AreEqual(accountSasParameters.Permissions, resultCredentials.Permissions);
            Assert.AreEqual(accountSasParameters.Protocols, resultCredentials.Protocols);
            Assert.NotNull(accountSasParameters.SharedAccessStartTime);
            Assert.NotNull(accountSasParameters.SharedAccessExpiryTime);
        }