Merge "Define 4 identity v2 clients as libraries"
This commit is contained in:
commit
330f11dd91
@ -7,3 +7,7 @@ features:
|
||||
any maintenance changes.
|
||||
|
||||
* endpoints_client(v2)
|
||||
* roles_client(v2)
|
||||
* services_client(v2)
|
||||
* tenants_client(v2)
|
||||
* users_client(v2)
|
||||
|
@ -126,15 +126,15 @@ from tempest.lib.services.compute import floating_ips_client
|
||||
from tempest.lib.services.compute import security_group_rules_client
|
||||
from tempest.lib.services.compute import security_groups_client
|
||||
from tempest.lib.services.compute import servers_client
|
||||
from tempest.lib.services.identity.v2 import roles_client
|
||||
from tempest.lib.services.identity.v2 import tenants_client
|
||||
from tempest.lib.services.identity.v2 import users_client
|
||||
from tempest.lib.services.image.v2 import images_client
|
||||
from tempest.lib.services.network import networks_client
|
||||
from tempest.lib.services.network import ports_client
|
||||
from tempest.lib.services.network import routers_client
|
||||
from tempest.lib.services.network import subnets_client
|
||||
from tempest.services.identity.v2.json import identity_client
|
||||
from tempest.services.identity.v2.json import roles_client
|
||||
from tempest.services.identity.v2.json import tenants_client
|
||||
from tempest.services.identity.v2.json import users_client
|
||||
from tempest.services.object_storage import container_client
|
||||
from tempest.services.object_storage import object_client
|
||||
from tempest.services.volume.v1.json import volumes_client
|
||||
|
107
tempest/lib/services/identity/v2/roles_client.py
Normal file
107
tempest/lib/services/identity/v2/roles_client.py
Normal file
@ -0,0 +1,107 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
from six.moves.urllib import parse as urllib
|
||||
|
||||
from tempest.lib.common import rest_client
|
||||
|
||||
|
||||
class RolesClient(rest_client.RestClient):
|
||||
api_version = "v2.0"
|
||||
|
||||
def create_role(self, **kwargs):
|
||||
"""Create a role.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#createRole
|
||||
"""
|
||||
post_body = json.dumps({'role': kwargs})
|
||||
resp, body = self.post('OS-KSADM/roles', post_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_role(self, role_id_or_name):
|
||||
"""Get a role by its id or name.
|
||||
|
||||
Available params: see
|
||||
http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#showRoleByID
|
||||
OR
|
||||
http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#showRoleByName
|
||||
"""
|
||||
resp, body = self.get('OS-KSADM/roles/%s' % role_id_or_name)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_roles(self, **params):
|
||||
"""Returns roles.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#listRoles
|
||||
"""
|
||||
url = 'OS-KSADM/roles'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def delete_role(self, role_id):
|
||||
"""Delete a role.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#deleteRole
|
||||
"""
|
||||
resp, body = self.delete('OS-KSADM/roles/%s' % str(role_id))
|
||||
self.expected_success(204, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def create_user_role_on_project(self, tenant_id, user_id, role_id):
|
||||
"""Add roles to a user on a tenant.
|
||||
|
||||
Available params: see
|
||||
http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#grantRoleToUserOnTenant
|
||||
"""
|
||||
resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
|
||||
(tenant_id, user_id, role_id), "")
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_user_roles_on_project(self, tenant_id, user_id, **params):
|
||||
"""Returns a list of roles assigned to a user for a tenant."""
|
||||
# TODO(gmann): Need to write API-ref link, Bug# 1592711
|
||||
url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def delete_role_from_user_on_project(self, tenant_id, user_id, role_id):
|
||||
"""Removes a role assignment for a user on a tenant.
|
||||
|
||||
Available params: see
|
||||
http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#revokeRoleFromUserOnTenant
|
||||
"""
|
||||
resp, body = self.delete('/tenants/%s/users/%s/roles/OS-KSADM/%s' %
|
||||
(tenant_id, user_id, role_id))
|
||||
self.expected_success(204, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
98
tempest/lib/services/identity/v2/tenants_client.py
Normal file
98
tempest/lib/services/identity/v2/tenants_client.py
Normal file
@ -0,0 +1,98 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
from six.moves.urllib import parse as urllib
|
||||
|
||||
from tempest.lib.common import rest_client
|
||||
|
||||
|
||||
class TenantsClient(rest_client.RestClient):
|
||||
api_version = "v2.0"
|
||||
|
||||
def create_tenant(self, **kwargs):
|
||||
"""Create a tenant
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#createTenant
|
||||
"""
|
||||
post_body = json.dumps({'tenant': kwargs})
|
||||
resp, body = self.post('tenants', post_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def delete_tenant(self, tenant_id):
|
||||
"""Delete a tenant.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#deleteTenant
|
||||
"""
|
||||
resp, body = self.delete('tenants/%s' % str(tenant_id))
|
||||
self.expected_success(204, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_tenant(self, tenant_id):
|
||||
"""Get tenant details.
|
||||
|
||||
Available params: see
|
||||
http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#admin-showTenantById
|
||||
"""
|
||||
resp, body = self.get('tenants/%s' % str(tenant_id))
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_tenants(self, **params):
|
||||
"""Returns tenants.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#admin-listTenants
|
||||
"""
|
||||
url = 'tenants'
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def update_tenant(self, tenant_id, **kwargs):
|
||||
"""Updates a tenant.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#updateTenant
|
||||
"""
|
||||
if 'id' not in kwargs:
|
||||
kwargs['id'] = tenant_id
|
||||
post_body = json.dumps({'tenant': kwargs})
|
||||
resp, body = self.post('tenants/%s' % tenant_id, post_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_tenant_users(self, tenant_id, **params):
|
||||
"""List users for a Tenant.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#listUsersForTenant
|
||||
"""
|
||||
url = '/tenants/%s/users' % tenant_id
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
152
tempest/lib/services/identity/v2/users_client.py
Normal file
152
tempest/lib/services/identity/v2/users_client.py
Normal file
@ -0,0 +1,152 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
from six.moves.urllib import parse as urllib
|
||||
|
||||
from tempest.lib.common import rest_client
|
||||
|
||||
|
||||
class UsersClient(rest_client.RestClient):
|
||||
api_version = "v2.0"
|
||||
|
||||
def create_user(self, **kwargs):
|
||||
"""Create a user.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-admin-v2.html#admin-createUser
|
||||
"""
|
||||
post_body = json.dumps({'user': kwargs})
|
||||
resp, body = self.post('users', post_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def update_user(self, user_id, **kwargs):
|
||||
"""Updates a user.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-admin-v2.html#admin-updateUser
|
||||
"""
|
||||
put_body = json.dumps({'user': kwargs})
|
||||
resp, body = self.put('users/%s' % user_id, put_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_user(self, user_id):
|
||||
"""GET a user.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-admin-v2.html#admin-showUser
|
||||
"""
|
||||
resp, body = self.get("users/%s" % user_id)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def delete_user(self, user_id):
|
||||
"""Delete a user.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-admin-v2.html#admin-deleteUser
|
||||
"""
|
||||
resp, body = self.delete("users/%s" % user_id)
|
||||
self.expected_success(204, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_users(self, **params):
|
||||
"""Get the list of users.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-admin-v2.html#admin-listUsers
|
||||
"""
|
||||
url = "users"
|
||||
if params:
|
||||
url += '?%s' % urllib.urlencode(params)
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def update_user_enabled(self, user_id, **kwargs):
|
||||
"""Enables or disables a user.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-identity-v2-ext.html#enableUser
|
||||
"""
|
||||
# NOTE: The URL (users/<id>/enabled) is different from the api-site
|
||||
# one (users/<id>/OS-KSADM/enabled) , but they are the same API
|
||||
# because of the fact that in keystone/contrib/admin_crud/core.py
|
||||
# both api use same action='set_user_enabled'
|
||||
put_body = json.dumps({'user': kwargs})
|
||||
resp, body = self.put('users/%s/enabled' % user_id, put_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def update_user_password(self, user_id, **kwargs):
|
||||
"""Update User Password."""
|
||||
# TODO(piyush): Current api-site doesn't contain this API description.
|
||||
# After fixing the api-site, we need to fix here also for putting the
|
||||
# link to api-site.
|
||||
# LP: https://bugs.launchpad.net/openstack-api-site/+bug/1524147
|
||||
put_body = json.dumps({'user': kwargs})
|
||||
resp, body = self.put('users/%s/OS-KSADM/password' % user_id, put_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def update_user_own_password(self, user_id, **kwargs):
|
||||
"""User updates own password"""
|
||||
# TODO(piyush): Current api-site doesn't contain this API description.
|
||||
# After fixing the api-site, we need to fix here also for putting the
|
||||
# link to api-site.
|
||||
# LP: https://bugs.launchpad.net/openstack-api-site/+bug/1524153
|
||||
# NOTE: This API is used for updating user password by itself.
|
||||
# Ref: http://lists.openstack.org/pipermail/openstack-dev/2015-December
|
||||
# /081803.html
|
||||
patch_body = json.dumps({'user': kwargs})
|
||||
resp, body = self.patch('OS-KSCRUD/users/%s' % user_id, patch_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def create_user_ec2_credential(self, user_id, **kwargs):
|
||||
# TODO(piyush): Current api-site doesn't contain this API description.
|
||||
# After fixing the api-site, we need to fix here also for putting the
|
||||
# link to api-site.
|
||||
post_body = json.dumps(kwargs)
|
||||
resp, body = self.post('/users/%s/credentials/OS-EC2' % user_id,
|
||||
post_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def delete_user_ec2_credential(self, user_id, access):
|
||||
resp, body = self.delete('/users/%s/credentials/OS-EC2/%s' %
|
||||
(user_id, access))
|
||||
self.expected_success(204, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_user_ec2_credentials(self, user_id):
|
||||
resp, body = self.get('/users/%s/credentials/OS-EC2' % user_id)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_user_ec2_credential(self, user_id, access):
|
||||
resp, body = self.get('/users/%s/credentials/OS-EC2/%s' %
|
||||
(user_id, access))
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
@ -13,12 +13,12 @@
|
||||
# the License.
|
||||
|
||||
from tempest.lib.services.identity.v2.endpoints_client import EndpointsClient
|
||||
from tempest.lib.services.identity.v2.roles_client import RolesClient
|
||||
from tempest.lib.services.identity.v2.services_client import ServicesClient
|
||||
from tempest.lib.services.identity.v2.tenants_client import TenantsClient
|
||||
from tempest.lib.services.identity.v2.token_client import TokenClient
|
||||
from tempest.lib.services.identity.v2.users_client import UsersClient
|
||||
from tempest.services.identity.v2.json.identity_client import IdentityClient
|
||||
from tempest.services.identity.v2.json.roles_client import RolesClient
|
||||
from tempest.services.identity.v2.json.services_client import ServicesClient
|
||||
from tempest.services.identity.v2.json.tenants_client import TenantsClient
|
||||
from tempest.services.identity.v2.json.users_client import UsersClient
|
||||
|
||||
__all__ = ['EndpointsClient', 'TokenClient', 'IdentityClient', 'RolesClient',
|
||||
'ServicesClient', 'TenantsClient', 'UsersClient']
|
||||
|
@ -22,14 +22,14 @@ from tempest import config
|
||||
from tempest import exceptions
|
||||
from tempest.lib.common import rest_client
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest.lib.services.identity.v2 import roles_client as v2_roles_client
|
||||
from tempest.lib.services.identity.v2 import tenants_client as \
|
||||
v2_tenants_client
|
||||
from tempest.lib.services.identity.v2 import token_client as v2_token_client
|
||||
from tempest.lib.services.identity.v2 import users_client as v2_users_client
|
||||
from tempest.lib.services.identity.v3 import token_client as v3_token_client
|
||||
from tempest.lib.services.network import routers_client
|
||||
from tempest.services.identity.v2.json import identity_client as v2_iden_client
|
||||
from tempest.services.identity.v2.json import roles_client as v2_roles_client
|
||||
from tempest.services.identity.v2.json import tenants_client as \
|
||||
v2_tenants_client
|
||||
from tempest.services.identity.v2.json import users_client as v2_users_client
|
||||
from tempest.services.identity.v3.json import domains_client
|
||||
from tempest.services.identity.v3.json import identity_client as v3_iden_client
|
||||
from tempest.services.identity.v3.json import projects_client as \
|
||||
|
@ -12,7 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.services.identity.v2.json import roles_client
|
||||
from tempest.lib.services.identity.v2 import roles_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
@ -0,0 +1,97 @@
|
||||
# Copyright 2016 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.identity.v2 import services_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
|
||||
class TestServicesClient(base.BaseServiceTest):
|
||||
FAKE_SERVICE_INFO = {
|
||||
"OS-KSADM:service": {
|
||||
"id": "1",
|
||||
"name": "test",
|
||||
"type": "compute",
|
||||
"description": "test_description"
|
||||
}
|
||||
}
|
||||
|
||||
FAKE_LIST_SERVICES = {
|
||||
"OS-KSADM:services": [
|
||||
{
|
||||
"id": "1",
|
||||
"name": "test",
|
||||
"type": "compute",
|
||||
"description": "test_description"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"name": "test2",
|
||||
"type": "compute",
|
||||
"description": "test2_description"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestServicesClient, self).setUp()
|
||||
fake_auth = fake_auth_provider.FakeAuthProvider()
|
||||
self.client = services_client.ServicesClient(fake_auth,
|
||||
'identity', 'regionOne')
|
||||
|
||||
def _test_create_service(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.create_service,
|
||||
'tempest.lib.common.rest_client.RestClient.post',
|
||||
self.FAKE_SERVICE_INFO,
|
||||
bytes_body,
|
||||
id="1",
|
||||
name="test",
|
||||
type="compute",
|
||||
description="test_description")
|
||||
|
||||
def _test_show_service(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.show_service,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_SERVICE_INFO,
|
||||
bytes_body,
|
||||
service_id="1")
|
||||
|
||||
def _test_list_services(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.list_services,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_LIST_SERVICES,
|
||||
bytes_body)
|
||||
|
||||
def test_create_service_with_str_body(self):
|
||||
self._test_create_service()
|
||||
|
||||
def test_create_service_with_bytes_body(self):
|
||||
self._test_create_service(bytes_body=True)
|
||||
|
||||
def test_show_service_with_str_body(self):
|
||||
self._test_show_service()
|
||||
|
||||
def test_show_service_with_bytes_body(self):
|
||||
self._test_show_service(bytes_body=True)
|
||||
|
||||
def test_delete_service(self):
|
||||
self.check_service_client_function(
|
||||
self.client.delete_service,
|
||||
'tempest.lib.common.rest_client.RestClient.delete',
|
||||
{},
|
||||
service_id="1",
|
||||
status=204)
|
131
tempest/tests/lib/services/identity/v2/test_tenants_client.py
Normal file
131
tempest/tests/lib/services/identity/v2/test_tenants_client.py
Normal file
@ -0,0 +1,131 @@
|
||||
# Copyright 2016 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.identity.v2 import tenants_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
|
||||
class TestTenantsClient(base.BaseServiceTest):
|
||||
FAKE_TENANT_INFO = {
|
||||
"tenant": {
|
||||
"id": "1",
|
||||
"name": "test",
|
||||
"description": "test_description",
|
||||
"enabled": True
|
||||
}
|
||||
}
|
||||
|
||||
FAKE_LIST_TENANTS = {
|
||||
"tenants": [
|
||||
{
|
||||
"id": "1",
|
||||
"name": "test",
|
||||
"description": "test_description",
|
||||
"enabled": True
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"name": "test2",
|
||||
"description": "test2_description",
|
||||
"enabled": True
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestTenantsClient, self).setUp()
|
||||
fake_auth = fake_auth_provider.FakeAuthProvider()
|
||||
self.client = tenants_client.TenantsClient(fake_auth,
|
||||
'identity', 'regionOne')
|
||||
|
||||
def _test_create_tenant(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.create_tenant,
|
||||
'tempest.lib.common.rest_client.RestClient.post',
|
||||
self.FAKE_TENANT_INFO,
|
||||
bytes_body,
|
||||
name="test",
|
||||
description="test_description")
|
||||
|
||||
def _test_show_tenant(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.show_tenant,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_TENANT_INFO,
|
||||
bytes_body,
|
||||
tenant_id="1")
|
||||
|
||||
def _test_update_tenant(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.update_tenant,
|
||||
'tempest.lib.common.rest_client.RestClient.post',
|
||||
self.FAKE_TENANT_INFO,
|
||||
bytes_body,
|
||||
tenant_id="1",
|
||||
name="test",
|
||||
description="test_description")
|
||||
|
||||
def _test_list_tenants(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.list_tenants,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_LIST_TENANTS,
|
||||
bytes_body)
|
||||
|
||||
def _test_list_tenant_users(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.list_tenant_users,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_LIST_TENANTS,
|
||||
bytes_body,
|
||||
tenant_id="1")
|
||||
|
||||
def test_create_tenant_with_str_body(self):
|
||||
self._test_create_tenant()
|
||||
|
||||
def test_create_tenant_with_bytes_body(self):
|
||||
self._test_create_tenant(bytes_body=True)
|
||||
|
||||
def test_show_tenant_with_str_body(self):
|
||||
self._test_show_tenant()
|
||||
|
||||
def test_show_tenant_with_bytes_body(self):
|
||||
self._test_show_tenant(bytes_body=True)
|
||||
|
||||
def test_update_tenant_with_str_body(self):
|
||||
self._test_update_tenant()
|
||||
|
||||
def test_update_tenant_with_bytes_body(self):
|
||||
self._test_update_tenant(bytes_body=True)
|
||||
|
||||
def test_list_tenants_with_str_body(self):
|
||||
self._test_list_tenants()
|
||||
|
||||
def test_list_tenants_with_bytes_body(self):
|
||||
self._test_list_tenants(bytes_body=True)
|
||||
|
||||
def test_delete_tenant(self):
|
||||
self.check_service_client_function(
|
||||
self.client.delete_tenant,
|
||||
'tempest.lib.common.rest_client.RestClient.delete',
|
||||
{},
|
||||
tenant_id="1",
|
||||
status=204)
|
||||
|
||||
def test_list_tenant_users_with_str_body(self):
|
||||
self._test_list_tenant_users()
|
||||
|
||||
def test_list_tenant_users_with_bytes_body(self):
|
||||
self._test_list_tenant_users(bytes_body=True)
|
243
tempest/tests/lib/services/identity/v2/test_users_client.py
Normal file
243
tempest/tests/lib/services/identity/v2/test_users_client.py
Normal file
@ -0,0 +1,243 @@
|
||||
# Copyright 2016 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib.services.identity.v2 import users_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
|
||||
class TestUsersClient(base.BaseServiceTest):
|
||||
FAKE_USER_INFO = {
|
||||
"user": {
|
||||
"id": "1",
|
||||
"name": "test",
|
||||
"email": "john.smith@example.org",
|
||||
"enabled": True
|
||||
}
|
||||
}
|
||||
|
||||
FAKE_LIST_USERS = {
|
||||
"users": [
|
||||
{
|
||||
"id": "1",
|
||||
"name": "test",
|
||||
"email": "john.smith@example.org",
|
||||
"enabled": True
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"name": "test2",
|
||||
"email": "john.smith@example.org",
|
||||
"enabled": True
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
FAKE_USER_EC2_CREDENTIAL_INFO = {
|
||||
"credential": {
|
||||
'user_id': '9beb0e12f3e5416db8d7cccfc785db3b',
|
||||
'access': '79abf59acc77492a86170cbe2f1feafa',
|
||||
'secret': 'c4e7d3a691fd4563873d381a40320f46',
|
||||
'trust_id': None,
|
||||
'tenant_id': '596557269d7b4dd78631a602eb9f151d'
|
||||
}
|
||||
}
|
||||
|
||||
FAKE_LIST_USER_EC2_CREDENTIALS = {
|
||||
"credentials": [
|
||||
{
|
||||
'user_id': '9beb0e12f3e5416db8d7cccfc785db3b',
|
||||
'access': '79abf59acc77492a86170cbe2f1feafa',
|
||||
'secret': 'c4e7d3a691fd4563873d381a40320f46',
|
||||
'trust_id': None,
|
||||
'tenant_id': '596557269d7b4dd78631a602eb9f151d'
|
||||
},
|
||||
{
|
||||
'user_id': '3beb0e12f3e5416db8d7cccfc785de4r',
|
||||
'access': '45abf59acc77492a86170cbe2f1fesde',
|
||||
'secret': 'g4e7d3a691fd4563873d381a40320e45',
|
||||
'trust_id': None,
|
||||
'tenant_id': '123557269d7b4dd78631a602eb9f112f'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestUsersClient, self).setUp()
|
||||
fake_auth = fake_auth_provider.FakeAuthProvider()
|
||||
self.client = users_client.UsersClient(fake_auth,
|
||||
'identity', 'regionOne')
|
||||
|
||||
def _test_create_user(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.create_user,
|
||||
'tempest.lib.common.rest_client.RestClient.post',
|
||||
self.FAKE_USER_INFO,
|
||||
bytes_body,
|
||||
name="test",
|
||||
email="john.smith@example.org")
|
||||
|
||||
def _test_update_user(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.update_user,
|
||||
'tempest.lib.common.rest_client.RestClient.put',
|
||||
self.FAKE_USER_INFO,
|
||||
bytes_body,
|
||||
user_id="1",
|
||||
name="test")
|
||||
|
||||
def _test_show_user(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.show_user,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_USER_INFO,
|
||||
bytes_body,
|
||||
user_id="1")
|
||||
|
||||
def _test_list_users(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.list_users,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_LIST_USERS,
|
||||
bytes_body)
|
||||
|
||||
def _test_update_user_enabled(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.update_user_enabled,
|
||||
'tempest.lib.common.rest_client.RestClient.put',
|
||||
self.FAKE_USER_INFO,
|
||||
bytes_body,
|
||||
user_id="1",
|
||||
enabled=True)
|
||||
|
||||
def _test_update_user_password(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.update_user_password,
|
||||
'tempest.lib.common.rest_client.RestClient.put',
|
||||
self.FAKE_USER_INFO,
|
||||
bytes_body,
|
||||
user_id="1",
|
||||
password="pass")
|
||||
|
||||
def _test_update_user_own_password(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.update_user_own_password,
|
||||
'tempest.lib.common.rest_client.RestClient.patch',
|
||||
self.FAKE_USER_INFO,
|
||||
bytes_body,
|
||||
user_id="1",
|
||||
password="pass")
|
||||
|
||||
def _test_create_user_ec2_credential(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.create_user_ec2_credential,
|
||||
'tempest.lib.common.rest_client.RestClient.post',
|
||||
self.FAKE_USER_EC2_CREDENTIAL_INFO,
|
||||
bytes_body,
|
||||
user_id="1",
|
||||
tenant_id="123")
|
||||
|
||||
def _test_show_user_ec2_credential(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.show_user_ec2_credential,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_USER_EC2_CREDENTIAL_INFO,
|
||||
bytes_body,
|
||||
user_id="1",
|
||||
access="123")
|
||||
|
||||
def _test_list_user_ec2_credentials(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.list_user_ec2_credentials,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_LIST_USER_EC2_CREDENTIALS,
|
||||
bytes_body,
|
||||
user_id="1")
|
||||
|
||||
def test_create_user_with_str_body(self):
|
||||
self._test_create_user()
|
||||
|
||||
def test_create_user_with_bytes_body(self):
|
||||
self._test_create_user(bytes_body=True)
|
||||
|
||||
def test_update_user_with_str_body(self):
|
||||
self._test_update_user()
|
||||
|
||||
def test_update_user_with_bytes_body(self):
|
||||
self._test_update_user(bytes_body=True)
|
||||
|
||||
def test_show_user_with_str_body(self):
|
||||
self._test_show_user()
|
||||
|
||||
def test_show_user_with_bytes_body(self):
|
||||
self._test_show_user(bytes_body=True)
|
||||
|
||||
def test_list_users_with_str_body(self):
|
||||
self._test_list_users()
|
||||
|
||||
def test_list_users_with_bytes_body(self):
|
||||
self._test_list_users(bytes_body=True)
|
||||
|
||||
def test_delete_user(self):
|
||||
self.check_service_client_function(
|
||||
self.client.delete_user,
|
||||
'tempest.lib.common.rest_client.RestClient.delete',
|
||||
{},
|
||||
user_id="1",
|
||||
status=204)
|
||||
|
||||
def test_update_user_enabled_with_str_body(self):
|
||||
self._test_update_user_enabled()
|
||||
|
||||
def test_update_user_enabled_with_bytes_body(self):
|
||||
self._test_update_user_enabled(bytes_body=True)
|
||||
|
||||
def test_update_user_password_with_str_body(self):
|
||||
self._test_update_user_password()
|
||||
|
||||
def test_update_user_password_with_bytes_body(self):
|
||||
self._test_update_user_password(bytes_body=True)
|
||||
|
||||
def test_update_user_own_password_with_str_body(self):
|
||||
self._test_update_user_own_password()
|
||||
|
||||
def test_update_user_own_password_with_bytes_body(self):
|
||||
self._test_update_user_own_password(bytes_body=True)
|
||||
|
||||
def test_create_user_ec2_credential_with_str_body(self):
|
||||
self._test_create_user_ec2_credential()
|
||||
|
||||
def test_create_user_ec2_credential_with_bytes_body(self):
|
||||
self._test_create_user_ec2_credential(bytes_body=True)
|
||||
|
||||
def test_show_user_ec2_credential_with_str_body(self):
|
||||
self._test_show_user_ec2_credential()
|
||||
|
||||
def test_show_user_ec2_credential_with_bytes_body(self):
|
||||
self._test_show_user_ec2_credential(bytes_body=True)
|
||||
|
||||
def test_list_user_ec2_credentials_with_str_body(self):
|
||||
self._test_list_user_ec2_credentials()
|
||||
|
||||
def test_list_user_ec2_credentials_with_bytes_body(self):
|
||||
self._test_list_user_ec2_credentials(bytes_body=True)
|
||||
|
||||
def test_delete_user_ec2_credential(self):
|
||||
self.check_service_client_function(
|
||||
self.client.delete_user_ec2_credential,
|
||||
'tempest.lib.common.rest_client.RestClient.delete',
|
||||
{},
|
||||
user_id="123",
|
||||
access="1234",
|
||||
status=204)
|
Loading…
Reference in New Issue
Block a user