Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/azure-cli/azure/cli/command_modules/storage/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
with self.argument_context('storage container exists') as c:
c.ignore('blob_name', 'snapshot')

with self.argument_context('storage container immutability-policy') as c:
c.argument('allow_protected_append_writes', options_list=['--allow-protected-append-writes', '-w'],
arg_type=get_three_state_flag())

with self.argument_context('storage container list') as c:
c.argument('num_results', arg_type=num_results_type)

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,39 @@

class StorageImmutabilityPolicy(ScenarioTest):
@ResourceGroupPreparer()
def test_immutability_policy(self, resource_group):
storage_account = self.create_random_name('clistorage', 20)
self.cmd('storage account create -g {} -n {} --kind StorageV2'.format(
resource_group, storage_account))
@StorageAccountPreparer(kind="StorageV2")
def test_immutability_policy(self, resource_group, storage_account):
container_name = 'container1'
self.cmd('storage container create --account-name {} -n {}'.format(storage_account, container_name))

self.cmd('az storage container immutability-policy create --account-name {} -c {} -g {} --period 1'.format(
self.cmd('az storage container immutability-policy create --account-name {} -c {} -g {} --period 1 -w'.format(
storage_account, container_name, resource_group), checks=[
JMESPathCheck('immutabilityPeriodSinceCreationInDays', 1)])
JMESPathCheck('immutabilityPeriodSinceCreationInDays', 1),
JMESPathCheck('allowProtectedAppendWrites', True)
])

policy_etag = self.cmd('az storage container immutability-policy show --account-name {} -c {} -g {}'.format(
storage_account, container_name, resource_group), checks=[
JMESPathCheck('immutabilityPeriodSinceCreationInDays', 1)]).get_output_in_json().get('etag')
JMESPathCheck('immutabilityPeriodSinceCreationInDays', 1),
JMESPathCheck('allowProtectedAppendWrites', True)
]).get_output_in_json().get('etag')

self.cmd('az storage container immutability-policy delete --account-name {} -c {} -g {} --if-match {}'.format(
storage_account, container_name, resource_group, repr(policy_etag)))

self.cmd('az storage container immutability-policy show --account-name {} -c {} -g {}'.format(
storage_account, container_name, resource_group))

self.cmd('az storage container immutability-policy create --account-name {} -c {} -g {} --period 1'.format(
self.cmd('az storage container immutability-policy create --account-name {} -c {} -g {} --period 1 -w false'.format(
storage_account, container_name, resource_group), checks=[
JMESPathCheck('immutabilityPeriodSinceCreationInDays', 1)])
JMESPathCheck('immutabilityPeriodSinceCreationInDays', 1),
JMESPathCheck('allowProtectedAppendWrites', False)])

policy_etag = self.cmd('az storage container immutability-policy show --account-name {} -c {} -g {}'.format(
storage_account, container_name, resource_group), checks=[
JMESPathCheck('immutabilityPeriodSinceCreationInDays', 1)]).get_output_in_json().get('etag')
JMESPathCheck('immutabilityPeriodSinceCreationInDays', 1),
JMESPathCheck('allowProtectedAppendWrites', False)
]).get_output_in_json().get('etag')

self.cmd('az storage container immutability-policy lock --account-name {} -c {} -g {} --if-match {}'.format(
storage_account, container_name, resource_group, repr(policy_etag)))
Expand Down