Skip to content

Commit

Permalink
fixing sanity testing errors in ad related modules (#182)
Browse files Browse the repository at this point in the history
* disable ad relate module test
* fixing sanity testing errors in ad related modules
  • Loading branch information
Fred-sun authored Jul 9, 2020
1 parent 3e1c870 commit a88dac2
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion plugins/modules/azure_rm_adpassword.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def resolve_app_obj_id(self):
if not self.app_id:
self.fail("can't resolve app via service principal object id {0}".format(self.service_principal_object_id))

result = list(self.client.applications.list(filter="appId eq '{}'".format(self.app_id)))
result = list(self.client.applications.list(filter="appId eq '{0}'".format(self.app_id)))
if result:
self.app_object_id = result[0].object_id
else:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/azure_rm_adpassword_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def resolve_app_obj_id(self):
if not self.app_id:
self.fail("can't resolve app via service principal object id {0}".format(self.service_principal_object_id))

result = list(self.client.applications.list(filter="appId eq '{}'".format(self.app_id)))
result = list(self.client.applications.list(filter="appId eq '{0}'".format(self.app_id)))
if result:
self.app_object_id = result[0].object_id
else:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/azure_rm_adserviceprincipal.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def delete_resource(self, response):
def get_resource(self):
try:
client = self.get_graphrbac_client(self.tenant)
result = list(client.service_principals.list(filter="servicePrincipalNames/any(c:c eq '{}')".format(self.app_id)))
result = list(client.service_principals.list(filter="servicePrincipalNames/any(c:c eq '{0}')".format(self.app_id)))
if not result:
return False
result = result[0]
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/azure_rm_adserviceprincipal_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def exec_module(self, **kwargs):
try:
client = self.get_graphrbac_client(self.tenant)
if self.object_id is None:
service_principals = list(client.service_principals.list(filter="servicePrincipalNames/any(c:c eq '{}')".format(self.app_id)))
service_principals = list(client.service_principals.list(filter="servicePrincipalNames/any(c:c eq '{0}')".format(self.app_id)))
else:
service_principals = [client.service_principals.get(self.object_id)]

Expand Down
2 changes: 0 additions & 2 deletions pr-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ parameters:
- "azure_rm_virtualnetworkeepring"
- "azure_rm_webapp"
- "azure_rm_workspace"
- "azure_rm_adpassword"
- "azure_rm_adserviceprincipal"
- "inventory_azure"
- "setup_azure"

Expand Down
1 change: 1 addition & 0 deletions tests/integration/targets/azure_rm_adpassword/aliases
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cloud/azure
shippable/azure/group10
disabled
destructive
32 changes: 28 additions & 4 deletions tests/integration/targets/azure_rm_adpassword/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
tenant_id: "72f988bf-86f1-41af-91ab-2d7cd011db47"
app_object_id: "b52e8275-a1ee-4c4a-86ff-15992e0920ed"

- name: create ad password
- name: create first ad password by app_id
azure_rm_adpassword:
app_id: "{{ app_id }}"
value: "Password@032900001"
tenant: "{{ tenant_id }}"
app_object_id: "{{ app_object_id }}"
state: present
register: ad_fact

- assert:
that:
- ad_fact.changed

- name: create second ad password
- name: create second ad password by app_object_id
azure_rm_adpassword:
app_id: "{{ app_id }}"
value: "Password@032900002"
tenant: "{{ tenant_id }}"
app_object_id: "{{ app_object_id }}"
Expand All @@ -29,6 +27,32 @@
that:
- ad_fact02.changed

- name: create ad service principal
azure_rm_adserviceprincipal:
app_id: "{{ app_id }}"
tenant: "{{ tenant_id }}"
state: present

- name: Get ad service principal info
azure_rm_adserviceprincipal_info:
tenant: "{{ tenant_id }}"
app_id: "{{ app_id }}"
register: sp_info
- debug:
var: sp_info

- name: create third ad password by service_principal_object_id
azure_rm_adpassword:
value: "Password@032900003"
tenant: "{{ tenant_id }}"
service_principal_object_id: "{{ sp_info.service_principals[0].object_id }}"
state: present
register: ad_fact03

- assert:
that:
- ad_fact03.changed

- name: can't update ad password
azure_rm_adpassword:
app_id: "{{ app_id }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cloud/azure
shippable/azure/group10
destructive
disabled

0 comments on commit a88dac2

Please sign in to comment.