def test_global_group_create_again(self): respG, contentG = utils.create_global_group(self.global_group, str(self.auth_token)) respG, contentG = utils.create_global_group(self.global_group, str(self.auth_token)) if int(respG["status"]) == 500: self.fail("IDM fault") elif int(respG["status"]) == 503: self.fail("Service Not Available") self.assertEqual(409, int(respG["status"]))
def test_global_group_create_again(self): utils.create_global_group(self.global_group, str(self.auth_token)) resp_new, _content_new = utils.create_global_group(self.global_group, str(self.auth_token)) if int(resp_new['status']) == 500: self.fail('Identity fault') elif int(resp_new['status']) == 503: self.fail('Service Not Available') self.assertEqual(409, int(resp_new['status']))
def test_update_global_group_not_found(self): header = httplib2.Http(".cache") utils.create_global_group(self.global_group, str(self.auth_token)) url = '%sgroups/NonexistingID' % (utils.URL_V2) data = '{"group": { "description": "A NEW description...", \ "id":"NonexistingID"}}' #test for Content-Type = application/json resp, _content = header.request(url, "GET", body=data, headers={"Content-Type": "application/json", "X-Auth-Token": self.auth_token}) self.assertEqual(404, int(resp['status']))
def test_update_global_group_xml(self): h = httplib2.Http(".cache") respG, contentG = utils.create_global_group(self.global_group, str(self.auth_token)) url = "%sgroups/%s" % (utils.URL, self.global_group) data = ( u'<?xml version="1.0" encoding="UTF-8"?> \ <group xmlns="http://docs.openstack.org/idm/api/v1.0" \ id="%s"><description>A NEW description...</description> \ </group>' % (self.global_group) ) # test for Content-Type = application/json resp, content = h.request( url, "PUT", body=data, headers={"Content-Type": "application/xml", "X-Auth-Token": self.auth_token, "ACCEPT": "application/xml"}, ) body = etree.fromstring(content) desc = body.find("{http://docs.openstack.org/idm/api/v1.0}description") if int(resp["status"]) == 500: self.fail("IDM fault") elif int(resp["status"]) == 503: self.fail("Service Not Available") self.assertEqual(200, int(resp["status"])) self.assertEqual(str(self.global_group), str(body.get("id"))) self.assertEqual("A NEW description...", desc.text)
def test_update_global_group_xml(self): header = httplib2.Http(".cache") _resp_new, _content_new = utils.create_global_group(self.global_group, str(self.auth_token)) url = '%sgroups/%s' % (utils.URL_V2, self.global_group) data = u'<?xml version="1.0" encoding="UTF-8"?> \ <group xmlns="http://docs.openstack.org/identity/api/v2.0" \ id="%s"><description>A NEW description...</description> \ </group>' % (self.global_group) #test for Content-Type = application/json resp, content = header.request(url, "PUT", body=data, headers={"Content-Type": "application/xml", "X-Auth-Token": self.auth_token, "ACCEPT": "application/xml"}) body = etree.fromstring(content) desc = body.find("{http://docs.openstack.org/identity/api/v2.0}description") 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'])) self.assertEqual(str(self.global_group), str(body.get('id'))) self.assertEqual('A NEW description...', desc.text)
def test_add_user_global_group_forbidden_xml(self): resp, content = utils.create_global_group(self.global_group, str(self.auth_token)) utils.create_user(self.tenant, self.user, str(self.auth_token)) resp_new, content_new = utils.add_user_global_group_xml(self.global_group, self.user, str(self.disabled_token)) if int(resp["status"]) == 500: self.fail("IDM fault") elif int(resp["status"]) == 503: self.fail("Service Not Available") self.assertEqual(403, int(resp_new["status"]))
def test_global_group_create_unauthorized_token(self): _header = httplib2.Http(".cache") resp, _content = utils.create_global_group(\ self.global_group, str(self.token)) if int(resp['status']) == 500: self.fail('Identity Fault') elif int(resp['status']) == 503: self.fail('Service Not Available') self.assertEqual(401, int(resp['status']))
def test_global_group_create(self): respG, contentG = utils.delete_global_group(self.global_group, str(self.auth_token)) respG, contentG = utils.create_global_group(self.global_group, str(self.auth_token)) if int(respG["status"]) == 500: self.fail("IDM fault") elif int(respG["status"]) == 503: self.fail("Service Not Available") if int(respG["status"]) not in (200, 201): self.fail("Failed due to %d" % int(respG["status"]))
def test_global_group_create(self): utils.delete_global_group(self.global_group, str(self.auth_token)) resp_new, _content_new = utils.create_global_group(self.global_group, str(self.auth_token)) if int(resp_new['status']) == 500: self.fail('Identity fault') elif int(resp_new['status']) == 503: self.fail('Service Not Available') if int(resp_new['status']) not in (200, 201): self.fail('Failed due to %d' % int(resp_new['status']))
def test_delete_user_global_group_xml(self): h = httplib2.Http(".cache") resp, content = utils.create_global_group(self.global_group, str(self.auth_token)) respG, contentG = utils.create_user(self.tenant, self.user, str(self.auth_token)) respG, contentG = utils.add_user_global_group(self.global_group, self.user, str(self.auth_token)) respG, contentG = utils.delete_user_global_group_xml(self.global_group, self.user, str(self.auth_token)) if int(resp["status"]) == 500: self.fail("IDM fault") elif int(resp["status"]) == 503: self.fail("Service Not Available") self.assertEqual(204, int(respG["status"]))
def test_add_user_global_group_xml(self): resp, content = utils.create_global_group(self.global_group, str(self.auth_token)) utils.create_user(self.tenant, self.user, str(self.auth_token)) resp_new, content_new = utils.add_user_global_group_xml(self.global_group, self.user, str(self.auth_token)) if int(resp["status"]) == 500: self.fail("IDM fault") elif int(resp["status"]) == 503: self.fail("Service Not Available") if int(resp_new["status"]) not in (200, 201): self.fail("Failed due to %d" % int(resp_new["status"]))
def test_add_user_global_group(self): h = httplib2.Http(".cache") resp, content = utils.create_global_group(self.global_group, str(self.auth_token)) respG, contentG = utils.create_user(self.tenant, self.user, str(self.auth_token)) respG, contentG = utils.add_user_global_group(self.global_group, self.user, str(self.auth_token)) if int(resp["status"]) == 500: self.fail("IDM fault") elif int(resp["status"]) == 503: self.fail("Service Not Available") if int(respG["status"]) not in (200, 201): self.fail("Failed due to %d" % int(respG["status"]))
def test_get_users_global_group_unauthorized(self): resp, content = utils.create_global_group(self.global_group, str(self.auth_token)) utils.create_user(self.tenant, self.user, str(self.auth_token)) utils.add_user_global_group(self.global_group, self.user, str(self.auth_token)) resp_new, content_new = utils.get_user_global_group(self.global_group, str(self.token)) if int(resp["status"]) == 500: self.fail("IDM fault") elif int(resp["status"]) == 503: self.fail("Service Not Available") self.assertEqual(401, int(resp_new["status"]))
def test_get_global_groups_unauthorized_token(self): header = httplib2.Http(".cache") resp_new, content_new = utils.create_global_group(self.global_group, str(self.auth_token)) url = "%sgroups" % (utils.URL) # test for Content-Type = application/json resp, content = header.request( url, "GET", body="{}", headers={"Content-Type": "application/json", "X-Auth-Token": self.token} ) if int(resp["status"]) == 500: self.fail("IDM fault") elif int(resp["status"]) == 503: self.fail("Service Not Available") self.assertEqual(401, int(resp["status"]))
def test_get_global_group_bad(self): h = httplib2.Http(".cache") respG, contentG = utils.create_global_group(self.global_group, str(self.auth_token)) url = "%sgroups/%s" % (utils.URL, "global_group_bad") # test for Content-Type = application/json resp, content = h.request( url, "GET", body="", headers={"Content-Type": "application/json", "X-Auth-Token": self.auth_token} ) if int(resp["status"]) == 500: self.fail("IDM fault") elif int(resp["status"]) == 503: self.fail("Service Not Available") self.assertEqual(404, int(resp["status"]))
def test_add_user_global_group_forbidden_xml(self): resp, _content = utils.create_global_group(self.global_group, str(self.auth_token)) utils.create_user(self.tenant, self.user, str(self.auth_token)) resp_new, _content_new = utils.add_user_global_group_xml(\ self.global_group, self.user, str(self.disabled_token)) if int(resp['status']) == 500: self.fail('Identity Fault') elif int(resp['status']) == 503: self.fail('Service Not Available') self.assertEqual(403, int(resp_new['status']))
def test_add_user_global_group_unauthorized(self): resp, content = utils.create_global_group(self.global_group, str(self.auth_token)) utils.create_user(self.tenant, self.user, str(self.auth_token)) resp_new, content_new = utils.add_user_global_group(self.global_group, self.user, str(self.token)) if int(resp['status']) == 500: self.fail('Identity Fault') elif int(resp['status']) == 503: self.fail('Service Not Available') self.assertEqual(401, int(resp_new['status']))
def test_get_global_group_bad(self): header = httplib2.Http(".cache") _resp_new, _content_new = utils.create_global_group(self.global_group, str(self.auth_token)) url = '%sgroups/%s' % (utils.URL_V2, 'global_group_bad') #test for Content-Type = application/json resp, _content = header.request(url, "GET", body='', headers={"Content-Type": "application/json", "X-Auth-Token": self.auth_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_add_user_global_group(self): resp, _content = utils.create_global_group(self.global_group, str(self.auth_token)) utils.create_user(self.tenant, self.user, str(self.auth_token)) resp_new, _content_new = utils.add_user_global_group(self.global_group, self.user, str(self.auth_token)) if int(resp['status']) == 500: self.fail('Identity Fault') elif int(resp['status']) == 503: self.fail('Service Not Available') if int(resp_new['status']) not in (200, 201): self.fail('Failed due to %d' % int(resp_new['status']))
def test_get_global_groups(self): header = httplib2.Http(".cache") utils.delete_global_group(self.global_group, str(self.auth_token)) resp_new, content_new = utils.create_global_group(self.global_group, str(self.auth_token)) url = '%sgroups' % (utils.URL) resp, content = header.request(url, "GET", body='{}', headers={"Content-Type": "application/json", "X-Auth-Token": 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']))
def test_update_global_group_bad(self): header = httplib2.Http(".cache") _resp_new, _content_new = utils.create_global_group(self.global_group, str(self.auth_token)) url = '%sgroups/%s' % (utils.URL_V2, self.global_group) data = '{"group": { "description_bad": "A NEW description...", \ "id":"%s" }}'\ % (self.global_group) #test for Content-Type = application/json resp, _content = header.request(url, "PUT", body=data, headers={"Content-Type": "application/json", "X-Auth-Token": self.auth_token}) if int(resp['status']) == 500: self.fail('Identity Fault') elif int(resp['status']) == 503: self.fail('Service Not Available') self.assertEqual(400, int(resp['status']))
def test_update_global_group_bad(self): h = httplib2.Http(".cache") respG, contentG = utils.create_global_group(self.global_group, str(self.auth_token)) url = "%sgroups/%s" % (utils.URL, self.global_group) data = ( '{"group": { "description_bad": "A NEW description...", \ "id":"%s" }}' % (self.global_group) ) # test for Content-Type = application/json resp, content = h.request( url, "PUT", body=data, headers={"Content-Type": "application/json", "X-Auth-Token": self.auth_token} ) if int(resp["status"]) == 500: self.fail("IDM fault") elif int(resp["status"]) == 503: self.fail("Service Not Available") self.assertEqual(400, int(resp["status"]))
def test_update_global_group(self): header = httplib2.Http(".cache") _resp_new, _content_new = utils.create_global_group(self.global_group, str(self.auth_token)) url = '%sgroups/%s' % (utils.URL_V2, self.global_group) resp, content = header.request(url, "PUT", body='{"group":{\ "id" : "%s","description" :\ "A New description of the group..."}}' % self.global_group, headers={"Content-Type": "application/json", "X-Auth-Token": self.auth_token}) body = json.loads(content) 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'])) self.assertEqual(self.global_group, body['group']['id']) self.assertEqual('A New description of the group...', str(body['group']['description']))
def test_update_global_group(self): h = httplib2.Http(".cache") respG, contentG = utils.create_global_group(self.global_group, str(self.auth_token)) url = "%sgroups/%s" % (utils.URL, self.global_group) resp, content = h.request( url, "PUT", body='{"group":{\ "id" : "%s","description" :\ "A New description of the group..."}}' % self.global_group, headers={"Content-Type": "application/json", "X-Auth-Token": self.auth_token}, ) body = json.loads(content) if int(resp["status"]) == 500: self.fail("IDM fault") elif int(resp["status"]) == 503: self.fail("Service Not Available") self.assertEqual(200, int(resp["status"])) self.assertEqual(self.global_group, body["group"]["id"]) self.assertEqual("A New description of the group...", str(body["group"]["description"]))