Merge "Keystoneclient tests from venv-installed client"
This commit is contained in:
commit
09d2bdd256
|
@ -7,7 +7,7 @@ test_command=
|
|||
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
group_regex=.*(test_cert_setup|test_keystoneclient)
|
||||
group_regex=.*(test_cert_setup)
|
||||
|
||||
|
||||
# NOTE(morganfainberg): If single-worker mode is wanted (e.g. for live tests)
|
||||
|
|
|
@ -269,51 +269,6 @@ class TestClient(object):
|
|||
return self.request('PUT', path=path, headers=headers, body=body)
|
||||
|
||||
|
||||
class NoModule(object):
|
||||
"""A mixin class to provide support for unloading/disabling modules."""
|
||||
|
||||
def setUp(self):
|
||||
super(NoModule, self).setUp()
|
||||
|
||||
self._finders = []
|
||||
|
||||
def cleanup_finders():
|
||||
for finder in self._finders:
|
||||
sys.meta_path.remove(finder)
|
||||
del self._finders
|
||||
self.addCleanup(cleanup_finders)
|
||||
|
||||
self._cleared_modules = {}
|
||||
|
||||
def cleanup_modules():
|
||||
sys.modules.update(self._cleared_modules)
|
||||
del self._cleared_modules
|
||||
self.addCleanup(cleanup_modules)
|
||||
|
||||
def clear_module(self, module):
|
||||
cleared_modules = {}
|
||||
for fullname in sys.modules.keys():
|
||||
if fullname == module or fullname.startswith(module + '.'):
|
||||
cleared_modules[fullname] = sys.modules.pop(fullname)
|
||||
return cleared_modules
|
||||
|
||||
def disable_module(self, module):
|
||||
"""Ensure ImportError for the specified module."""
|
||||
|
||||
# Clear 'module' references in sys.modules
|
||||
self._cleared_modules.update(self.clear_module(module))
|
||||
|
||||
# Disallow further imports of 'module'
|
||||
class NoModule(object):
|
||||
def find_module(self, fullname, path):
|
||||
if fullname == module or fullname.startswith(module + '.'):
|
||||
raise ImportError
|
||||
|
||||
finder = NoModule()
|
||||
self._finders.append(finder)
|
||||
sys.meta_path.insert(0, finder)
|
||||
|
||||
|
||||
class BaseTestCase(oslotest.BaseTestCase):
|
||||
"""Light weight base test class.
|
||||
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
# under the License.
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
from keystoneclient.v2_0 import client as ks_client
|
||||
import mock
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import timeutils
|
||||
|
@ -30,15 +31,12 @@ from keystone.tests.ksfixtures import database
|
|||
|
||||
CONF = config.CONF
|
||||
DEFAULT_DOMAIN_ID = CONF.identity.default_domain_id
|
||||
OPENSTACK_REPO = os.environ.get('OPENSTACK_REPO',
|
||||
'https://git.openstack.org/openstack')
|
||||
KEYSTONECLIENT_REPO = '%s/python-keystoneclient.git' % OPENSTACK_REPO
|
||||
|
||||
|
||||
class CompatTestCase(tests.NoModule, tests.TestCase):
|
||||
class ClientDrivenTestCase(tests.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(CompatTestCase, self).setUp()
|
||||
super(ClientDrivenTestCase, self).setUp()
|
||||
|
||||
# FIXME(morganfainberg): Since we are running tests through the
|
||||
# controllers and some internal api drivers are SQL-only, the correct
|
||||
|
@ -65,13 +63,6 @@ class CompatTestCase(tests.NoModule, tests.TestCase):
|
|||
|
||||
self.addCleanup(self.cleanup_instance('public_server', 'admin_server'))
|
||||
|
||||
if isinstance(self.checkout_info, str):
|
||||
revdir = self.checkout_info
|
||||
else:
|
||||
revdir = tests.checkout_vendor(*self.checkout_info)
|
||||
self.add_path(revdir)
|
||||
self.clear_module('keystoneclient')
|
||||
|
||||
def _public_url(self):
|
||||
public_port = self.public_server.socket_info['socket'][1]
|
||||
return "http://localhost:%s/v2.0" % public_port
|
||||
|
@ -81,8 +72,6 @@ class CompatTestCase(tests.NoModule, tests.TestCase):
|
|||
return "http://localhost:%s/v2.0" % admin_port
|
||||
|
||||
def _client(self, admin=False, **kwargs):
|
||||
from keystoneclient.v2_0 import client as ks_client
|
||||
|
||||
url = self._admin_url() if admin else self._public_url()
|
||||
kc = ks_client.Client(endpoint=url,
|
||||
auth_url=self._public_url(),
|
||||
|
@ -114,10 +103,6 @@ class CompatTestCase(tests.NoModule, tests.TestCase):
|
|||
tenant_id=tenant_id,
|
||||
admin=admin)
|
||||
|
||||
|
||||
class KeystoneClientTests(object):
|
||||
"""Tests for all versions of keystoneclient."""
|
||||
|
||||
def test_authenticate_tenant_name_and_tenants(self):
|
||||
client = self.get_client()
|
||||
tenants = client.tenants.list()
|
||||
|
@ -131,7 +116,6 @@ class KeystoneClientTests(object):
|
|||
self.assertEqual(self.tenant_bar['id'], tenants[0].id)
|
||||
|
||||
def test_authenticate_invalid_tenant_id(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
self.assertRaises(client_exceptions.Unauthorized,
|
||||
self._client,
|
||||
username=self.user_foo['name'],
|
||||
|
@ -153,7 +137,6 @@ class KeystoneClientTests(object):
|
|||
self.assertEqual(self.tenant_bar['id'], tenants[0].id)
|
||||
|
||||
def test_authenticate_token_invalid_tenant_id(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client()
|
||||
token = client.auth_token
|
||||
self.assertRaises(client_exceptions.Unauthorized,
|
||||
|
@ -161,7 +144,6 @@ class KeystoneClientTests(object):
|
|||
tenant_id=uuid.uuid4().hex)
|
||||
|
||||
def test_authenticate_token_invalid_tenant_name(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client()
|
||||
token = client.auth_token
|
||||
self.assertRaises(client_exceptions.Unauthorized,
|
||||
|
@ -177,8 +159,6 @@ class KeystoneClientTests(object):
|
|||
self.assertEqual(self.tenant_bar['id'], tenants[0].id)
|
||||
|
||||
def test_authenticate_and_delete_token(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
client = self.get_client(admin=True)
|
||||
token = client.auth_token
|
||||
token_client = self._client(token=token)
|
||||
|
@ -191,8 +171,6 @@ class KeystoneClientTests(object):
|
|||
token_client.tenants.list)
|
||||
|
||||
def test_authenticate_no_password(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
user_ref = self.user_foo.copy()
|
||||
user_ref['password'] = None
|
||||
self.assertRaises(client_exceptions.AuthorizationFailure,
|
||||
|
@ -200,8 +178,6 @@ class KeystoneClientTests(object):
|
|||
user_ref)
|
||||
|
||||
def test_authenticate_no_username(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
user_ref = self.user_foo.copy()
|
||||
user_ref['name'] = None
|
||||
self.assertRaises(client_exceptions.AuthorizationFailure,
|
||||
|
@ -209,8 +185,6 @@ class KeystoneClientTests(object):
|
|||
user_ref)
|
||||
|
||||
def test_authenticate_disabled_tenant(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
admin_client = self.get_client(admin=True)
|
||||
|
||||
tenant = {
|
||||
|
@ -261,8 +235,6 @@ class KeystoneClientTests(object):
|
|||
# FIXME(ja): add a test that admin endpoint returns unauthorized if not
|
||||
# admin
|
||||
def test_tenant_create_update_and_delete(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
tenant_name = 'original_tenant'
|
||||
tenant_description = 'My original tenant!'
|
||||
tenant_enabled = True
|
||||
|
@ -316,8 +288,6 @@ class KeystoneClientTests(object):
|
|||
if t.id == tenant.id])
|
||||
|
||||
def test_tenant_create_update_and_delete_unicode(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
tenant_name = u'original \u540d\u5b57'
|
||||
tenant_description = 'My original tenant!'
|
||||
tenant_enabled = True
|
||||
|
@ -372,28 +342,24 @@ class KeystoneClientTests(object):
|
|||
if t.id == tenant.id])
|
||||
|
||||
def test_tenant_create_no_name(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.BadRequest,
|
||||
client.tenants.create,
|
||||
tenant_name="")
|
||||
|
||||
def test_tenant_delete_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.tenants.delete,
|
||||
tenant=uuid.uuid4().hex)
|
||||
|
||||
def test_tenant_get_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.tenants.get,
|
||||
tenant_id=uuid.uuid4().hex)
|
||||
|
||||
def test_tenant_update_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.tenants.update,
|
||||
|
@ -410,8 +376,6 @@ class KeystoneClientTests(object):
|
|||
self.assertEqual(len(default_fixtures.TENANTS), len(tenants))
|
||||
|
||||
def test_invalid_password(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
good_client = self._client(username=self.user_foo['name'],
|
||||
password=self.user_foo['password'])
|
||||
good_client.tenants.list()
|
||||
|
@ -422,16 +386,12 @@ class KeystoneClientTests(object):
|
|||
password=uuid.uuid4().hex)
|
||||
|
||||
def test_invalid_user_and_password(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
self.assertRaises(client_exceptions.Unauthorized,
|
||||
self._client,
|
||||
username=uuid.uuid4().hex,
|
||||
password=uuid.uuid4().hex)
|
||||
|
||||
def test_change_password_invalidates_token(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
client = self.get_client(admin=True)
|
||||
|
||||
username = uuid.uuid4().hex
|
||||
|
@ -453,8 +413,6 @@ class KeystoneClientTests(object):
|
|||
token=token_id)
|
||||
|
||||
def test_disable_tenant_invalidates_token(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
admin_client = self.get_client(admin=True)
|
||||
foo_client = self.get_client(self.user_foo)
|
||||
tenant_bar = admin_client.tenants.get(self.tenant_bar['id'])
|
||||
|
@ -473,8 +431,6 @@ class KeystoneClientTests(object):
|
|||
self.user_foo)
|
||||
|
||||
def test_delete_tenant_invalidates_token(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
admin_client = self.get_client(admin=True)
|
||||
foo_client = self.get_client(self.user_foo)
|
||||
tenant_bar = admin_client.tenants.get(self.tenant_bar['id'])
|
||||
|
@ -493,8 +449,6 @@ class KeystoneClientTests(object):
|
|||
self.user_foo)
|
||||
|
||||
def test_disable_user_invalidates_token(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
admin_client = self.get_client(admin=True)
|
||||
foo_client = self.get_client(self.user_foo)
|
||||
|
||||
|
@ -510,8 +464,6 @@ class KeystoneClientTests(object):
|
|||
self.user_foo)
|
||||
|
||||
def test_delete_user_invalidates_token(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
admin_client = self.get_client(admin=True)
|
||||
client = self.get_client(admin=False)
|
||||
|
||||
|
@ -549,8 +501,6 @@ class KeystoneClientTests(object):
|
|||
timeutils.parse_isotime(reauthenticated_token.expires))
|
||||
|
||||
def test_user_create_update_delete(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
test_username = 'new_user'
|
||||
client = self.get_client(admin=True)
|
||||
user = client.users.create(name=test_username,
|
||||
|
@ -612,7 +562,6 @@ class KeystoneClientTests(object):
|
|||
user=user, tenant=self.tenant_bar['id'])
|
||||
|
||||
def test_user_create_no_string_password(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.BadRequest,
|
||||
client.users.create,
|
||||
|
@ -621,7 +570,6 @@ class KeystoneClientTests(object):
|
|||
email=uuid.uuid4().hex)
|
||||
|
||||
def test_user_create_no_name(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.BadRequest,
|
||||
client.users.create,
|
||||
|
@ -630,7 +578,6 @@ class KeystoneClientTests(object):
|
|||
email=uuid.uuid4().hex)
|
||||
|
||||
def test_user_create_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.users.create,
|
||||
|
@ -640,21 +587,18 @@ class KeystoneClientTests(object):
|
|||
tenant_id=uuid.uuid4().hex)
|
||||
|
||||
def test_user_get_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.users.get,
|
||||
user=uuid.uuid4().hex)
|
||||
|
||||
def test_user_list_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.users.list,
|
||||
tenant_id=uuid.uuid4().hex)
|
||||
|
||||
def test_user_update_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.users.update,
|
||||
|
@ -668,7 +612,6 @@ class KeystoneClientTests(object):
|
|||
self.assertEqual(tenant_id, user.tenant_id)
|
||||
|
||||
def test_user_update_password_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.users.update_password,
|
||||
|
@ -676,7 +619,6 @@ class KeystoneClientTests(object):
|
|||
password=uuid.uuid4().hex)
|
||||
|
||||
def test_user_delete_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.users.delete,
|
||||
|
@ -700,8 +642,6 @@ class KeystoneClientTests(object):
|
|||
self.assertEqual(self.role_admin['id'], role.id)
|
||||
|
||||
def test_role_crud(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
test_role = 'new_role'
|
||||
client = self.get_client(admin=True)
|
||||
role = client.roles.create(name=test_role)
|
||||
|
@ -720,28 +660,24 @@ class KeystoneClientTests(object):
|
|||
role=role.id)
|
||||
|
||||
def test_role_create_no_name(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.BadRequest,
|
||||
client.roles.create,
|
||||
name="")
|
||||
|
||||
def test_role_get_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.roles.get,
|
||||
role=uuid.uuid4().hex)
|
||||
|
||||
def test_role_delete_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.roles.delete,
|
||||
role=uuid.uuid4().hex)
|
||||
|
||||
def test_role_list_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.roles.roles_for_user,
|
||||
|
@ -763,7 +699,6 @@ class KeystoneClientTests(object):
|
|||
self.assertTrue(len(roles) > 0)
|
||||
|
||||
def test_service_crud(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
|
||||
service_name = uuid.uuid4().hex
|
||||
|
@ -799,28 +734,24 @@ class KeystoneClientTests(object):
|
|||
self.assertEqual(0, len(services))
|
||||
|
||||
def test_service_delete_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.services.delete,
|
||||
id=uuid.uuid4().hex)
|
||||
|
||||
def test_service_get_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.services.get,
|
||||
id=uuid.uuid4().hex)
|
||||
|
||||
def test_endpoint_delete_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.endpoints.delete,
|
||||
id=uuid.uuid4().hex)
|
||||
|
||||
def test_admin_requires_adminness(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
# FIXME(ja): this should be Unauthorized
|
||||
exception = client_exceptions.ClientException
|
||||
|
||||
|
@ -889,7 +820,6 @@ class KeystoneClientTests(object):
|
|||
self.assertNotIn(self.user_two['id'], [x.id for x in user_refs])
|
||||
|
||||
def test_user_role_add_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.roles.add_user_role,
|
||||
|
@ -910,7 +840,6 @@ class KeystoneClientTests(object):
|
|||
role=self.role_member['id'])
|
||||
|
||||
def test_user_role_remove_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.roles.remove_user_role,
|
||||
|
@ -954,8 +883,6 @@ class KeystoneClientTests(object):
|
|||
self.assertEqual(tenants_marker[1].name, tenants[2].name)
|
||||
|
||||
def test_tenant_list_marker_not_found(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
client = self.get_client()
|
||||
self.assertRaises(client_exceptions.BadRequest,
|
||||
client.tenants.list, marker=uuid.uuid4().hex)
|
||||
|
@ -981,8 +908,6 @@ class KeystoneClientTests(object):
|
|||
self.assertEqual(tenants[1].name, tenants_limited[1].name)
|
||||
|
||||
def test_tenant_list_limit_bad_value(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
client = self.get_client()
|
||||
self.assertRaises(client_exceptions.BadRequest,
|
||||
client.tenants.list, limit='a')
|
||||
|
@ -1021,8 +946,6 @@ class KeystoneClientTests(object):
|
|||
self.get_client(self.user_two)
|
||||
|
||||
def test_user_cannot_update_other_users_passwd(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
client = self.get_client(self.user_two)
|
||||
|
||||
token_id = client.auth_token
|
||||
|
@ -1050,8 +973,6 @@ class KeystoneClientTests(object):
|
|||
self.get_client, self.user_two)
|
||||
|
||||
def test_tokens_after_user_update_passwd(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
client = self.get_client(self.user_two)
|
||||
|
||||
token_id = client.auth_token
|
||||
|
@ -1080,28 +1001,3 @@ class KeystoneClientTests(object):
|
|||
self.assertRaises(client_exceptions.Unauthorized, client.tenants.list)
|
||||
client.auth_token = new_token_id
|
||||
client.tenants.list()
|
||||
|
||||
|
||||
class KcMasterTestCase(CompatTestCase, KeystoneClientTests):
|
||||
checkout_info = (KEYSTONECLIENT_REPO, 'master')
|
||||
|
||||
def setUp(self):
|
||||
if os.environ.get('KSCTEST_PATH'):
|
||||
self.skip('KSCTEST_PATH env set, running tests with local '
|
||||
'client instead.')
|
||||
super(KcMasterTestCase, self).setUp()
|
||||
|
||||
|
||||
class KcOptTestCase(KcMasterTestCase):
|
||||
# Set KSCTEST_PATH to the keystoneclient directory, then run this test.
|
||||
#
|
||||
# For example, to test your local keystoneclient,
|
||||
#
|
||||
# KSCTEST_PATH=/opt/stack/python-keystoneclient;
|
||||
# tox -e py27 test_keystoneclient.KcOptTestCase
|
||||
|
||||
def setUp(self):
|
||||
self.checkout_info = os.environ.get('KSCTEST_PATH')
|
||||
if not self.checkout_info:
|
||||
self.skip('Set KSCTEST_PATH env to test with local client')
|
||||
super(KcOptTestCase, self).setUp()
|
||||
|
|
|
@ -12,29 +12,27 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from keystoneclient.contrib.ec2 import utils as ec2_utils
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
from keystone import tests
|
||||
from keystone.tests import test_keystoneclient
|
||||
|
||||
|
||||
class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
|
||||
class ClientDrivenSqlTestCase(test_keystoneclient.ClientDrivenTestCase):
|
||||
def config_files(self):
|
||||
config_files = super(KcMasterSqlTestCase, self).config_files()
|
||||
config_files = super(ClientDrivenSqlTestCase, self).config_files()
|
||||
config_files.append(tests.dirs.tests_conf('backend_sql.conf'))
|
||||
return config_files
|
||||
|
||||
def setUp(self):
|
||||
super(KcMasterSqlTestCase, self).setUp()
|
||||
super(ClientDrivenSqlTestCase, self).setUp()
|
||||
self.default_client = self.get_client()
|
||||
self.addCleanup(self.cleanup_instance('default_client'))
|
||||
|
||||
def test_endpoint_crud(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
client = self.get_client(admin=True)
|
||||
|
||||
service = client.services.create(name=uuid.uuid4().hex,
|
||||
|
@ -142,8 +140,6 @@ class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
|
|||
# this test..
|
||||
|
||||
def test_ec2_auth_failure(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
credentials, signature = self._generate_default_user_ec2_credentials()
|
||||
credentials['signature'] = uuid.uuid4().hex
|
||||
self.assertRaises(client_exceptions.Unauthorized,
|
||||
|
@ -206,7 +202,6 @@ class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
|
|||
self.assertNotIn(cred_4, creds)
|
||||
|
||||
def test_ec2_credentials_create_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
self.default_client.ec2.create,
|
||||
user_id=uuid.uuid4().hex,
|
||||
|
@ -217,38 +212,28 @@ class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
|
|||
tenant_id=uuid.uuid4().hex)
|
||||
|
||||
def test_ec2_credentials_delete_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
self.default_client.ec2.delete,
|
||||
user_id=uuid.uuid4().hex,
|
||||
access=uuid.uuid4().hex)
|
||||
|
||||
def test_ec2_credentials_get_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
self.default_client.ec2.get,
|
||||
user_id=uuid.uuid4().hex,
|
||||
access=uuid.uuid4().hex)
|
||||
|
||||
def test_ec2_credentials_list_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
self.default_client.ec2.list,
|
||||
user_id=uuid.uuid4().hex)
|
||||
|
||||
def test_ec2_credentials_list_user_forbidden(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
two = self.get_client(self.user_two)
|
||||
self.assertRaises(client_exceptions.Forbidden, two.ec2.list,
|
||||
user_id=self.user_foo['id'])
|
||||
|
||||
def test_ec2_credentials_get_user_forbidden(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
cred = self.default_client.ec2.create(user_id=self.user_foo['id'],
|
||||
tenant_id=self.tenant_bar['id'])
|
||||
|
||||
|
@ -260,8 +245,6 @@ class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
|
|||
access=cred.access)
|
||||
|
||||
def test_ec2_credentials_delete_user_forbidden(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
cred = self.default_client.ec2.create(user_id=self.user_foo['id'],
|
||||
tenant_id=self.tenant_bar['id'])
|
||||
|
||||
|
@ -273,7 +256,6 @@ class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
|
|||
access=cred.access)
|
||||
|
||||
def test_endpoint_create_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.endpoints.create,
|
||||
|
@ -284,15 +266,12 @@ class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
|
|||
internalurl=uuid.uuid4().hex)
|
||||
|
||||
def test_endpoint_delete_404(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
client = self.get_client(admin=True)
|
||||
self.assertRaises(client_exceptions.NotFound,
|
||||
client.endpoints.delete,
|
||||
id=uuid.uuid4().hex)
|
||||
|
||||
def test_policy_crud(self):
|
||||
from keystoneclient import exceptions as client_exceptions
|
||||
|
||||
# FIXME(dolph): this test was written prior to the v3 implementation of
|
||||
# the client and essentially refers to a non-existent
|
||||
# policy manager in the v2 client. this test needs to be
|
||||
|
@ -363,18 +342,3 @@ class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
|
|||
policy=policy.id)
|
||||
policies = [x for x in client.policies.list() if x.id == policy.id]
|
||||
self.assertEqual(0, len(policies))
|
||||
|
||||
|
||||
class KcOptTestCase(KcMasterSqlTestCase):
|
||||
# Set KSCTEST_PATH to the keystoneclient directory, then run this test.
|
||||
#
|
||||
# For example, to test your local keystoneclient,
|
||||
#
|
||||
# KSCTEST_PATH=/opt/stack/python-keystoneclient;
|
||||
# tox -e py27 test_keystoneclient_sql.KcOptTestCase
|
||||
|
||||
def setUp(self):
|
||||
self.checkout_info = os.environ.get('KSCTEST_PATH')
|
||||
if not self.checkout_info:
|
||||
self.skip('Set KSCTEST_PATH env to test with local client')
|
||||
super(KcOptTestCase, self).setUp()
|
||||
|
|
|
@ -47,10 +47,6 @@ testrepository>=0.0.18
|
|||
testtools>=0.9.36,!=1.2.0
|
||||
testscenarios>=0.4
|
||||
|
||||
# for python-keystoneclient
|
||||
requests>=2.2.0,!=2.4.0
|
||||
keyring>=2.1,!=3.3
|
||||
|
||||
# For documentation
|
||||
oslosphinx>=2.2.0 # Apache-2.0
|
||||
|
||||
|
|
|
@ -48,10 +48,6 @@ testrepository>=0.0.18
|
|||
testtools>=0.9.36,!=1.2.0
|
||||
testscenarios>=0.4
|
||||
|
||||
# for python-keystoneclient
|
||||
requests>=2.2.0,!=2.4.0
|
||||
keyring>=2.1,!=3.3
|
||||
|
||||
# For documentation
|
||||
oslosphinx>=2.2.0 # Apache-2.0
|
||||
|
||||
|
|
Loading…
Reference in New Issue