Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# --------------------------------------------------------------------------------------------

import os
import requests
from datetime import datetime, timedelta
from azure.cli.testsdk import (LiveScenarioTest, ResourceGroupPreparer, StorageAccountPreparer,
JMESPathCheck, NoneCheck, StringCheck, StringContainCheck)
from ..storage_test_util import StorageScenarioMixin
Expand All @@ -13,11 +15,11 @@ class StorageFileShareScenarios(StorageScenarioMixin, LiveScenarioTest):
@ResourceGroupPreparer()
@StorageAccountPreparer()
def test_storage_file_url_sas_token_scenario(self, resource_group, storage_account):
import requests
account_info = self.get_account_info(resource_group, storage_account)
share = self.create_share(account_info)
source_file = self.create_temp_file(128, full_random=False)
filename = "sample_file.bin"
expiry = (datetime.utcnow() + timedelta(hours=1)).strftime('%Y-%m-%dT%H:%MZ')

self.storage_cmd('storage share exists -n {}', account_info, share) \
.assert_with_checks(JMESPathCheck('exists', True))
Expand All @@ -28,8 +30,8 @@ def test_storage_file_url_sas_token_scenario(self, resource_group, storage_accou
.assert_with_checks(JMESPathCheck('exists', True))

sas_token = self.cmd(
'storage file generate-sas -s {} -p {} --permissions rw --https-only --expiry "2018-11-14T23:50Z" --account-name {} -otsv'.format(
share, filename, storage_account)).output.strip()
'storage file generate-sas -s {} -p {} --permissions rw --https-only --expiry {} --account-name {} -otsv'.format(
share, filename, expiry, storage_account)).output.strip()
# print(sas_token
file_url = self.cmd(
'storage file url -s {} -p {} --account-name {} --sas-token "{}" -otsv'.format(
Expand All @@ -42,11 +44,11 @@ class StorageBlobShareScenarios(StorageScenarioMixin, LiveScenarioTest):
@ResourceGroupPreparer()
@StorageAccountPreparer()
def test_storage_blob_url_sas_token_scenario(self, resource_group, storage_account):
import requests
account_info = self.get_account_info(resource_group, storage_account)
container = self.create_container(account_info)
source_file = self.create_temp_file(128, full_random=False)
blob = "blob"
expiry = (datetime.utcnow() + timedelta(hours=1)).strftime('%Y-%m-%dT%H:%MZ')

self.storage_cmd('storage container exists -n {}', account_info, container) \
.assert_with_checks(JMESPathCheck('exists', True))
Expand All @@ -57,8 +59,8 @@ def test_storage_blob_url_sas_token_scenario(self, resource_group, storage_accou
.assert_with_checks(JMESPathCheck('exists', True))

sas_token = self.cmd(
'storage blob generate-sas -c {} -n {} --permissions rw --https-only --expiry "2018-11-14T23:50Z" --account-name {} -otsv'.format(
container, blob, storage_account)).output.strip()
'storage blob generate-sas -c {} -n {} --permissions rw --https-only --expiry {} --account-name {} -otsv'.format(
container, blob, expiry, storage_account)).output.strip()
# print(sas_token
blob_url = self.cmd(
'storage blob url -c {} -n {} --account-name {} --sas-token "{}" -otsv'.format(
Expand Down