def test_role_ref_create_xml(self): utils.add_user_json(self.auth_token) resp, _content = utils.create_role_ref_xml( self.user, 'Admin', self.tenant, str(self.auth_token)) resp_val = int(resp['status']) self.assertEqual(201, resp_val)
def test_delete_roleref_using_invalid_token(self): header = httplib2.Http(".cache") utils.add_user_json(self.auth_token) resp, content = utils.create_role_ref(self.user, "Admin", self.tenant, str(self.auth_token)) resp_val = int(resp["status"]) self.assertEqual(201, resp_val) obj = json.loads(content) if not "roleRef" in obj: raise fault.BadRequestFault("Expecting RoleRef") roleRef = obj["roleRef"] if not "id" in roleRef: role_ref_id = None else: role_ref_id = roleRef["id"] if role_ref_id is None: raise fault.BadRequestFault("Expecting RoleRefId") url = "%susers/%s/roleRefs/%s" % (URL_V2, self.user, role_ref_id) resp, content = header.request( url, "DELETE", body="", headers={"Content-Type": "application/json", "X-Auth-Token": str(self.invalid_token)}, ) resp_val = int(resp["status"]) self.assertEqual(404, resp_val)
def setUp(self): self.auth_token = utils.get_auth_token() self.userdisabled = utils.get_userdisabled() utils.create_tenant('test_tenant1', self.auth_token) utils.create_tenant('test_tenant2', self.auth_token) utils.create_user('test_tenant1', 'test_user1', self.auth_token) utils.create_user('test_tenant1', 'test_user2', self.auth_token) utils.add_user_json(self.auth_token)
def test_get_rolerefs_json_using_invalid_token(self): header = httplib2.Http(".cache") utils.add_user_json(self.auth_token) _resp, _content = utils.create_role_ref(self.user, "Admin", self.tenant, str(self.auth_token)) url = "%susers/%s/roleRefs" % (URL_V2, self.user) # test for Content-Type = application/json resp, _content = header.request( url, "GET", body="{}", headers={"Content-Type": "application/json", "X-Auth-Token": str(self.invalid_token)} ) self.assertEqual(404, int(resp["status"]))
def test_get_rolerefs_using_missing_token(self): header = httplib2.Http(".cache") utils.add_user_json(self.auth_token) _resp, _content = utils.create_role_ref(self.user, 'Admin', self.tenant, str(self.auth_token)) url = '%susers/%s/roleRefs' % (URL_V2, self.user) #test for Content-Type = application/json resp, _content = header.request(url, "GET", body='{}', headers={ "Content-Type": "application/json", "X-Auth-Token": str(self.missing_token)}) self.assertEqual(401, int(resp['status']))
def setUp(self): self.tenant = 'test_tenant' self.auth_token = utils.get_auth_token() self.user = utils.get_user() self.userdisabled = utils.get_userdisabled() self.exp_auth_token = utils.get_exp_auth_token() self.disabled_token = utils.get_disabled_token() utils.create_tenant(self.tenant, str(self.auth_token)) utils.create_user(self.tenant, self.user, self.auth_token) utils.add_user_json(self.tenant, self.user, self.auth_token) self.token = utils.get_token(self.user, 'secrete', self.tenant, 'token')
def setUp(self): self.tenant = utils.get_global_tenant() self.user = utils.get_user() self.userdisabled = utils.get_userdisabled() self.auth_token = utils.get_auth_token() self.exp_auth_token = utils.get_exp_auth_token() self.disabled_token = utils.get_disabled_token() self.global_group = "test_global_group" utils.create_tenant(self.tenant, str(self.auth_token)) utils.create_user(self.tenant, self.user, self.auth_token) utils.add_user_json(self.tenant, self.user, self.auth_token) self.token = utils.get_token(self.user, "secrete", self.tenant, "token")
def test_get_rolerefs_using_invalid_token(self): header = httplib2.Http(".cache") utils.add_user_json(self.tenant, self.user, self.auth_token) resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, str(self.auth_token)) url = '%susers/%s/roleRefs' % (URL, self.user) #test for Content-Type = application/json resp, content = header.request(url, "GET", body='{}', headers={"Content-Type": "application/json", "X-Auth-Token": str(self.invalid_token)}) if int(resp['status']) == 500: self.fail('Identity Fault') elif int(resp['status']) == 503: self.fail('Service Not Available') self.assertEqual(404, int(resp['status']))
def test_get_rolerefs(self): header = httplib2.Http(".cache") utils.add_user_json(self.auth_token) _resp, _content = utils.create_role_ref(self.user, "Admin", self.tenant, str(self.auth_token)) url = "%susers/%s/roleRefs" % (URL_V2, self.user) # test for Content-Type = application/json resp, content = header.request( url, "GET", body="{}", headers={"Content-Type": "application/json", "X-Auth-Token": str(self.auth_token)} ) self.assertEqual(200, int(resp["status"])) # verify content obj = json.loads(content) if not "roleRefs" in obj: raise self.fail("Expecting RoleRefs")
def test_get_rolerefs(self): header = httplib2.Http(".cache") utils.add_user_json(self.tenant, self.user, self.auth_token) resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, str(self.auth_token)) url = '%susers/%s/roleRefs' % (URL, self.user) #test for Content-Type = application/json resp, content = header.request(url, "GET", body='{}', headers={"Content-Type": "application/json", "X-Auth-Token": str(self.auth_token)}) if int(resp['status']) == 500: self.fail('Identity Fault') elif int(resp['status']) == 503: self.fail('Service Not Available') self.assertEqual(200, int(resp['status'])) #verify content obj = json.loads(content) if not "roleRefs" in obj: raise self.fail("Expecting RoleRefs")
def test_get_rolerefs_xml_using_service_admin_token(self): header = httplib2.Http(".cache") utils.add_user_json(self.auth_token) _resp, _content = utils.create_role_ref( self.user, 'Admin', self.tenant, str(self.auth_token)) url = '%susers/%s/roleRefs' % (URL_V2, self.user) #test for Content-Type = application/xml resp, content = header.request(url, "GET", body='{}', headers={"Content-Type": "application/xml", "X-Auth-Token": str(self.service_token), "ACCEPT": "application/xml"}) self.assertEqual(200, int(resp['status'])) #verify content dom = etree.Element("root") dom.append(etree.fromstring(content)) roles = dom.find("{http://docs.openstack.org/identity/api/v2.0}" \ "roleRefs") if roles == None: self.fail("Expecting Role Refs")
def setUp(self): self.auth_token = utils.get_auth_token() self.userdisabled = utils.get_userdisabled() resp1, content1 = utils.create_tenant('test_tenant1', self.auth_token) #create tenant2 resp2, content2 = utils.create_tenant('test_tenant2', self.auth_token) #create user1 with tenant1 resp3, content3 = utils.create_user('test_tenant1', 'test_user1', self.auth_token) resp3, content3 = utils.create_user('test_tenant1', 'test_user2', self.auth_token) #add user1 to tenant2 resp4, content4 = utils.add_user_json('test_tenant2', 'test_user1', self.auth_token)
def test_role_ref_create_json_using_invalid_token(self): utils.add_user_json(self.tenant, self.user, self.auth_token) resp, content = utils.create_role_ref(self.user, 'Admin', self.tenant, str(self.invalid_token)) resp_val = int(resp['status']) self.assertEqual(404, resp_val)
def test_role_ref_create_json_using_missing_token(self): utils.add_user_json(self.auth_token) resp, _content = utils.create_role_ref(self.user, "Admin", self.tenant, str(self.missing_token)) resp_val = int(resp["status"]) self.assertEqual(401, resp_val)