diff --git a/plugins/modules/azure_rm_webappaccessrestriction.py b/plugins/modules/azure_rm_webappaccessrestriction.py index a8a3f5952..41978088d 100644 --- a/plugins/modules/azure_rm_webappaccessrestriction.py +++ b/plugins/modules/azure_rm_webappaccessrestriction.py @@ -316,9 +316,9 @@ def get_updated_config(self, site_config): return site_config def has_updates(self, site_config): - return (self.ip_security_restrictions != self.to_restriction_dict_list(site_config.ip_security_restrictions) - or self.scm_ip_security_restrictions != self.to_restriction_dict_list(site_config.scm_ip_security_restrictions) - or site_config.scm_ip_security_restrictions_use_main != self.scm_ip_security_restrictions_use_main) + return (site_config.scm_ip_security_restrictions_use_main != self.scm_ip_security_restrictions_use_main or self.ip_security_restrictions and + self.ip_security_restrictions != self.to_restriction_dict_list(site_config.ip_security_restrictions) or self.scm_ip_security_restrictions and + self.scm_ip_security_restrictions != self.to_restriction_dict_list(site_config.scm_ip_security_restrictions)) def has_access_restrictions(self, site_config): return site_config.ip_security_restrictions or site_config.scm_ip_security_restrictions diff --git a/tests/integration/targets/azure_rm_webappaccessrestriction/tasks/main.yml b/tests/integration/targets/azure_rm_webappaccessrestriction/tasks/main.yml index dcf05e334..05061d195 100644 --- a/tests/integration/targets/azure_rm_webappaccessrestriction/tasks/main.yml +++ b/tests/integration/targets/azure_rm_webappaccessrestriction/tasks/main.yml @@ -33,19 +33,6 @@ assert: that: output.changed -- name: "Check webapp access restriction facts 1" - azure_rm_webappaccessrestriction_info: - name: webapp{{ rpfx }} - resource_group: "{{ resource_group }}" - register: output -- name: Assert no restrictions - assert: - that: - - not output.changed - - output.ip_security_restrictions | length == 0 - - output.scm_ip_security_restrictions | length == 0 - - output.scm_ip_security_restrictions_use_main == false - - name: "Create webapp access restriction" azure_rm_webappaccessrestriction: name: webapp{{ rpfx }} @@ -70,10 +57,9 @@ - output.ip_security_restrictions[0].ip_address == '1.1.1.1/24' - output.ip_security_restrictions[1].action == 'Allow' - output.ip_security_restrictions[1].ip_address == '2.2.2.2/24' - - output.scm_ip_security_restrictions | length == 0 - output.scm_ip_security_restrictions_use_main == true -- name: "Check webapp access restriction facts 2" +- name: "Check webapp access restriction facts 1" azure_rm_webappaccessrestriction_info: name: webapp{{ rpfx }} resource_group: "{{ resource_group }}" @@ -87,7 +73,6 @@ - output.ip_security_restrictions[0].ip_address == '1.1.1.1/24' - output.ip_security_restrictions[1].action == 'Allow' - output.ip_security_restrictions[1].ip_address == '2.2.2.2/24' - - output.scm_ip_security_restrictions | length == 0 - output.scm_ip_security_restrictions_use_main == true - name: "Create webapp access restriction - idempotent" @@ -127,7 +112,6 @@ - output.ip_security_restrictions | length == 1 - output.ip_security_restrictions[0].action == 'Allow' - output.ip_security_restrictions[0].ip_address == '1.1.1.1/24' - - output.scm_ip_security_restrictions | length == 0 - output.scm_ip_security_restrictions_use_main == true - name: "Update existing webapp access restriction 1" @@ -148,10 +132,9 @@ - output.ip_security_restrictions | length == 1 - output.ip_security_restrictions[0].action == 'Deny' - output.ip_security_restrictions[0].ip_address == '1.2.3.4/24' - - output.scm_ip_security_restrictions | length == 0 - output.scm_ip_security_restrictions_use_main == true -- name: "Update existing webapp access restriction 2" +- name: "Update existing webapp access restriction 1" azure_rm_webappaccessrestriction: name: webapp{{ rpfx }} resource_group: "{{ resource_group }}" @@ -169,7 +152,6 @@ - output.ip_security_restrictions | length == 1 - output.ip_security_restrictions[0].action == 'Deny' - output.ip_security_restrictions[0].ip_address == '1.2.3.4/24' - - output.scm_ip_security_restrictions | length == 0 - output.scm_ip_security_restrictions_use_main == false - name: "Update existing webapp access restriction 3" @@ -281,6 +263,6 @@ assert: that: - not output.changed - - output.ip_security_restrictions | length == 0 - - output.scm_ip_security_restrictions | length == 0 + - output.ip_security_restrictions | length <= 1 + - output.scm_ip_security_restrictions | length <= 1 - output.scm_ip_security_restrictions_use_main == false