Fixes Bug 1031639: admin_client.py- 'Assign and Remove role to user' points to a different URI
Change-Id: Ie8b60da44dcd9eef9daf59628a376f143d53ad9e
diff --git a/tempest/services/identity/json/admin_client.py b/tempest/services/identity/json/admin_client.py
index 314814e..b5aef5f 100644
--- a/tempest/services/identity/json/admin_client.py
+++ b/tempest/services/identity/json/admin_client.py
@@ -57,28 +57,26 @@
resp, body = self.delete('OS-KSADM/roles/%s' % str(role_id))
return resp, body
- def list_user_roles(self, user_id):
+ def list_user_roles(self, tenant_id, user_id):
"""Returns a list of roles assigned to a user for a tenant"""
- resp, body = self.get('users/%s/roleRefs' % user_id)
+ url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
+ resp, body = self.get(url)
body = json.loads(body)
return resp, body['roles']
- def assign_user_role(self, user_id, role_id, tenant_id):
- """Assigns a role to a user for a tenant"""
- post_body = {
- 'roleId': role_id,
- 'tenantId': tenant_id
- }
- post_body = json.dumps({'role': post_body})
- resp, body = self.post('users/%s/roleRefs' % user_id, post_body,
- self.headers)
+ def assign_user_role(self, tenant_id, user_id, role_id):
+ """Add roles to a user on a tenant"""
+ post_body = json.dumps({})
+ resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s'
+ % (tenant_id, user_id, role_id), post_body,
+ self.headers)
body = json.loads(body)
return resp, body['role']
- def remove_user_role(self, user_id, role_id):
+ def remove_user_role(self, tenant_id, user_id, role_id):
"""Removes a role assignment for a user on a tenant"""
- resp, body = self.delete('users/%s/roleRefs/%s' % (user_id, role_id))
- return resp, body
+ return self.delete('/tenants/%s/users/%s/roles/OS-KSADM/%s'
+ % (tenant_id, user_id, role_id))
def delete_tenant(self, tenant_id):
"""Delete a tenant"""