Fixing pep8 errors in tests/*py
Fixes bug 1022575 Making change to tests/*py to pass pep8 tests. pep8 tests started failing following39b20acc93
update pep8 to 1.3.304df79b64e
include tests dir in pep8 tests Change-Id: I2d7dec0a87f1ae9b5f828d7f321b65bf8c06a421
This commit is contained in:
parent
41f8843b82
commit
7cdae1bc02
|
@ -18,7 +18,7 @@ TENANTS = [
|
||||||
{'id': 'bar', 'name': 'BAR'},
|
{'id': 'bar', 'name': 'BAR'},
|
||||||
{'id': 'baz', 'name': 'BAZ'},
|
{'id': 'baz', 'name': 'BAZ'},
|
||||||
{'id': 'tenent4add', 'name': 'tenant4add'},
|
{'id': 'tenent4add', 'name': 'tenant4add'},
|
||||||
]
|
]
|
||||||
|
|
||||||
# NOTE(ja): a role of keystone_admin and attribute "is_admin" is done in setUp
|
# NOTE(ja): a role of keystone_admin and attribute "is_admin" is done in setUp
|
||||||
USERS = [
|
USERS = [
|
||||||
|
@ -28,17 +28,17 @@ USERS = [
|
||||||
'name': 'NO_META',
|
'name': 'NO_META',
|
||||||
'password': 'no_meta2',
|
'password': 'no_meta2',
|
||||||
'tenants': ['baz']},
|
'tenants': ['baz']},
|
||||||
]
|
]
|
||||||
|
|
||||||
METADATA = [
|
METADATA = [
|
||||||
{'user_id': 'foo', 'tenant_id': 'bar', 'extra': 'extra'},
|
{'user_id': 'foo', 'tenant_id': 'bar', 'extra': 'extra'},
|
||||||
{'user_id': 'two', 'tenant_id': 'baz', 'extra': 'extra'},
|
{'user_id': 'two', 'tenant_id': 'baz', 'extra': 'extra'},
|
||||||
]
|
]
|
||||||
|
|
||||||
ROLES = [
|
ROLES = [
|
||||||
{'id': 'keystone_admin', 'name': 'Keystone Admin'},
|
{'id': 'keystone_admin', 'name': 'Keystone Admin'},
|
||||||
{'id': 'useless', 'name': 'Useless'},
|
{'id': 'useless', 'name': 'Useless'},
|
||||||
]
|
]
|
||||||
|
|
||||||
SERVICES = [
|
SERVICES = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,8 +45,8 @@ class IdentityTests(object):
|
||||||
|
|
||||||
def test_authenticate_no_tenant(self):
|
def test_authenticate_no_tenant(self):
|
||||||
user_ref, tenant_ref, metadata_ref = self.identity_api.authenticate(
|
user_ref, tenant_ref, metadata_ref = self.identity_api.authenticate(
|
||||||
user_id=self.user_foo['id'],
|
user_id=self.user_foo['id'],
|
||||||
password=self.user_foo['password'])
|
password=self.user_foo['password'])
|
||||||
# NOTE(termie): the password field is left in user_foo to make
|
# NOTE(termie): the password field is left in user_foo to make
|
||||||
# it easier to authenticate in tests, but should
|
# it easier to authenticate in tests, but should
|
||||||
# not be returned by the api
|
# not be returned by the api
|
||||||
|
@ -57,9 +57,9 @@ class IdentityTests(object):
|
||||||
|
|
||||||
def test_authenticate(self):
|
def test_authenticate(self):
|
||||||
user_ref, tenant_ref, metadata_ref = self.identity_api.authenticate(
|
user_ref, tenant_ref, metadata_ref = self.identity_api.authenticate(
|
||||||
user_id=self.user_foo['id'],
|
user_id=self.user_foo['id'],
|
||||||
tenant_id=self.tenant_bar['id'],
|
tenant_id=self.tenant_bar['id'],
|
||||||
password=self.user_foo['password'])
|
password=self.user_foo['password'])
|
||||||
# NOTE(termie): the password field is left in user_foo to make
|
# NOTE(termie): the password field is left in user_foo to make
|
||||||
# it easier to authenticate in tests, but should
|
# it easier to authenticate in tests, but should
|
||||||
# not be returned by the api
|
# not be returned by the api
|
||||||
|
@ -72,9 +72,9 @@ class IdentityTests(object):
|
||||||
user = self.user_no_meta
|
user = self.user_no_meta
|
||||||
tenant = self.tenant_baz
|
tenant = self.tenant_baz
|
||||||
user_ref, tenant_ref, metadata_ref = self.identity_api.authenticate(
|
user_ref, tenant_ref, metadata_ref = self.identity_api.authenticate(
|
||||||
user_id=user['id'],
|
user_id=user['id'],
|
||||||
tenant_id=tenant['id'],
|
tenant_id=tenant['id'],
|
||||||
password=user['password'])
|
password=user['password'])
|
||||||
# NOTE(termie): the password field is left in user_foo to make
|
# NOTE(termie): the password field is left in user_foo to make
|
||||||
# it easier to authenticate in tests, but should
|
# it easier to authenticate in tests, but should
|
||||||
# not be returned by the api
|
# not be returned by the api
|
||||||
|
@ -99,7 +99,7 @@ class IdentityTests(object):
|
||||||
|
|
||||||
def test_get_tenant_by_name(self):
|
def test_get_tenant_by_name(self):
|
||||||
tenant_ref = self.identity_api.get_tenant_by_name(
|
tenant_ref = self.identity_api.get_tenant_by_name(
|
||||||
tenant_name=self.tenant_bar['name'])
|
tenant_name=self.tenant_bar['name'])
|
||||||
self.assertDictEqual(tenant_ref, self.tenant_bar)
|
self.assertDictEqual(tenant_ref, self.tenant_bar)
|
||||||
|
|
||||||
def test_get_tenant_by_name_404(self):
|
def test_get_tenant_by_name_404(self):
|
||||||
|
@ -127,7 +127,7 @@ class IdentityTests(object):
|
||||||
|
|
||||||
def test_get_user_by_name(self):
|
def test_get_user_by_name(self):
|
||||||
user_ref = self.identity_api.get_user_by_name(
|
user_ref = self.identity_api.get_user_by_name(
|
||||||
user_name=self.user_foo['name'])
|
user_name=self.user_foo['name'])
|
||||||
# NOTE(termie): the password field is left in user_foo to make
|
# NOTE(termie): the password field is left in user_foo to make
|
||||||
# it easier to authenticate in tests, but should
|
# it easier to authenticate in tests, but should
|
||||||
# not be returned by the api
|
# not be returned by the api
|
||||||
|
@ -141,8 +141,8 @@ class IdentityTests(object):
|
||||||
|
|
||||||
def test_get_metadata(self):
|
def test_get_metadata(self):
|
||||||
metadata_ref = self.identity_api.get_metadata(
|
metadata_ref = self.identity_api.get_metadata(
|
||||||
user_id=self.user_foo['id'],
|
user_id=self.user_foo['id'],
|
||||||
tenant_id=self.tenant_bar['id'])
|
tenant_id=self.tenant_bar['id'])
|
||||||
self.assertDictEqual(metadata_ref, self.metadata_foobar)
|
self.assertDictEqual(metadata_ref, self.metadata_foobar)
|
||||||
|
|
||||||
def test_get_metadata_404(self):
|
def test_get_metadata_404(self):
|
||||||
|
@ -159,7 +159,7 @@ class IdentityTests(object):
|
||||||
|
|
||||||
def test_get_role(self):
|
def test_get_role(self):
|
||||||
role_ref = self.identity_api.get_role(
|
role_ref = self.identity_api.get_role(
|
||||||
role_id=self.role_keystone_admin['id'])
|
role_id=self.role_keystone_admin['id'])
|
||||||
role_ref_dict = dict((x, role_ref[x]) for x in role_ref)
|
role_ref_dict = dict((x, role_ref[x]) for x in role_ref)
|
||||||
self.assertDictEqual(role_ref_dict, self.role_keystone_admin)
|
self.assertDictEqual(role_ref_dict, self.role_keystone_admin)
|
||||||
|
|
||||||
|
@ -179,10 +179,14 @@ class IdentityTests(object):
|
||||||
role)
|
role)
|
||||||
|
|
||||||
def test_rename_duplicate_role_name_fails(self):
|
def test_rename_duplicate_role_name_fails(self):
|
||||||
role1 = {'id': 'fake1',
|
role1 = {
|
||||||
'name': 'fake1name'}
|
'id': 'fake1',
|
||||||
role2 = {'id': 'fake2',
|
'name': 'fake1name'
|
||||||
'name': 'fake2name'}
|
}
|
||||||
|
role2 = {
|
||||||
|
'id': 'fake2',
|
||||||
|
'name': 'fake2name'
|
||||||
|
}
|
||||||
self.identity_api.create_role('fake1', role1)
|
self.identity_api.create_role('fake1', role1)
|
||||||
self.identity_api.create_role('fake2', role2)
|
self.identity_api.create_role('fake2', role2)
|
||||||
role1['name'] = 'fake2name'
|
role1['name'] = 'fake2name'
|
||||||
|
@ -538,9 +542,9 @@ class TokenTests(object):
|
||||||
|
|
||||||
self.token_api.delete_token(token_id)
|
self.token_api.delete_token(token_id)
|
||||||
self.assertRaises(exception.TokenNotFound,
|
self.assertRaises(exception.TokenNotFound,
|
||||||
self.token_api.get_token, token_id)
|
self.token_api.get_token, token_id)
|
||||||
self.assertRaises(exception.TokenNotFound,
|
self.assertRaises(exception.TokenNotFound,
|
||||||
self.token_api.delete_token, token_id)
|
self.token_api.delete_token, token_id)
|
||||||
|
|
||||||
def test_get_token_404(self):
|
def test_get_token_404(self):
|
||||||
self.assertRaises(exception.TokenNotFound,
|
self.assertRaises(exception.TokenNotFound,
|
||||||
|
@ -559,7 +563,7 @@ class TokenTests(object):
|
||||||
data_ref = self.token_api.create_token(token_id, data)
|
data_ref = self.token_api.create_token(token_id, data)
|
||||||
self.assertDictEqual(data_ref, data)
|
self.assertDictEqual(data_ref, data)
|
||||||
self.assertRaises(exception.TokenNotFound,
|
self.assertRaises(exception.TokenNotFound,
|
||||||
self.token_api.get_token, token_id)
|
self.token_api.get_token, token_id)
|
||||||
|
|
||||||
def test_null_expires_token(self):
|
def test_null_expires_token(self):
|
||||||
token_id = uuid.uuid4().hex
|
token_id = uuid.uuid4().hex
|
||||||
|
@ -572,17 +576,21 @@ class TokenTests(object):
|
||||||
|
|
||||||
class CatalogTests(object):
|
class CatalogTests(object):
|
||||||
def test_service_crud(self):
|
def test_service_crud(self):
|
||||||
new_service = {'id': 'MY_SERVICE', 'type': 'myservice',
|
new_service = {
|
||||||
'name': 'My Service', 'description': 'My description'}
|
'id': 'MY_SERVICE',
|
||||||
|
'type': 'myservice',
|
||||||
|
'name': 'My Service',
|
||||||
|
'description': 'My description'
|
||||||
|
}
|
||||||
res = self.catalog_api.create_service(new_service['id'], new_service)
|
res = self.catalog_api.create_service(new_service['id'], new_service)
|
||||||
self.assertDictEqual(res, new_service)
|
self.assertDictEqual(res, new_service)
|
||||||
|
|
||||||
service_id = new_service['id']
|
service_id = new_service['id']
|
||||||
self.catalog_api.delete_service(service_id)
|
self.catalog_api.delete_service(service_id)
|
||||||
self.assertRaises(exception.ServiceNotFound,
|
self.assertRaises(exception.ServiceNotFound,
|
||||||
self.catalog_man.delete_service, {}, service_id)
|
self.catalog_man.delete_service, {}, service_id)
|
||||||
self.assertRaises(exception.ServiceNotFound,
|
self.assertRaises(exception.ServiceNotFound,
|
||||||
self.catalog_man.get_service, {}, service_id)
|
self.catalog_man.get_service, {}, service_id)
|
||||||
|
|
||||||
def test_get_service_404(self):
|
def test_get_service_404(self):
|
||||||
self.assertRaises(exception.ServiceNotFound,
|
self.assertRaises(exception.ServiceNotFound,
|
||||||
|
@ -598,8 +606,8 @@ class CatalogTests(object):
|
||||||
|
|
||||||
def test_create_endpoint_404(self):
|
def test_create_endpoint_404(self):
|
||||||
endpoint = {
|
endpoint = {
|
||||||
'id': uuid.uuid4().hex,
|
'id': uuid.uuid4().hex,
|
||||||
'service_id': uuid.uuid4().hex,
|
'service_id': uuid.uuid4().hex,
|
||||||
}
|
}
|
||||||
self.assertRaises(exception.ServiceNotFound,
|
self.assertRaises(exception.ServiceNotFound,
|
||||||
self.catalog_api.create_endpoint,
|
self.catalog_api.create_endpoint,
|
||||||
|
|
|
@ -55,10 +55,14 @@ class LDAPIdentity(test.TestCase, test_backend.IdentityTests):
|
||||||
uuid.uuid4().hex)
|
uuid.uuid4().hex)
|
||||||
|
|
||||||
def test_rename_duplicate_role_name_fails(self):
|
def test_rename_duplicate_role_name_fails(self):
|
||||||
role1 = {'id': 'fake1',
|
role1 = {
|
||||||
'name': 'fake1name'}
|
'id': 'fake1',
|
||||||
role2 = {'id': 'fake2',
|
'name': 'fake1name'
|
||||||
'name': 'fake2name'}
|
}
|
||||||
|
role2 = {
|
||||||
|
'id': 'fake2',
|
||||||
|
'name': 'fake2name'
|
||||||
|
}
|
||||||
self.identity_api.create_role('fake1', role1)
|
self.identity_api.create_role('fake1', role1)
|
||||||
self.identity_api.create_role('fake2', role2)
|
self.identity_api.create_role('fake2', role2)
|
||||||
role1['name'] = 'fake2name'
|
role1['name'] = 'fake2name'
|
||||||
|
|
|
@ -26,8 +26,8 @@ import default_fixtures
|
||||||
import test_backend
|
import test_backend
|
||||||
|
|
||||||
DEFAULT_CATALOG_TEMPLATES = os.path.abspath(os.path.join(
|
DEFAULT_CATALOG_TEMPLATES = os.path.abspath(os.path.join(
|
||||||
os.path.dirname(__file__),
|
os.path.dirname(__file__),
|
||||||
'default_catalog.templates'))
|
'default_catalog.templates'))
|
||||||
|
|
||||||
|
|
||||||
class TestTemplatedCatalog(test.TestCase, test_backend.CatalogTests):
|
class TestTemplatedCatalog(test.TestCase, test_backend.CatalogTests):
|
||||||
|
|
|
@ -71,9 +71,9 @@ class RestfulTestCase(test.TestCase):
|
||||||
# TODO(termie): add an admin user to the fixtures and use that user
|
# TODO(termie): add an admin user to the fixtures and use that user
|
||||||
# override the fixtures, for now
|
# override the fixtures, for now
|
||||||
self.metadata_foobar = self.identity_api.update_metadata(
|
self.metadata_foobar = self.identity_api.update_metadata(
|
||||||
self.user_foo['id'],
|
self.user_foo['id'],
|
||||||
self.tenant_bar['id'],
|
self.tenant_bar['id'],
|
||||||
dict(roles=['keystone_admin'], is_admin='1'))
|
dict(roles=['keystone_admin'], is_admin='1'))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""Kill running servers and release references to avoid leaks."""
|
"""Kill running servers and release references to avoid leaks."""
|
||||||
|
@ -123,7 +123,8 @@ class RestfulTestCase(test.TestCase):
|
||||||
|
|
||||||
>>> self.assertResponseSuccessful(response, 203)
|
>>> self.assertResponseSuccessful(response, 203)
|
||||||
"""
|
"""
|
||||||
self.assertTrue(response.status >= 200 and response.status <= 299,
|
self.assertTrue(
|
||||||
|
response.status >= 200 and response.status <= 299,
|
||||||
'Status code %d is outside of the expected range (2xx)\n\n%s' %
|
'Status code %d is outside of the expected range (2xx)\n\n%s' %
|
||||||
(response.status, response.body))
|
(response.status, response.body))
|
||||||
|
|
||||||
|
@ -137,7 +138,9 @@ class RestfulTestCase(test.TestCase):
|
||||||
|
|
||||||
>>> self.assertResponseStatus(response, 203)
|
>>> self.assertResponseStatus(response, 203)
|
||||||
"""
|
"""
|
||||||
self.assertEqual(response.status, expected_status,
|
self.assertEqual(
|
||||||
|
response.status,
|
||||||
|
expected_status,
|
||||||
'Status code %s is not %s, as expected)\n\n%s' %
|
'Status code %s is not %s, as expected)\n\n%s' %
|
||||||
(response.status, expected_status, response.body))
|
(response.status, expected_status, response.body))
|
||||||
|
|
||||||
|
@ -225,7 +228,10 @@ class RestfulTestCase(test.TestCase):
|
||||||
|
|
||||||
def get_scoped_token(self):
|
def get_scoped_token(self):
|
||||||
"""Convenience method so that we can test authenticated requests."""
|
"""Convenience method so that we can test authenticated requests."""
|
||||||
r = self.public_request(method='POST', path='/v2.0/tokens', body={
|
r = self.public_request(
|
||||||
|
method='POST',
|
||||||
|
path='/v2.0/tokens',
|
||||||
|
body={
|
||||||
'auth': {
|
'auth': {
|
||||||
'passwordCredentials': {
|
'passwordCredentials': {
|
||||||
'username': self.user_foo['name'],
|
'username': self.user_foo['name'],
|
||||||
|
@ -341,7 +347,10 @@ class CoreApiTests(object):
|
||||||
self.assertValidExtensionResponse(r)
|
self.assertValidExtensionResponse(r)
|
||||||
|
|
||||||
def test_authenticate(self):
|
def test_authenticate(self):
|
||||||
r = self.public_request(method='POST', path='/v2.0/tokens', body={
|
r = self.public_request(
|
||||||
|
method='POST',
|
||||||
|
path='/v2.0/tokens',
|
||||||
|
body={
|
||||||
'auth': {
|
'auth': {
|
||||||
'passwordCredentials': {
|
'passwordCredentials': {
|
||||||
'username': self.user_foo['name'],
|
'username': self.user_foo['name'],
|
||||||
|
@ -356,12 +365,13 @@ class CoreApiTests(object):
|
||||||
|
|
||||||
def test_get_tenants_for_token(self):
|
def test_get_tenants_for_token(self):
|
||||||
r = self.public_request(path='/v2.0/tenants',
|
r = self.public_request(path='/v2.0/tenants',
|
||||||
token=self.get_scoped_token())
|
token=self.get_scoped_token())
|
||||||
self.assertValidTenantListResponse(r)
|
self.assertValidTenantListResponse(r)
|
||||||
|
|
||||||
def test_validate_token(self):
|
def test_validate_token(self):
|
||||||
token = self.get_scoped_token()
|
token = self.get_scoped_token()
|
||||||
r = self.admin_request(path='/v2.0/tokens/%(token_id)s' % {
|
r = self.admin_request(
|
||||||
|
path='/v2.0/tokens/%(token_id)s' % {
|
||||||
'token_id': token,
|
'token_id': token,
|
||||||
},
|
},
|
||||||
token=token)
|
token=token)
|
||||||
|
@ -390,7 +400,9 @@ class CoreApiTests(object):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
token = self.get_scoped_token()
|
token = self.get_scoped_token()
|
||||||
self.admin_request(method='HEAD', path='/v2.0/tokens/%(token_id)s' % {
|
self.admin_request(
|
||||||
|
method='HEAD',
|
||||||
|
path='/v2.0/tokens/%(token_id)s' % {
|
||||||
'token_id': token,
|
'token_id': token,
|
||||||
},
|
},
|
||||||
token=token,
|
token=token,
|
||||||
|
@ -400,7 +412,8 @@ class CoreApiTests(object):
|
||||||
raise nose.exc.SkipTest('Blocked by bug 933555')
|
raise nose.exc.SkipTest('Blocked by bug 933555')
|
||||||
|
|
||||||
token = self.get_scoped_token()
|
token = self.get_scoped_token()
|
||||||
r = self.admin_request(path='/v2.0/tokens/%(token_id)s/endpoints' % {
|
r = self.admin_request(
|
||||||
|
path='/v2.0/tokens/%(token_id)s/endpoints' % {
|
||||||
'token_id': token,
|
'token_id': token,
|
||||||
},
|
},
|
||||||
token=token)
|
token=token)
|
||||||
|
@ -408,7 +421,8 @@ class CoreApiTests(object):
|
||||||
|
|
||||||
def test_get_tenant(self):
|
def test_get_tenant(self):
|
||||||
token = self.get_scoped_token()
|
token = self.get_scoped_token()
|
||||||
r = self.admin_request(path='/v2.0/tenants/%(tenant_id)s' % {
|
r = self.admin_request(
|
||||||
|
path='/v2.0/tenants/%(tenant_id)s' % {
|
||||||
'tenant_id': self.tenant_bar['id'],
|
'tenant_id': self.tenant_bar['id'],
|
||||||
},
|
},
|
||||||
token=token)
|
token=token)
|
||||||
|
@ -418,7 +432,8 @@ class CoreApiTests(object):
|
||||||
raise nose.exc.SkipTest('Blocked by bug 933565')
|
raise nose.exc.SkipTest('Blocked by bug 933565')
|
||||||
|
|
||||||
token = self.get_scoped_token()
|
token = self.get_scoped_token()
|
||||||
r = self.admin_request(path='/v2.0/users/%(user_id)s/roles' % {
|
r = self.admin_request(
|
||||||
|
path='/v2.0/users/%(user_id)s/roles' % {
|
||||||
'user_id': self.user_foo['id'],
|
'user_id': self.user_foo['id'],
|
||||||
},
|
},
|
||||||
token=token)
|
token=token)
|
||||||
|
@ -436,7 +451,8 @@ class CoreApiTests(object):
|
||||||
|
|
||||||
def test_get_user(self):
|
def test_get_user(self):
|
||||||
token = self.get_scoped_token()
|
token = self.get_scoped_token()
|
||||||
r = self.admin_request(path='/v2.0/users/%(user_id)s' % {
|
r = self.admin_request(
|
||||||
|
path='/v2.0/users/%(user_id)s' % {
|
||||||
'user_id': self.user_foo['id'],
|
'user_id': self.user_foo['id'],
|
||||||
},
|
},
|
||||||
token=token)
|
token=token)
|
||||||
|
@ -567,11 +583,11 @@ class JsonTestCase(RestfulTestCase, CoreApiTests):
|
||||||
# values here don't matter because we should 401 before they're checked
|
# values here don't matter because we should 401 before they're checked
|
||||||
service_path = '/v2.0/OS-KSADM/services/%s' % uuid.uuid4().hex
|
service_path = '/v2.0/OS-KSADM/services/%s' % uuid.uuid4().hex
|
||||||
service_body = {
|
service_body = {
|
||||||
'OS-KSADM:service': {
|
'OS-KSADM:service': {
|
||||||
'name': uuid.uuid4().hex,
|
'name': uuid.uuid4().hex,
|
||||||
'type': uuid.uuid4().hex,
|
'type': uuid.uuid4().hex,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
r = self.admin_request(method='GET',
|
r = self.admin_request(method='GET',
|
||||||
path='/v2.0/OS-KSADM/services',
|
path='/v2.0/OS-KSADM/services',
|
||||||
|
@ -598,8 +614,8 @@ class JsonTestCase(RestfulTestCase, CoreApiTests):
|
||||||
"""User role list should 401 without an X-Auth-Token (bug 1006815)."""
|
"""User role list should 401 without an X-Auth-Token (bug 1006815)."""
|
||||||
# values here don't matter because we should 401 before they're checked
|
# values here don't matter because we should 401 before they're checked
|
||||||
path = '/v2.0/tenants/%(tenant_id)s/users/%(user_id)s/roles' % {
|
path = '/v2.0/tenants/%(tenant_id)s/users/%(user_id)s/roles' % {
|
||||||
'tenant_id': uuid.uuid4().hex,
|
'tenant_id': uuid.uuid4().hex,
|
||||||
'user_id': uuid.uuid4().hex,
|
'user_id': uuid.uuid4().hex,
|
||||||
}
|
}
|
||||||
|
|
||||||
r = self.admin_request(path=path, expected_status=401)
|
r = self.admin_request(path=path, expected_status=401)
|
||||||
|
|
|
@ -235,7 +235,7 @@ class KeystoneClientTests(object):
|
||||||
self.assertRaises(client_exceptions.NotFound, client.tenants.get,
|
self.assertRaises(client_exceptions.NotFound, client.tenants.get,
|
||||||
tenant.id)
|
tenant.id)
|
||||||
self.assertFalse([t for t in client.tenants.list()
|
self.assertFalse([t for t in client.tenants.list()
|
||||||
if t.id == tenant.id])
|
if t.id == tenant.id])
|
||||||
|
|
||||||
def test_tenant_create_no_name(self):
|
def test_tenant_create_no_name(self):
|
||||||
from keystoneclient import exceptions as client_exceptions
|
from keystoneclient import exceptions as client_exceptions
|
||||||
|
@ -341,7 +341,7 @@ class KeystoneClientTests(object):
|
||||||
|
|
||||||
time.sleep(1.01)
|
time.sleep(1.01)
|
||||||
reauthenticated_token = foo_client.tokens.authenticate(
|
reauthenticated_token = foo_client.tokens.authenticate(
|
||||||
token=foo_client.auth_token)
|
token=foo_client.auth_token)
|
||||||
|
|
||||||
self.assertEquals(orig_token['expires'],
|
self.assertEquals(orig_token['expires'],
|
||||||
reauthenticated_token.expires)
|
reauthenticated_token.expires)
|
||||||
|
@ -370,9 +370,9 @@ class KeystoneClientTests(object):
|
||||||
self.assertFalse(user.enabled)
|
self.assertFalse(user.enabled)
|
||||||
|
|
||||||
self.assertRaises(client_exceptions.Unauthorized,
|
self.assertRaises(client_exceptions.Unauthorized,
|
||||||
self._client,
|
self._client,
|
||||||
username=test_username,
|
username=test_username,
|
||||||
password='password')
|
password='password')
|
||||||
client.users.update_enabled(user, True)
|
client.users.update_enabled(user, True)
|
||||||
|
|
||||||
user = client.users.update_password(user=user, password='password2')
|
user = client.users.update_password(user=user, password='password2')
|
||||||
|
@ -868,16 +868,16 @@ class KcEssex3TestCase(CompatTestCase, KeystoneClientTests):
|
||||||
user_id=self.user_foo['id'],
|
user_id=self.user_foo['id'],
|
||||||
role_id=self.role_useless['id'])
|
role_id=self.role_useless['id'])
|
||||||
role_refs = client.roles.get_user_role_refs(
|
role_refs = client.roles.get_user_role_refs(
|
||||||
user_id=self.user_foo['id'])
|
user_id=self.user_foo['id'])
|
||||||
self.assert_(self.tenant_baz['id'] in [x.tenantId for x in role_refs])
|
self.assert_(self.tenant_baz['id'] in [x.tenantId for x in role_refs])
|
||||||
|
|
||||||
# get the "role_refs" so we get the proper id, this is how the clients
|
# get the "role_refs" so we get the proper id, this is how the clients
|
||||||
# do it
|
# do it
|
||||||
roleref_refs = client.roles.get_user_role_refs(
|
roleref_refs = client.roles.get_user_role_refs(
|
||||||
user_id=self.user_foo['id'])
|
user_id=self.user_foo['id'])
|
||||||
for roleref_ref in roleref_refs:
|
for roleref_ref in roleref_refs:
|
||||||
if (roleref_ref.roleId == self.role_useless['id']
|
if (roleref_ref.roleId == self.role_useless['id']
|
||||||
and roleref_ref.tenantId == self.tenant_baz['id']):
|
and roleref_ref.tenantId == self.tenant_baz['id']):
|
||||||
# use python's scope fall through to leave roleref_ref set
|
# use python's scope fall through to leave roleref_ref set
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -886,7 +886,7 @@ class KcEssex3TestCase(CompatTestCase, KeystoneClientTests):
|
||||||
role_id=roleref_ref.id)
|
role_id=roleref_ref.id)
|
||||||
|
|
||||||
role_refs = client.roles.get_user_role_refs(
|
role_refs = client.roles.get_user_role_refs(
|
||||||
user_id=self.user_foo['id'])
|
user_id=self.user_foo['id'])
|
||||||
self.assert_(self.tenant_baz['id'] not in
|
self.assert_(self.tenant_baz['id'] not in
|
||||||
[x.tenantId for x in role_refs])
|
[x.tenantId for x in role_refs])
|
||||||
|
|
||||||
|
@ -923,9 +923,9 @@ class KcEssex3TestCase(CompatTestCase, KeystoneClientTests):
|
||||||
self.assertFalse(user.enabled)
|
self.assertFalse(user.enabled)
|
||||||
|
|
||||||
self.assertRaises(client_exceptions.Unauthorized,
|
self.assertRaises(client_exceptions.Unauthorized,
|
||||||
self._client,
|
self._client,
|
||||||
username=test_username,
|
username=test_username,
|
||||||
password='password')
|
password='password')
|
||||||
client.users.update_enabled(user, True)
|
client.users.update_enabled(user, True)
|
||||||
|
|
||||||
user = client.users.update_password(user=user, password='password2')
|
user = client.users.update_password(user=user, password='password2')
|
||||||
|
|
|
@ -29,9 +29,9 @@ CONF = config.CONF
|
||||||
class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
|
class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
|
||||||
def config(self, config_files):
|
def config(self, config_files):
|
||||||
super(KcMasterSqlTestCase, self).config([
|
super(KcMasterSqlTestCase, self).config([
|
||||||
test.etcdir('keystone.conf.sample'),
|
test.etcdir('keystone.conf.sample'),
|
||||||
test.testsdir('test_overrides.conf'),
|
test.testsdir('test_overrides.conf'),
|
||||||
test.testsdir('backend_sql.conf')])
|
test.testsdir('backend_sql.conf')])
|
||||||
sql_util.setup_test_database()
|
sql_util.setup_test_database()
|
||||||
|
|
||||||
def test_endpoint_crud(self):
|
def test_endpoint_crud(self):
|
||||||
|
|
|
@ -145,9 +145,9 @@ class XmlBodyMiddlewareTest(test.TestCase):
|
||||||
def test_xml_replaced_by_json(self):
|
def test_xml_replaced_by_json(self):
|
||||||
"""XML requests should be replaced by JSON requests."""
|
"""XML requests should be replaced by JSON requests."""
|
||||||
req = make_request(
|
req = make_request(
|
||||||
body='<container><element attribute="value" /></container>',
|
body='<container><element attribute="value" /></container>',
|
||||||
content_type='application/xml',
|
content_type='application/xml',
|
||||||
method='POST')
|
method='POST')
|
||||||
middleware.XmlBodyMiddleware(None).process_request(req)
|
middleware.XmlBodyMiddleware(None).process_request(req)
|
||||||
self.assertTrue(req.content_type, 'application/json')
|
self.assertTrue(req.content_type, 'application/json')
|
||||||
self.assertTrue(jsonutils.loads(req.body))
|
self.assertTrue(jsonutils.loads(req.body))
|
||||||
|
|
|
@ -138,7 +138,7 @@ class MigrateNovaAuth(test.TestCase):
|
||||||
user = users[old_user]
|
user = users[old_user]
|
||||||
tenant = tenants[tenant_name]
|
tenant = tenants[tenant_name]
|
||||||
roles = self.identity_api.get_roles_for_user_and_tenant(
|
roles = self.identity_api.get_roles_for_user_and_tenant(
|
||||||
user['id'], tenant['id'])
|
user['id'], tenant['id'])
|
||||||
actual = [self.identity_api.get_role(role_id)['name']
|
actual = [self.identity_api.get_role(role_id)['name']
|
||||||
for role_id in roles]
|
for role_id in roles]
|
||||||
expected = old_tenant_map.get(tenant_name, [])
|
expected = old_tenant_map.get(tenant_name, [])
|
||||||
|
|
|
@ -28,11 +28,9 @@ from keystone.openstack.common import jsonutils
|
||||||
|
|
||||||
def denied_request(code):
|
def denied_request(code):
|
||||||
error_table = {
|
error_table = {
|
||||||
'AccessDenied':
|
'AccessDenied': (401, 'Access denied'),
|
||||||
(401, 'Access denied'),
|
'InvalidURI': (400, 'Could not parse the specified URI'),
|
||||||
'InvalidURI':
|
}
|
||||||
(400, 'Could not parse the specified URI'),
|
|
||||||
}
|
|
||||||
xml = '<?xml version="1.0" encoding="UTF-8"?>\r\n<Error>\r\n ' \
|
xml = '<?xml version="1.0" encoding="UTF-8"?>\r\n<Error>\r\n ' \
|
||||||
'<Code>%s</Code>\r\n <Message>%s</Message>\r\n</Error>\r\n' \
|
'<Code>%s</Code>\r\n <Message>%s</Message>\r\n</Error>\r\n' \
|
||||||
% (code, error_table[code][1])
|
% (code, error_table[code][1])
|
||||||
|
|
|
@ -40,11 +40,11 @@ class XmlSerializerTestCase(test.TestCase):
|
||||||
|
|
||||||
# operations should be invertable
|
# operations should be invertable
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
serializer.from_xml(serializer.to_xml(d, xmlns)),
|
serializer.from_xml(serializer.to_xml(d, xmlns)),
|
||||||
d)
|
d)
|
||||||
self.assertEqualIgnoreWhitespace(
|
self.assertEqualIgnoreWhitespace(
|
||||||
serializer.to_xml(serializer.from_xml(xml), xmlns),
|
serializer.to_xml(serializer.from_xml(xml), xmlns),
|
||||||
xml)
|
xml)
|
||||||
|
|
||||||
def test_none(self):
|
def test_none(self):
|
||||||
d = None
|
d = None
|
||||||
|
|
|
@ -37,19 +37,19 @@ class SetupTest(unittest.TestCase):
|
||||||
with open(self.mailmap, 'w') as mm_fh:
|
with open(self.mailmap, 'w') as mm_fh:
|
||||||
mm_fh.write("Foo Bar <email@foo.com> Foo Bar <email@bar.com>\n")
|
mm_fh.write("Foo Bar <email@foo.com> Foo Bar <email@bar.com>\n")
|
||||||
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
||||||
parse_mailmap(self.mailmap))
|
parse_mailmap(self.mailmap))
|
||||||
|
|
||||||
def test_mailmap_with_firstname(self):
|
def test_mailmap_with_firstname(self):
|
||||||
with open(self.mailmap, 'w') as mm_fh:
|
with open(self.mailmap, 'w') as mm_fh:
|
||||||
mm_fh.write("Foo <email@foo.com> Foo <email@bar.com>\n")
|
mm_fh.write("Foo <email@foo.com> Foo <email@bar.com>\n")
|
||||||
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
||||||
parse_mailmap(self.mailmap))
|
parse_mailmap(self.mailmap))
|
||||||
|
|
||||||
def test_mailmap_with_noname(self):
|
def test_mailmap_with_noname(self):
|
||||||
with open(self.mailmap, 'w') as mm_fh:
|
with open(self.mailmap, 'w') as mm_fh:
|
||||||
mm_fh.write("<email@foo.com> <email@bar.com>\n")
|
mm_fh.write("<email@foo.com> <email@bar.com>\n")
|
||||||
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
||||||
parse_mailmap(self.mailmap))
|
parse_mailmap(self.mailmap))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
if os.path.exists(self.mailmap):
|
if os.path.exists(self.mailmap):
|
||||||
|
|
|
@ -43,9 +43,9 @@ class SSLTestCase(test.TestCase):
|
||||||
Make sure both public and admin API work with 1-way SSL.
|
Make sure both public and admin API work with 1-way SSL.
|
||||||
"""
|
"""
|
||||||
self.public_server = self.serveapp('keystone', name='main',
|
self.public_server = self.serveapp('keystone', name='main',
|
||||||
cert=CERT, key=KEY, ca=CA)
|
cert=CERT, key=KEY, ca=CA)
|
||||||
self.admin_server = self.serveapp('keystone', name='admin',
|
self.admin_server = self.serveapp('keystone', name='admin',
|
||||||
cert=CERT, key=KEY, ca=CA)
|
cert=CERT, key=KEY, ca=CA)
|
||||||
# Verify Admin
|
# Verify Admin
|
||||||
conn = httplib.HTTPSConnection('127.0.0.1', CONF.admin_port)
|
conn = httplib.HTTPSConnection('127.0.0.1', CONF.admin_port)
|
||||||
conn.request('GET', '/')
|
conn.request('GET', '/')
|
||||||
|
@ -62,10 +62,12 @@ class SSLTestCase(test.TestCase):
|
||||||
Make sure both public and admin API work with 2-way SSL. Requires
|
Make sure both public and admin API work with 2-way SSL. Requires
|
||||||
client certificate.
|
client certificate.
|
||||||
"""
|
"""
|
||||||
self.public_server = self.serveapp('keystone', name='main',
|
self.public_server = self.serveapp(
|
||||||
cert=CERT, key=KEY, ca=CA, cert_required=True)
|
'keystone', name='main', cert=CERT,
|
||||||
self.admin_server = self.serveapp('keystone', name='admin',
|
key=KEY, ca=CA, cert_required=True)
|
||||||
cert=CERT, key=KEY, ca=CA, cert_required=True)
|
self.admin_server = self.serveapp(
|
||||||
|
'keystone', name='admin', cert=CERT,
|
||||||
|
key=KEY, ca=CA, cert_required=True)
|
||||||
# Verify Admin
|
# Verify Admin
|
||||||
conn = httplib.HTTPSConnection(
|
conn = httplib.HTTPSConnection(
|
||||||
'127.0.0.1', CONF.admin_port, CLIENT, CLIENT)
|
'127.0.0.1', CONF.admin_port, CLIENT, CLIENT)
|
||||||
|
@ -83,10 +85,12 @@ class SSLTestCase(test.TestCase):
|
||||||
"""
|
"""
|
||||||
Expect to fail when client does not present proper certificate.
|
Expect to fail when client does not present proper certificate.
|
||||||
"""
|
"""
|
||||||
self.public_server = self.serveapp('keystone', name='main',
|
self.public_server = self.serveapp(
|
||||||
cert=CERT, key=KEY, ca=CA, cert_required=True)
|
'keystone', name='main', cert=CERT,
|
||||||
self.admin_server = self.serveapp('keystone', name='admin',
|
key=KEY, ca=CA, cert_required=True)
|
||||||
cert=CERT, key=KEY, ca=CA, cert_required=True)
|
self.admin_server = self.serveapp(
|
||||||
|
'keystone', name='admin', cert=CERT,
|
||||||
|
key=KEY, ca=CA, cert_required=True)
|
||||||
# Verify Admin
|
# Verify Admin
|
||||||
conn = httplib.HTTPSConnection('127.0.0.1', CONF.admin_port)
|
conn = httplib.HTTPSConnection('127.0.0.1', CONF.admin_port)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -67,7 +67,7 @@ class SwiftAuth(unittest.TestCase):
|
||||||
return webob.Request.blank(path, headers=headers, **kwargs)
|
return webob.Request.blank(path, headers=headers, **kwargs)
|
||||||
|
|
||||||
def _get_identity_headers(self, status='Confirmed', tenant_id='1',
|
def _get_identity_headers(self, status='Confirmed', tenant_id='1',
|
||||||
tenant_name='acct', user='usr', role=''):
|
tenant_name='acct', user='usr', role=''):
|
||||||
return dict(X_IDENTITY_STATUS=status,
|
return dict(X_IDENTITY_STATUS=status,
|
||||||
X_TENANT_ID=tenant_id,
|
X_TENANT_ID=tenant_id,
|
||||||
X_TENANT_NAME=tenant_name,
|
X_TENANT_NAME=tenant_name,
|
||||||
|
|
Loading…
Reference in New Issue