Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update azure_rm_storageaccount relate test yml #488

Merged
merged 4 commits into from
Apr 14, 2021
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
2 changes: 2 additions & 0 deletions plugins/module_utils/azure_rm_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,7 @@ def search_client(self):
api_version='2020-08-01')
return self._search_client

@property
def datalake_store_client(self):
self.log('Getting datalake store client...')
if not self._datalake_store_client:
Expand All @@ -1320,6 +1321,7 @@ def datalake_store_client(self):
api_version='2016-11-01')
return self._datalake_store_client

@property
def datalake_store_models(self):
return DataLakeStoreAccountModel

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/azure_rm_cognitivesearch/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cloud/azure
shippable/azure/group2
shippable/azure/group10
destructive
48 changes: 32 additions & 16 deletions tests/integration/targets/azure_rm_storageaccount/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
- name: Set Storage Account Names
set_fact:
storage_account_name_default: "sa{{ resource_group | hash('md5') | truncate(22, True, '') }}"
storage_account_name_explicit: "sa{{ resource_group | hash('sha1') | truncate(22, True, '') }}"
storage_account_name_default: "sa{{ resource_group | hash('md5') | truncate(20, True, '') }}"
storage_account_name_explicit: "sa{{ resource_group | hash('sha1') | truncate(20, True, '') }}"

- name: Test invalid account name
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
resource_group: "{{ resource_group }}"
name: "invalid_char$"
account_type: Standard_LRS
register: output
ignore_errors: yes
ignore_errors: yes

- name: Check intentional name failure.
assert:
Expand All @@ -19,17 +19,18 @@

- name: Delete storage accounts to prepare fresh deployment
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
resource_group: "{{ resource_group }}"
name: "{{ item }}"
state: absent
force_delete_nonempty: True
loop:
- "{{ storage_account_name_default }}"
- "{{ storage_account_name_explicit }}"
- "{{ storage_account_name_default }}02"

- name: Create new storage account with defaults (omitted parameters)
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_default }}"
account_type: Standard_LRS
register: defaults_output
Expand All @@ -45,6 +46,20 @@
- defaults_output.state.allow_blob_public_access == None
- defaults_output.state.minimum_tls_version == None

- name: Create new storage account with I(kind=FileStorage)
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_default }}02"
account_type: Premium_ZRS
kind: FileStorage
register: filestorage_output

- name: Assert status succeeded and results match I(kind=FileStorage)
assert:
that:
- filestorage_output.changed
- filestorage_output.state.sku_name == "Premium_ZRS"

- name: Create new storage account with explicit parameters
azure_rm_storageaccount:
access_tier: Hot
Expand Down Expand Up @@ -75,7 +90,7 @@
ip_rules:
- value: '9.9.9.9'
action: Allow
resource_group: "{{ resource_group }}"
resource_group: "{{ resource_group }}"
tags:
test: test
galaxy: galaxy
Expand Down Expand Up @@ -124,7 +139,7 @@
ip_rules:
- value: '9.9.9.9'
action: Allow
resource_group: "{{ resource_group }}"
resource_group: "{{ resource_group }}"
tags:
test: test
galaxy: galaxy
Expand Down Expand Up @@ -154,7 +169,7 @@

- name: Update existing storage account with parameters omitted
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_explicit }}"
register: output

Expand Down Expand Up @@ -182,7 +197,7 @@

- name: Update existing storage account with parameters defined
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_default }}"
allow_blob_public_access: False
append_tags: no
Expand Down Expand Up @@ -230,21 +245,21 @@

- name: Change existing account type (invalid)
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_default }}"
account_type: Premium_LRS
register: output
ignore_errors: yes
ignore_errors: yes

- name: Assert account type change failed
- name: Assert account type change failed
assert:
that:
- output.failed
- output.msg is regex('Storage account of type .* cannot be changed')

- name: Unverified custom domain failure
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
resource_group: "{{ resource_group }}"
name: "{{ storage_account_name_default }}"
custom_domain:
name: ansible.com
Expand Down Expand Up @@ -300,7 +315,7 @@
- output.storageaccounts[0].account_type == "Premium_LRS"
- output.storageaccounts[0].primary_endpoints.blob.connectionstring
- output.storageaccounts[0].blob_cors
- output.storageaccounts[0].minimum_tls_version == "TLS1_2"
- output.storageaccounts[0].minimum_tls_version == "TLS1_2"
- not output.storageaccounts[0].allow_blob_public_access
- not output.storageaccounts[0].https_only
- output.storageaccounts[0].network_acls.bypass == "AzureServices"
Expand All @@ -318,10 +333,11 @@

- name: Delete storage accounts
azure_rm_storageaccount:
resource_group: "{{ resource_group }}"
resource_group: "{{ resource_group }}"
name: "{{ item }}"
state: absent
force_delete_nonempty: True
loop:
- "{{ storage_account_name_default }}"
- "{{ storage_account_name_default }}02"
- "{{ storage_account_name_explicit }}"