def test_create_user_by_name(username, password, tenant_name): """ test administrator to create a user whose name is the giving name""" bt = BaseTest() endpoint = bt.get_service_endpoint('keystone') endpoint = endpoint + '/users' headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} tenant = bt.get_tenant_by_name(tenant_name) user = bt.get_user_by_name(username) if tenant == None or user != None: return 3 body = { 'user': { 'name': username, 'password': password, 'tenantId': tenant['id'], 'email': '*****@*****.**', 'enabled': True } } response, content = bt.post(endpoint, headers=headers, body=json.dumps(body)) if(response['status'] == '200'): return 0 return 1
def test_tenant_disable(tenant_name): """ test disable a tenant by name given """ bt = BaseTest() tenant = bt.get_tenant_by_name(tenant_name) if(tenant == None): return 3 tenant_id = tenant['id'] endpoint = bt.get_service_endpoint('keystone') endpoint = endpoint + '/tenants/' + tenant_id body = { "tenant": { "enabled": False, }, } headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} response, content = bt.post(endpoint, headers=headers, body=json.dumps(body)) if(response['status'] == '200'): return 0 return 1
def test_tenant_reenable(tenant_name): """ test enable a disabled tenant """ bt = BaseTest() tenant = bt.get_tenant_by_name(tenant_name) if (tenant == None): return 3 tenant_id = tenant['id'] endpoint = bt.get_service_endpoint('keystone') endpoint = endpoint + '/tenants/' + tenant_id body = { "tenant": { "enabled": True, }, } headers = { 'Content-Type': 'application/json', 'Accept': 'application/json' } response, content = bt.post(endpoint, headers=headers, body=json.dumps(body)) if (response['status'] == '200'): return 0 return 1
def test_create_user_by_name(username, password, tenant_name): """ test administrator to create a user whose name is the giving name""" bt = BaseTest() endpoint = bt.get_service_endpoint('keystone') endpoint = endpoint + '/users' headers = { 'Content-Type': 'application/json', 'Accept': 'application/json' } tenant = bt.get_tenant_by_name(tenant_name) user = bt.get_user_by_name(username) if tenant == None or user != None: return 3 body = { 'user': { 'name': username, 'password': password, 'tenantId': tenant['id'], 'email': '*****@*****.**', 'enabled': True } } response, content = bt.post(endpoint, headers=headers, body=json.dumps(body)) if (response['status'] == '200'): return 0 return 1
def test_create_tenant_by_name(name): """ test administrator to create a tenant whose name is the giving name """ bt = BaseTest() endpoint = bt.get_service_endpoint('keystone') endpoint = endpoint + '/tenants' headers = { 'Content-Type': 'application/json', 'Accept': 'application/json' } body = { "tenant": { "name": name, "description": "test create tenant", "enabled": "true", }, } response, content = bt.post(endpoint, headers=headers, body=json.dumps(body)) if (response['status'] == '200'): return 0 return 1
def test_create_tenant_by_name(name): """ test administrator to create a tenant whose name is the giving name """ bt = BaseTest() endpoint = bt.get_service_endpoint('keystone') endpoint = endpoint + '/tenants' headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} body = { "tenant": { "name": name, "description": "test create tenant", "enabled": "true", }, } response, content = bt.post(endpoint, headers=headers, body=json.dumps(body)) if(response['status'] == '200'): return 0 return 1
def test_tenant_reenable(tenant_name): """ test enable a disabled tenant """ bt = BaseTest() tenant = bt.get_tenant_by_name(tenant_name) if tenant == None: return 3 tenant_id = tenant["id"] endpoint = bt.get_service_endpoint("keystone") endpoint = endpoint + "/tenants/" + tenant_id body = {"tenant": {"enabled": True}} headers = {"Content-Type": "application/json", "Accept": "application/json"} response, content = bt.post(endpoint, headers=headers, body=json.dumps(body)) if response["status"] == "200": return 0 return 1