Merge "Enable foreign keys for unit test"
This commit is contained in:
commit
8e33c78232
keystone
resource
tests/unit
base_classes.pycore.py
federation
identity
ksfixtures
resource
rest.pytest_backend_endpoint_policy_sql.pytest_backend_ldap.pytest_backend_sql.pytest_cli.pytest_shadow_users.pytest_v3.pytest_v3_assignment.pytest_v3_auth.pytest_v3_catalog.pytest_v3_federation.pytest_v3_filters.pytest_v3_protection.pytest_v3_resource.pytoken
releasenotes/notes
@ -102,7 +102,8 @@ class Manager(manager.Manager):
|
|||||||
was not satisfied.
|
was not satisfied.
|
||||||
"""
|
"""
|
||||||
if (not PROVIDERS.identity_api.multiple_domains_supported and
|
if (not PROVIDERS.identity_api.multiple_domains_supported and
|
||||||
project_ref['id'] != CONF.identity.default_domain_id):
|
project_ref['id'] != CONF.identity.default_domain_id and
|
||||||
|
project_ref['id'] != base.NULL_DOMAIN_ID):
|
||||||
raise exception.ValidationError(
|
raise exception.ValidationError(
|
||||||
message=_('Multiple domains are not supported'))
|
message=_('Multiple domains are not supported'))
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@ from oslo_config import fixture as config_fixture
|
|||||||
from keystone.cmd import bootstrap
|
from keystone.cmd import bootstrap
|
||||||
from keystone.common import provider_api
|
from keystone.common import provider_api
|
||||||
import keystone.conf
|
import keystone.conf
|
||||||
|
from keystone import exception
|
||||||
from keystone.tests.unit import core
|
from keystone.tests.unit import core
|
||||||
|
from keystone.tests.unit import default_fixtures
|
||||||
from keystone.tests.unit import ksfixtures
|
from keystone.tests.unit import ksfixtures
|
||||||
from keystone.tests.unit.ksfixtures import database
|
from keystone.tests.unit.ksfixtures import database
|
||||||
|
|
||||||
@ -56,6 +58,14 @@ class TestCaseWithBootstrap(core.BaseTestCase):
|
|||||||
self.bootstrapper.admin_role_name = 'admin'
|
self.bootstrapper.admin_role_name = 'admin'
|
||||||
self.bootstrapper.service_name = 'keystone'
|
self.bootstrapper.service_name = 'keystone'
|
||||||
self.bootstrapper.public_url = 'http://localhost/identity/'
|
self.bootstrapper.public_url = 'http://localhost/identity/'
|
||||||
|
|
||||||
|
try:
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'],
|
||||||
|
default_fixtures.ROOT_DOMAIN)
|
||||||
|
except exception.Conflict:
|
||||||
|
pass
|
||||||
|
|
||||||
self.bootstrapper.bootstrap()
|
self.bootstrapper.bootstrap()
|
||||||
|
|
||||||
def clean_default_domain(self):
|
def clean_default_domain(self):
|
||||||
|
@ -821,7 +821,7 @@ class TestCase(BaseTestCase):
|
|||||||
provider_api.ProviderAPIs._clear_registry_instances()
|
provider_api.ProviderAPIs._clear_registry_instances()
|
||||||
self.useFixture(ksfixtures.BackendLoader(self))
|
self.useFixture(ksfixtures.BackendLoader(self))
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
"""Hacky basic and naive fixture loading based on a python module.
|
"""Hacky basic and naive fixture loading based on a python module.
|
||||||
|
|
||||||
Expects that the various APIs into the various services are already
|
Expects that the various APIs into the various services are already
|
||||||
@ -837,12 +837,12 @@ class TestCase(BaseTestCase):
|
|||||||
if (hasattr(self, 'identity_api') and
|
if (hasattr(self, 'identity_api') and
|
||||||
hasattr(self, 'assignment_api') and
|
hasattr(self, 'assignment_api') and
|
||||||
hasattr(self, 'resource_api')):
|
hasattr(self, 'resource_api')):
|
||||||
# TODO(wxy): Once all test enable FKs, remove
|
try:
|
||||||
# ``enable_sqlite_foreign_key`` and create the root domain by
|
PROVIDERS.resource_api.create_domain(
|
||||||
# default.
|
resource_base.NULL_DOMAIN_ID, fixtures.ROOT_DOMAIN)
|
||||||
if enable_sqlite_foreign_key:
|
except exception.Conflict:
|
||||||
self.resource_api.create_domain(resource_base.NULL_DOMAIN_ID,
|
# the root domain already exists, skip now.
|
||||||
fixtures.ROOT_DOMAIN)
|
pass
|
||||||
for domain in fixtures.DOMAINS:
|
for domain in fixtures.DOMAINS:
|
||||||
rv = PROVIDERS.resource_api.create_domain(domain['id'], domain)
|
rv = PROVIDERS.resource_api.create_domain(domain['id'], domain)
|
||||||
attrname = 'domain_%s' % domain['id']
|
attrname = 'domain_%s' % domain['id']
|
||||||
|
@ -15,6 +15,7 @@ import uuid
|
|||||||
from keystone.common import provider_api
|
from keystone.common import provider_api
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
from keystone.tests import unit
|
from keystone.tests import unit
|
||||||
|
from keystone.tests.unit import default_fixtures
|
||||||
from keystone.tests.unit.ksfixtures import database
|
from keystone.tests.unit.ksfixtures import database
|
||||||
from keystone.tests.unit import mapping_fixtures
|
from keystone.tests.unit import mapping_fixtures
|
||||||
|
|
||||||
@ -27,6 +28,8 @@ class TestFederationProtocol(unit.TestCase):
|
|||||||
super(TestFederationProtocol, self).setUp()
|
super(TestFederationProtocol, self).setUp()
|
||||||
self.useFixture(database.Database())
|
self.useFixture(database.Database())
|
||||||
self.load_backends()
|
self.load_backends()
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
self.idp = {
|
self.idp = {
|
||||||
'id': uuid.uuid4().hex,
|
'id': uuid.uuid4().hex,
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
|
@ -24,6 +24,7 @@ import keystone.conf
|
|||||||
from keystone import exception
|
from keystone import exception
|
||||||
from keystone import identity
|
from keystone import identity
|
||||||
from keystone.tests import unit
|
from keystone.tests import unit
|
||||||
|
from keystone.tests.unit import default_fixtures
|
||||||
from keystone.tests.unit.ksfixtures import database
|
from keystone.tests.unit.ksfixtures import database
|
||||||
|
|
||||||
|
|
||||||
@ -133,6 +134,8 @@ class TestDatabaseDomainConfigs(unit.TestCase):
|
|||||||
super(TestDatabaseDomainConfigs, self).setUp()
|
super(TestDatabaseDomainConfigs, self).setUp()
|
||||||
self.useFixture(database.Database())
|
self.useFixture(database.Database())
|
||||||
self.load_backends()
|
self.load_backends()
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
|
|
||||||
def test_domain_config_in_database_disabled_by_default(self):
|
def test_domain_config_in_database_disabled_by_default(self):
|
||||||
self.assertFalse(CONF.identity.domain_configurations_from_database)
|
self.assertFalse(CONF.identity.domain_configurations_from_database)
|
||||||
|
@ -103,11 +103,10 @@ def _load_sqlalchemy_models():
|
|||||||
class Database(fixtures.Fixture):
|
class Database(fixtures.Fixture):
|
||||||
"""A fixture for setting up and tearing down a database."""
|
"""A fixture for setting up and tearing down a database."""
|
||||||
|
|
||||||
def __init__(self, enable_sqlite_foreign_key=False):
|
def __init__(self):
|
||||||
super(Database, self).__init__()
|
super(Database, self).__init__()
|
||||||
initialize_sql_session()
|
initialize_sql_session()
|
||||||
_load_sqlalchemy_models()
|
_load_sqlalchemy_models()
|
||||||
if enable_sqlite_foreign_key:
|
|
||||||
sql.enable_sqlite_foreign_key()
|
sql.enable_sqlite_foreign_key()
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
from keystone.resource.backends import sql
|
from keystone.resource.backends import sql
|
||||||
from keystone.tests import unit
|
from keystone.tests import unit
|
||||||
|
from keystone.tests.unit import default_fixtures
|
||||||
from keystone.tests.unit.ksfixtures import database
|
from keystone.tests.unit.ksfixtures import database
|
||||||
from keystone.tests.unit.resource import test_backends
|
from keystone.tests.unit.resource import test_backends
|
||||||
|
|
||||||
@ -22,3 +23,8 @@ class TestSqlResourceDriver(unit.BaseTestCase,
|
|||||||
super(TestSqlResourceDriver, self).setUp()
|
super(TestSqlResourceDriver, self).setUp()
|
||||||
self.useFixture(database.Database())
|
self.useFixture(database.Database())
|
||||||
self.driver = sql.Resource()
|
self.driver = sql.Resource()
|
||||||
|
root_domain = default_fixtures.ROOT_DOMAIN
|
||||||
|
root_domain['domain_id'] = root_domain['id']
|
||||||
|
root_domain['is_domain'] = True
|
||||||
|
self.driver.create_project(root_domain['id'],
|
||||||
|
root_domain)
|
||||||
|
@ -1731,7 +1731,7 @@ class ResourceDriverTests(object):
|
|||||||
project = {
|
project = {
|
||||||
'name': uuid.uuid4().hex,
|
'name': uuid.uuid4().hex,
|
||||||
'id': project_id,
|
'id': project_id,
|
||||||
'domain_id': uuid.uuid4().hex,
|
'domain_id': default_fixtures.ROOT_DOMAIN['id'],
|
||||||
}
|
}
|
||||||
self.driver.create_project(project_id, project)
|
self.driver.create_project(project_id, project)
|
||||||
|
|
||||||
@ -1740,10 +1740,18 @@ class ResourceDriverTests(object):
|
|||||||
project = {
|
project = {
|
||||||
'name': uuid.uuid4().hex,
|
'name': uuid.uuid4().hex,
|
||||||
'id': project_id,
|
'id': project_id,
|
||||||
'domain_id': uuid.uuid4().hex,
|
'domain_id': default_fixtures.ROOT_DOMAIN['id'],
|
||||||
|
}
|
||||||
|
parent_project = self.driver.create_project(project_id, project)
|
||||||
|
|
||||||
|
project_id = uuid.uuid4().hex
|
||||||
|
project = {
|
||||||
|
'name': uuid.uuid4().hex,
|
||||||
|
'id': project_id,
|
||||||
|
'domain_id': default_fixtures.ROOT_DOMAIN['id'],
|
||||||
'description': uuid.uuid4().hex,
|
'description': uuid.uuid4().hex,
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
'parent_id': uuid.uuid4().hex,
|
'parent_id': parent_project['id'],
|
||||||
'is_domain': True,
|
'is_domain': True,
|
||||||
}
|
}
|
||||||
self.driver.create_project(project_id, project)
|
self.driver.create_project(project_id, project)
|
||||||
@ -1759,7 +1767,7 @@ class ResourceDriverTests(object):
|
|||||||
|
|
||||||
def test_create_project_same_name_same_domain_conflict(self):
|
def test_create_project_same_name_same_domain_conflict(self):
|
||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
domain_id = uuid.uuid4().hex
|
domain_id = default_fixtures.ROOT_DOMAIN['id']
|
||||||
|
|
||||||
project_id = uuid.uuid4().hex
|
project_id = uuid.uuid4().hex
|
||||||
project = {
|
project = {
|
||||||
@ -1784,14 +1792,14 @@ class ResourceDriverTests(object):
|
|||||||
project = {
|
project = {
|
||||||
'name': uuid.uuid4().hex,
|
'name': uuid.uuid4().hex,
|
||||||
'id': project_id,
|
'id': project_id,
|
||||||
'domain_id': uuid.uuid4().hex,
|
'domain_id': default_fixtures.ROOT_DOMAIN['id'],
|
||||||
}
|
}
|
||||||
self.driver.create_project(project_id, project)
|
self.driver.create_project(project_id, project)
|
||||||
|
|
||||||
project = {
|
project = {
|
||||||
'name': uuid.uuid4().hex,
|
'name': uuid.uuid4().hex,
|
||||||
'id': project_id,
|
'id': project_id,
|
||||||
'domain_id': uuid.uuid4().hex,
|
'domain_id': default_fixtures.ROOT_DOMAIN['id'],
|
||||||
}
|
}
|
||||||
self.assertRaises(exception.Conflict, self.driver.create_project,
|
self.assertRaises(exception.Conflict, self.driver.create_project,
|
||||||
project_id, project)
|
project_id, project)
|
||||||
|
@ -21,6 +21,7 @@ from keystone.common import provider_api
|
|||||||
import keystone.conf
|
import keystone.conf
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
from keystone.tests import unit
|
from keystone.tests import unit
|
||||||
|
from keystone.tests.unit import default_fixtures
|
||||||
from keystone.tests.unit.ksfixtures import database
|
from keystone.tests.unit.ksfixtures import database
|
||||||
|
|
||||||
|
|
||||||
@ -34,6 +35,8 @@ class TestResourceManagerNoFixtures(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
super(TestResourceManagerNoFixtures, self).setUp()
|
super(TestResourceManagerNoFixtures, self).setUp()
|
||||||
self.useFixture(database.Database())
|
self.useFixture(database.Database())
|
||||||
self.load_backends()
|
self.load_backends()
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
|
|
||||||
def test_update_project_name_conflict(self):
|
def test_update_project_name_conflict(self):
|
||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
|
@ -52,16 +52,14 @@ class RestfulTestCase(unit.TestCase):
|
|||||||
# default content type to test
|
# default content type to test
|
||||||
content_type = 'json'
|
content_type = 'json'
|
||||||
|
|
||||||
def setUp(self, enable_sqlite_foreign_key=False):
|
def setUp(self):
|
||||||
super(RestfulTestCase, self).setUp()
|
super(RestfulTestCase, self).setUp()
|
||||||
|
|
||||||
self.auth_plugin_config_override()
|
self.auth_plugin_config_override()
|
||||||
|
|
||||||
self.useFixture(database.Database(
|
self.useFixture(database.Database())
|
||||||
enable_sqlite_foreign_key=enable_sqlite_foreign_key))
|
|
||||||
self.load_backends()
|
self.load_backends()
|
||||||
self.load_fixtures(default_fixtures,
|
self.load_fixtures(default_fixtures)
|
||||||
enable_sqlite_foreign_key=enable_sqlite_foreign_key)
|
|
||||||
|
|
||||||
self.public_app = webtest.TestApp(
|
self.public_app = webtest.TestApp(
|
||||||
self.loadapp(name='public'))
|
self.loadapp(name='public'))
|
||||||
|
@ -33,7 +33,6 @@ class SqlPolicyAssociationTests(
|
|||||||
test_backend_sql.SqlTests,
|
test_backend_sql.SqlTests,
|
||||||
test_backend_endpoint_policy.PolicyAssociationTests):
|
test_backend_endpoint_policy.PolicyAssociationTests):
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
super(SqlPolicyAssociationTests, self).load_fixtures(
|
super(SqlPolicyAssociationTests, self).load_fixtures(fixtures)
|
||||||
fixtures, enable_sqlite_foreign_key=enable_sqlite_foreign_key)
|
|
||||||
self.load_sample_data()
|
self.load_sample_data()
|
||||||
|
@ -1941,7 +1941,7 @@ class LDAPIdentityEnabledEmulation(LDAPIdentity, unit.TestCase):
|
|||||||
super(LDAPIdentityEnabledEmulation, self).setUp()
|
super(LDAPIdentityEnabledEmulation, self).setUp()
|
||||||
_assert_backends(self, identity='ldap')
|
_assert_backends(self, identity='ldap')
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
# Override super impl since need to create group container.
|
# Override super impl since need to create group container.
|
||||||
super(LDAPIdentity, self).load_fixtures(fixtures)
|
super(LDAPIdentity, self).load_fixtures(fixtures)
|
||||||
for obj in [self.tenant_bar, self.tenant_baz, self.user_foo,
|
for obj in [self.tenant_bar, self.tenant_baz, self.user_foo,
|
||||||
@ -2360,9 +2360,11 @@ class MultiLDAPandSQLIdentity(BaseLDAPIdentity, unit.SQLDriverOverrides,
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
self.domain_count = 5
|
self.domain_count = 5
|
||||||
self.domain_specific_count = 3
|
self.domain_specific_count = 3
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
self.setup_initial_domains()
|
self.setup_initial_domains()
|
||||||
|
|
||||||
# All initial test data setup complete, time to switch on support
|
# All initial test data setup complete, time to switch on support
|
||||||
@ -2934,7 +2936,9 @@ class DomainSpecificLDAPandSQLIdentity(
|
|||||||
|
|
||||||
super(DomainSpecificLDAPandSQLIdentity, self).setUp()
|
super(DomainSpecificLDAPandSQLIdentity, self).setUp()
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
self.setup_initial_domains()
|
self.setup_initial_domains()
|
||||||
super(DomainSpecificLDAPandSQLIdentity, self).load_fixtures(fixtures)
|
super(DomainSpecificLDAPandSQLIdentity, self).load_fixtures(fixtures)
|
||||||
|
|
||||||
|
@ -52,11 +52,11 @@ class SqlTests(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(SqlTests, self).setUp()
|
super(SqlTests, self).setUp()
|
||||||
self.useFixture(database.Database(enable_sqlite_foreign_key=True))
|
self.useFixture(database.Database())
|
||||||
self.load_backends()
|
self.load_backends()
|
||||||
|
|
||||||
# populate the engine with tables & fixtures
|
# populate the engine with tables & fixtures
|
||||||
self.load_fixtures(default_fixtures, enable_sqlite_foreign_key=True)
|
self.load_fixtures(default_fixtures)
|
||||||
# defaulted by the data load
|
# defaulted by the data load
|
||||||
self.user_foo['enabled'] = True
|
self.user_foo['enabled'] = True
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ class CliBootStrapTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.useFixture(database.Database())
|
self.useFixture(database.Database())
|
||||||
super(CliBootStrapTestCase, self).setUp()
|
super(CliBootStrapTestCase, self).setUp()
|
||||||
|
self.bootstrap = cli.BootStrap()
|
||||||
|
|
||||||
def config_files(self):
|
def config_files(self):
|
||||||
self.config_fixture.register_cli_opt(cli.command_opt)
|
self.config_fixture.register_cli_opt(cli.command_opt)
|
||||||
@ -112,10 +113,16 @@ class CliBootStrapTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
default_config_files=config_files)
|
default_config_files=config_files)
|
||||||
|
|
||||||
def test_bootstrap(self):
|
def test_bootstrap(self):
|
||||||
bootstrap = cli.BootStrap()
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
self._do_test_bootstrap(bootstrap)
|
|
||||||
|
|
||||||
def _do_test_bootstrap(self, bootstrap):
|
def _do_test_bootstrap(self, bootstrap):
|
||||||
|
try:
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'],
|
||||||
|
default_fixtures.ROOT_DOMAIN)
|
||||||
|
except exception.Conflict:
|
||||||
|
pass
|
||||||
|
|
||||||
bootstrap.do_bootstrap()
|
bootstrap.do_bootstrap()
|
||||||
project = PROVIDERS.resource_api.get_project_by_name(
|
project = PROVIDERS.resource_api.get_project_by_name(
|
||||||
bootstrap.project_name,
|
bootstrap.project_name,
|
||||||
@ -175,8 +182,7 @@ class CliBootStrapTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
def test_bootstrap_is_idempotent_when_password_does_not_change(self):
|
def test_bootstrap_is_idempotent_when_password_does_not_change(self):
|
||||||
# NOTE(morganfainberg): Ensure we can run bootstrap with the same
|
# NOTE(morganfainberg): Ensure we can run bootstrap with the same
|
||||||
# configuration multiple times without erroring.
|
# configuration multiple times without erroring.
|
||||||
bootstrap = cli.BootStrap()
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
self._do_test_bootstrap(bootstrap)
|
|
||||||
app = self.loadapp()
|
app = self.loadapp()
|
||||||
v3_password_data = {
|
v3_password_data = {
|
||||||
'auth': {
|
'auth': {
|
||||||
@ -184,8 +190,8 @@ class CliBootStrapTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
"methods": ["password"],
|
"methods": ["password"],
|
||||||
"password": {
|
"password": {
|
||||||
"user": {
|
"user": {
|
||||||
"name": bootstrap.username,
|
"name": self.bootstrap.username,
|
||||||
"password": bootstrap.password,
|
"password": self.bootstrap.password,
|
||||||
"domain": {
|
"domain": {
|
||||||
"id": CONF.identity.default_domain_id
|
"id": CONF.identity.default_domain_id
|
||||||
}
|
}
|
||||||
@ -198,7 +204,7 @@ class CliBootStrapTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
auth_response = c.post('/v3/auth/tokens',
|
auth_response = c.post('/v3/auth/tokens',
|
||||||
json=v3_password_data)
|
json=v3_password_data)
|
||||||
token = auth_response.headers['X-Subject-Token']
|
token = auth_response.headers['X-Subject-Token']
|
||||||
self._do_test_bootstrap(bootstrap)
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
# build validation request
|
# build validation request
|
||||||
with app.test_client() as c:
|
with app.test_client() as c:
|
||||||
# Get a new X-Auth-Token
|
# Get a new X-Auth-Token
|
||||||
@ -214,8 +220,7 @@ class CliBootStrapTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
def test_bootstrap_is_not_idempotent_when_password_does_change(self):
|
def test_bootstrap_is_not_idempotent_when_password_does_change(self):
|
||||||
# NOTE(lbragstad): Ensure bootstrap isn't idempotent when run with
|
# NOTE(lbragstad): Ensure bootstrap isn't idempotent when run with
|
||||||
# different arguments or configuration values.
|
# different arguments or configuration values.
|
||||||
bootstrap = cli.BootStrap()
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
self._do_test_bootstrap(bootstrap)
|
|
||||||
app = self.loadapp()
|
app = self.loadapp()
|
||||||
v3_password_data = {
|
v3_password_data = {
|
||||||
'auth': {
|
'auth': {
|
||||||
@ -223,8 +228,8 @@ class CliBootStrapTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
"methods": ["password"],
|
"methods": ["password"],
|
||||||
"password": {
|
"password": {
|
||||||
"user": {
|
"user": {
|
||||||
"name": bootstrap.username,
|
"name": self.bootstrap.username,
|
||||||
"password": bootstrap.password,
|
"password": self.bootstrap.password,
|
||||||
"domain": {
|
"domain": {
|
||||||
"id": CONF.identity.default_domain_id
|
"id": CONF.identity.default_domain_id
|
||||||
}
|
}
|
||||||
@ -241,7 +246,7 @@ class CliBootStrapTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
token = auth_response.headers['X-Subject-Token']
|
token = auth_response.headers['X-Subject-Token']
|
||||||
new_passwd = uuid.uuid4().hex
|
new_passwd = uuid.uuid4().hex
|
||||||
os.environ['OS_BOOTSTRAP_PASSWORD'] = new_passwd
|
os.environ['OS_BOOTSTRAP_PASSWORD'] = new_passwd
|
||||||
self._do_test_bootstrap(bootstrap)
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
v3_password_data['auth']['identity']['password']['user'][
|
v3_password_data['auth']['identity']['password']['user'][
|
||||||
'password'] = new_passwd
|
'password'] = new_passwd
|
||||||
# Move time forward a second to avoid rev. event capturing the new
|
# Move time forward a second to avoid rev. event capturing the new
|
||||||
@ -264,12 +269,11 @@ class CliBootStrapTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
expected_status_code=http_client.NOT_FOUND)
|
expected_status_code=http_client.NOT_FOUND)
|
||||||
|
|
||||||
def test_bootstrap_recovers_user(self):
|
def test_bootstrap_recovers_user(self):
|
||||||
bootstrap = cli.BootStrap()
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
self._do_test_bootstrap(bootstrap)
|
|
||||||
|
|
||||||
# Completely lock the user out.
|
# Completely lock the user out.
|
||||||
user_id = PROVIDERS.identity_api.get_user_by_name(
|
user_id = PROVIDERS.identity_api.get_user_by_name(
|
||||||
bootstrap.username,
|
self.bootstrap.username,
|
||||||
'default')['id']
|
'default')['id']
|
||||||
PROVIDERS.identity_api.update_user(
|
PROVIDERS.identity_api.update_user(
|
||||||
user_id,
|
user_id,
|
||||||
@ -277,13 +281,13 @@ class CliBootStrapTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
'password': uuid.uuid4().hex})
|
'password': uuid.uuid4().hex})
|
||||||
|
|
||||||
# The second bootstrap run will recover the account.
|
# The second bootstrap run will recover the account.
|
||||||
self._do_test_bootstrap(bootstrap)
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
|
|
||||||
# Sanity check that the original password works again.
|
# Sanity check that the original password works again.
|
||||||
PROVIDERS.identity_api.authenticate(
|
PROVIDERS.identity_api.authenticate(
|
||||||
self.make_request(),
|
self.make_request(),
|
||||||
user_id,
|
user_id,
|
||||||
bootstrap.password)
|
self.bootstrap.password)
|
||||||
|
|
||||||
|
|
||||||
class CliBootStrapTestCaseWithEnvironment(CliBootStrapTestCase):
|
class CliBootStrapTestCaseWithEnvironment(CliBootStrapTestCase):
|
||||||
@ -335,9 +339,11 @@ class CliBootStrapTestCaseWithEnvironment(CliBootStrapTestCase):
|
|||||||
fixtures.EnvironmentVariable('OS_BOOTSTRAP_REGION_ID',
|
fixtures.EnvironmentVariable('OS_BOOTSTRAP_REGION_ID',
|
||||||
newvalue=self.region_id))
|
newvalue=self.region_id))
|
||||||
|
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
|
|
||||||
def test_assignment_created_with_user_exists(self):
|
def test_assignment_created_with_user_exists(self):
|
||||||
# test assignment can be created if user already exists.
|
# test assignment can be created if user already exists.
|
||||||
bootstrap = cli.BootStrap()
|
|
||||||
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
||||||
self.default_domain)
|
self.default_domain)
|
||||||
user_ref = unit.new_user_ref(self.default_domain['id'],
|
user_ref = unit.new_user_ref(self.default_domain['id'],
|
||||||
@ -345,47 +351,42 @@ class CliBootStrapTestCaseWithEnvironment(CliBootStrapTestCase):
|
|||||||
password=self.password)
|
password=self.password)
|
||||||
PROVIDERS.identity_api.create_user(user_ref)
|
PROVIDERS.identity_api.create_user(user_ref)
|
||||||
|
|
||||||
self._do_test_bootstrap(bootstrap)
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
|
|
||||||
def test_assignment_created_with_project_exists(self):
|
def test_assignment_created_with_project_exists(self):
|
||||||
# test assignment can be created if project already exists.
|
# test assignment can be created if project already exists.
|
||||||
bootstrap = cli.BootStrap()
|
|
||||||
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
||||||
self.default_domain)
|
self.default_domain)
|
||||||
project_ref = unit.new_project_ref(self.default_domain['id'],
|
project_ref = unit.new_project_ref(self.default_domain['id'],
|
||||||
name=self.project_name)
|
name=self.project_name)
|
||||||
PROVIDERS.resource_api.create_project(project_ref['id'], project_ref)
|
PROVIDERS.resource_api.create_project(project_ref['id'], project_ref)
|
||||||
self._do_test_bootstrap(bootstrap)
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
|
|
||||||
def test_assignment_created_with_role_exists(self):
|
def test_assignment_created_with_role_exists(self):
|
||||||
# test assignment can be created if role already exists.
|
# test assignment can be created if role already exists.
|
||||||
bootstrap = cli.BootStrap()
|
|
||||||
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
||||||
self.default_domain)
|
self.default_domain)
|
||||||
role = unit.new_role_ref(name=self.role_name)
|
role = unit.new_role_ref(name=self.role_name)
|
||||||
PROVIDERS.role_api.create_role(role['id'], role)
|
PROVIDERS.role_api.create_role(role['id'], role)
|
||||||
self._do_test_bootstrap(bootstrap)
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
|
|
||||||
def test_assignment_created_with_region_exists(self):
|
def test_assignment_created_with_region_exists(self):
|
||||||
# test assignment can be created if region already exists.
|
# test assignment can be created if region already exists.
|
||||||
bootstrap = cli.BootStrap()
|
|
||||||
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
||||||
self.default_domain)
|
self.default_domain)
|
||||||
region = unit.new_region_ref(id=self.region_id)
|
region = unit.new_region_ref(id=self.region_id)
|
||||||
PROVIDERS.catalog_api.create_region(region)
|
PROVIDERS.catalog_api.create_region(region)
|
||||||
self._do_test_bootstrap(bootstrap)
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
|
|
||||||
def test_endpoints_created_with_service_exists(self):
|
def test_endpoints_created_with_service_exists(self):
|
||||||
# test assignment can be created if service already exists.
|
# test assignment can be created if service already exists.
|
||||||
bootstrap = cli.BootStrap()
|
|
||||||
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
||||||
self.default_domain)
|
self.default_domain)
|
||||||
service = unit.new_service_ref(name=self.service_name)
|
service = unit.new_service_ref(name=self.service_name)
|
||||||
PROVIDERS.catalog_api.create_service(service['id'], service)
|
PROVIDERS.catalog_api.create_service(service['id'], service)
|
||||||
self._do_test_bootstrap(bootstrap)
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
|
|
||||||
def test_endpoints_created_with_endpoint_exists(self):
|
def test_endpoints_created_with_endpoint_exists(self):
|
||||||
bootstrap = cli.BootStrap()
|
|
||||||
# test assignment can be created if endpoint already exists.
|
# test assignment can be created if endpoint already exists.
|
||||||
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
PROVIDERS.resource_api.create_domain(self.default_domain['id'],
|
||||||
self.default_domain)
|
self.default_domain)
|
||||||
@ -401,7 +402,7 @@ class CliBootStrapTestCaseWithEnvironment(CliBootStrapTestCase):
|
|||||||
region_id=self.region_id)
|
region_id=self.region_id)
|
||||||
PROVIDERS.catalog_api.create_endpoint(endpoint['id'], endpoint)
|
PROVIDERS.catalog_api.create_endpoint(endpoint['id'], endpoint)
|
||||||
|
|
||||||
self._do_test_bootstrap(bootstrap)
|
self._do_test_bootstrap(self.bootstrap)
|
||||||
|
|
||||||
|
|
||||||
class CliDomainConfigAllTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
class CliDomainConfigAllTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
||||||
@ -449,6 +450,9 @@ class CliDomainConfigAllTestCase(unit.SQLDriverOverrides, unit.TestCase):
|
|||||||
def create_domain(domain):
|
def create_domain(domain):
|
||||||
return PROVIDERS.resource_api.create_domain(domain['id'], domain)
|
return PROVIDERS.resource_api.create_domain(domain['id'], domain)
|
||||||
|
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
|
|
||||||
self.domains = {}
|
self.domains = {}
|
||||||
self.addCleanup(self.cleanup_domains)
|
self.addCleanup(self.cleanup_domains)
|
||||||
for x in range(1, self.domain_count):
|
for x in range(1, self.domain_count):
|
||||||
|
@ -14,6 +14,7 @@ import uuid
|
|||||||
|
|
||||||
from keystone.common import provider_api
|
from keystone.common import provider_api
|
||||||
from keystone.tests import unit
|
from keystone.tests import unit
|
||||||
|
from keystone.tests.unit import default_fixtures
|
||||||
from keystone.tests.unit.identity.shadow_users import test_backend
|
from keystone.tests.unit.identity.shadow_users import test_backend
|
||||||
from keystone.tests.unit.identity.shadow_users import test_core
|
from keystone.tests.unit.identity.shadow_users import test_core
|
||||||
from keystone.tests.unit.ksfixtures import database
|
from keystone.tests.unit.ksfixtures import database
|
||||||
@ -28,6 +29,8 @@ class ShadowUsersTests(unit.TestCase,
|
|||||||
super(ShadowUsersTests, self).setUp()
|
super(ShadowUsersTests, self).setUp()
|
||||||
self.useFixture(database.Database())
|
self.useFixture(database.Database())
|
||||||
self.load_backends()
|
self.load_backends()
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
self.idp = {
|
self.idp = {
|
||||||
'id': uuid.uuid4().hex,
|
'id': uuid.uuid4().hex,
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
|
@ -197,10 +197,9 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
|
|||||||
config_files.append(unit.dirs.tests_conf('backend_sql.conf'))
|
config_files.append(unit.dirs.tests_conf('backend_sql.conf'))
|
||||||
return config_files
|
return config_files
|
||||||
|
|
||||||
def setUp(self, enable_sqlite_foreign_key=False):
|
def setUp(self):
|
||||||
"""Setup for v3 Restful Test Cases."""
|
"""Setup for v3 Restful Test Cases."""
|
||||||
super(RestfulTestCase, self).setUp(
|
super(RestfulTestCase, self).setUp()
|
||||||
enable_sqlite_foreign_key=enable_sqlite_foreign_key)
|
|
||||||
|
|
||||||
self.empty_context = {'environment': {}}
|
self.empty_context = {'environment': {}}
|
||||||
|
|
||||||
@ -210,26 +209,18 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
|
|||||||
|
|
||||||
super(RestfulTestCase, self).load_backends()
|
super(RestfulTestCase, self).load_backends()
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
self.load_sample_data(
|
self.load_sample_data()
|
||||||
enable_sqlite_foreign_key=enable_sqlite_foreign_key)
|
|
||||||
|
|
||||||
def _populate_default_domain(self, enable_sqlite_foreign_key=False):
|
def _populate_default_domain(self):
|
||||||
try:
|
try:
|
||||||
PROVIDERS.resource_api.get_domain(DEFAULT_DOMAIN_ID)
|
PROVIDERS.resource_api.get_domain(DEFAULT_DOMAIN_ID)
|
||||||
except exception.DomainNotFound:
|
except exception.DomainNotFound:
|
||||||
# TODO(wxy): when FK is enabled in sqlite, a lot of tests will fail
|
|
||||||
# due to the root domain is missing. So we should open FKs for the
|
|
||||||
# tests one by one. If the FKs is enabled for one test,
|
|
||||||
# `enable_sqlite_foreign_key` should be `true` here to ensure the
|
|
||||||
# root domain is created. Once all tests enable FKs, the
|
|
||||||
# ``enable_sqlite_foreign_key`` can be removed.
|
|
||||||
if enable_sqlite_foreign_key:
|
|
||||||
root_domain = unit.new_domain_ref(
|
root_domain = unit.new_domain_ref(
|
||||||
id=resource_base.NULL_DOMAIN_ID,
|
id=resource_base.NULL_DOMAIN_ID,
|
||||||
name=resource_base.NULL_DOMAIN_ID
|
name=resource_base.NULL_DOMAIN_ID
|
||||||
)
|
)
|
||||||
self.resource_api.create_domain(resource_base.NULL_DOMAIN_ID,
|
PROVIDERS.resource_api.create_domain(resource_base.NULL_DOMAIN_ID,
|
||||||
root_domain)
|
root_domain)
|
||||||
domain = unit.new_domain_ref(
|
domain = unit.new_domain_ref(
|
||||||
description=(u'The default domain'),
|
description=(u'The default domain'),
|
||||||
@ -237,10 +228,8 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
|
|||||||
name=u'Default')
|
name=u'Default')
|
||||||
PROVIDERS.resource_api.create_domain(DEFAULT_DOMAIN_ID, domain)
|
PROVIDERS.resource_api.create_domain(DEFAULT_DOMAIN_ID, domain)
|
||||||
|
|
||||||
def load_sample_data(self, create_region_and_endpoints=True,
|
def load_sample_data(self, create_region_and_endpoints=True):
|
||||||
enable_sqlite_foreign_key=False):
|
self._populate_default_domain()
|
||||||
self._populate_default_domain(
|
|
||||||
enable_sqlite_foreign_key=enable_sqlite_foreign_key)
|
|
||||||
self.domain = unit.new_domain_ref()
|
self.domain = unit.new_domain_ref()
|
||||||
self.domain_id = self.domain['id']
|
self.domain_id = self.domain['id']
|
||||||
PROVIDERS.resource_api.create_domain(self.domain_id, self.domain)
|
PROVIDERS.resource_api.create_domain(self.domain_id, self.domain)
|
||||||
|
@ -22,6 +22,7 @@ from testtools import matchers
|
|||||||
from keystone.common import provider_api
|
from keystone.common import provider_api
|
||||||
import keystone.conf
|
import keystone.conf
|
||||||
from keystone import exception
|
from keystone import exception
|
||||||
|
from keystone.resource.backends import base as resource_base
|
||||||
from keystone.tests import unit
|
from keystone.tests import unit
|
||||||
from keystone.tests.unit import test_v3
|
from keystone.tests.unit import test_v3
|
||||||
from keystone.tests.unit import utils as test_utils
|
from keystone.tests.unit import utils as test_utils
|
||||||
@ -1174,7 +1175,7 @@ class RoleAssignmentBaseTestCase(test_v3.RestfulTestCase,
|
|||||||
MAX_HIERARCHY_BREADTH = 3
|
MAX_HIERARCHY_BREADTH = 3
|
||||||
MAX_HIERARCHY_DEPTH = CONF.max_project_tree_depth - 1
|
MAX_HIERARCHY_DEPTH = CONF.max_project_tree_depth - 1
|
||||||
|
|
||||||
def load_sample_data(self, enable_sqlite_foreign_key=False):
|
def load_sample_data(self):
|
||||||
"""Create sample data to be used on tests.
|
"""Create sample data to be used on tests.
|
||||||
|
|
||||||
Created data are i) a role and ii) a domain containing: a project
|
Created data are i) a role and ii) a domain containing: a project
|
||||||
@ -3294,7 +3295,7 @@ class DomainSpecificRoleTests(test_v3.RestfulTestCase, unit.TestCase):
|
|||||||
class ListUserProjectsTestCase(test_v3.RestfulTestCase):
|
class ListUserProjectsTestCase(test_v3.RestfulTestCase):
|
||||||
"""Test for /users/<user>/projects."""
|
"""Test for /users/<user>/projects."""
|
||||||
|
|
||||||
def load_sample_data(self, enable_sqlite_foreign_key=False):
|
def load_sample_data(self):
|
||||||
# do not load base class's data, keep it focused on the tests
|
# do not load base class's data, keep it focused on the tests
|
||||||
|
|
||||||
self.auths = []
|
self.auths = []
|
||||||
@ -3303,6 +3304,13 @@ class ListUserProjectsTestCase(test_v3.RestfulTestCase):
|
|||||||
self.roles = []
|
self.roles = []
|
||||||
self.users = []
|
self.users = []
|
||||||
|
|
||||||
|
root_domain = unit.new_domain_ref(
|
||||||
|
id=resource_base.NULL_DOMAIN_ID,
|
||||||
|
name=resource_base.NULL_DOMAIN_ID
|
||||||
|
)
|
||||||
|
self.resource_api.create_domain(resource_base.NULL_DOMAIN_ID,
|
||||||
|
root_domain)
|
||||||
|
|
||||||
# Create 3 sets of domain, roles, projects, and users to demonstrate
|
# Create 3 sets of domain, roles, projects, and users to demonstrate
|
||||||
# the right user's data is loaded and only projects they can access
|
# the right user's data is loaded and only projects they can access
|
||||||
# are returned.
|
# are returned.
|
||||||
|
@ -2575,7 +2575,7 @@ class TestFernetTokenAPIs(test_v3.RestfulTestCase, TokenAPITests,
|
|||||||
class TestTokenRevokeSelfAndAdmin(test_v3.RestfulTestCase):
|
class TestTokenRevokeSelfAndAdmin(test_v3.RestfulTestCase):
|
||||||
"""Test token revoke using v3 Identity API by token owner and admin."""
|
"""Test token revoke using v3 Identity API by token owner and admin."""
|
||||||
|
|
||||||
def load_sample_data(self, enable_sqlite_foreign_key=False):
|
def load_sample_data(self):
|
||||||
"""Load Sample Data for Test Cases.
|
"""Load Sample Data for Test Cases.
|
||||||
|
|
||||||
Two domains, domainA and domainB
|
Two domains, domainA and domainB
|
||||||
|
@ -20,6 +20,7 @@ from testtools import matchers
|
|||||||
|
|
||||||
from keystone.common import provider_api
|
from keystone.common import provider_api
|
||||||
from keystone.tests import unit
|
from keystone.tests import unit
|
||||||
|
from keystone.tests.unit import default_fixtures
|
||||||
from keystone.tests.unit.ksfixtures import database
|
from keystone.tests.unit.ksfixtures import database
|
||||||
from keystone.tests.unit import test_v3
|
from keystone.tests.unit import test_v3
|
||||||
|
|
||||||
@ -832,6 +833,9 @@ class TestCatalogAPISQL(unit.TestCase):
|
|||||||
|
|
||||||
self.create_endpoint(service_id=self.service_id)
|
self.create_endpoint(service_id=self.service_id)
|
||||||
|
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
|
|
||||||
def create_endpoint(self, service_id, **kwargs):
|
def create_endpoint(self, service_id, **kwargs):
|
||||||
endpoint = unit.new_endpoint_ref(service_id=service_id,
|
endpoint = unit.new_endpoint_ref(service_id=service_id,
|
||||||
region_id=None, **kwargs)
|
region_id=None, **kwargs)
|
||||||
@ -929,6 +933,8 @@ class TestCatalogAPISQLRegions(unit.TestCase):
|
|||||||
super(TestCatalogAPISQLRegions, self).setUp()
|
super(TestCatalogAPISQLRegions, self).setUp()
|
||||||
self.useFixture(database.Database())
|
self.useFixture(database.Database())
|
||||||
self.load_backends()
|
self.load_backends()
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
|
|
||||||
def config_overrides(self):
|
def config_overrides(self):
|
||||||
super(TestCatalogAPISQLRegions, self).config_overrides()
|
super(TestCatalogAPISQLRegions, self).config_overrides()
|
||||||
@ -998,7 +1004,7 @@ class TestCatalogAPITemplatedProject(test_v3.RestfulTestCase):
|
|||||||
super(TestCatalogAPITemplatedProject, self).config_overrides()
|
super(TestCatalogAPITemplatedProject, self).config_overrides()
|
||||||
self.config_fixture.config(group='catalog', driver='templated')
|
self.config_fixture.config(group='catalog', driver='templated')
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
self.load_sample_data(create_region_and_endpoints=False)
|
self.load_sample_data(create_region_and_endpoints=False)
|
||||||
|
|
||||||
def test_project_delete(self):
|
def test_project_delete(self):
|
||||||
|
@ -1892,7 +1892,7 @@ class FederatedTokenTests(test_v3.RestfulTestCase, FederatedSetupMixin):
|
|||||||
self.assertEqual(note['protocol'], protocol)
|
self.assertEqual(note['protocol'], protocol)
|
||||||
self.assertTrue(note['send_notification_called'])
|
self.assertTrue(note['send_notification_called'])
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
super(FederatedTokenTests, self).load_fixtures(fixtures)
|
super(FederatedTokenTests, self).load_fixtures(fixtures)
|
||||||
self.load_federation_sample_data()
|
self.load_federation_sample_data()
|
||||||
|
|
||||||
@ -2856,7 +2856,7 @@ class FederatedTokenTests(test_v3.RestfulTestCase, FederatedSetupMixin):
|
|||||||
class FernetFederatedTokenTests(test_v3.RestfulTestCase, FederatedSetupMixin):
|
class FernetFederatedTokenTests(test_v3.RestfulTestCase, FederatedSetupMixin):
|
||||||
AUTH_METHOD = 'token'
|
AUTH_METHOD = 'token'
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
super(FernetFederatedTokenTests, self).load_fixtures(fixtures)
|
super(FernetFederatedTokenTests, self).load_fixtures(fixtures)
|
||||||
self.load_federation_sample_data()
|
self.load_federation_sample_data()
|
||||||
|
|
||||||
@ -2972,7 +2972,7 @@ class FederatedUserTests(test_v3.RestfulTestCase, FederatedSetupMixin):
|
|||||||
methods = ['saml2', 'token']
|
methods = ['saml2', 'token']
|
||||||
super(FederatedUserTests, self).auth_plugin_config_override(methods)
|
super(FederatedUserTests, self).auth_plugin_config_override(methods)
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
super(FederatedUserTests, self).load_fixtures(fixtures)
|
super(FederatedUserTests, self).load_fixtures(fixtures)
|
||||||
self.load_federation_sample_data()
|
self.load_federation_sample_data()
|
||||||
|
|
||||||
@ -3341,7 +3341,7 @@ class ShadowMappingTests(test_v3.RestfulTestCase, FederatedSetupMixin):
|
|||||||
methods = ['saml2', 'token']
|
methods = ['saml2', 'token']
|
||||||
super(ShadowMappingTests, self).auth_plugin_config_override(methods)
|
super(ShadowMappingTests, self).auth_plugin_config_override(methods)
|
||||||
|
|
||||||
def load_fixtures(self, fixtures, enable_sqlite_foreign_key=False):
|
def load_fixtures(self, fixtures):
|
||||||
super(ShadowMappingTests, self).load_fixtures(fixtures)
|
super(ShadowMappingTests, self).load_fixtures(fixtures)
|
||||||
self.load_federation_sample_data()
|
self.load_federation_sample_data()
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class IdentityTestFilteredCase(filtering.FilterTests,
|
|||||||
self.tmpfilename = self.tempfile.file_name
|
self.tmpfilename = self.tempfile.file_name
|
||||||
super(IdentityTestFilteredCase, self).setUp()
|
super(IdentityTestFilteredCase, self).setUp()
|
||||||
|
|
||||||
def load_sample_data(self, enable_sqlite_foreign_key=False):
|
def load_sample_data(self):
|
||||||
"""Create sample data for these tests.
|
"""Create sample data for these tests.
|
||||||
|
|
||||||
As well as the usual housekeeping, create a set of domains,
|
As well as the usual housekeeping, create a set of domains,
|
||||||
@ -341,7 +341,7 @@ class IdentityPasswordExpiryFilteredTestCase(filtering.FilterTests,
|
|||||||
self.config_fixture = self.useFixture(config_fixture.Config(CONF))
|
self.config_fixture = self.useFixture(config_fixture.Config(CONF))
|
||||||
super(IdentityPasswordExpiryFilteredTestCase, self).setUp()
|
super(IdentityPasswordExpiryFilteredTestCase, self).setUp()
|
||||||
|
|
||||||
def load_sample_data(self, enable_sqlite_foreign_key=False):
|
def load_sample_data(self):
|
||||||
"""Create sample data for password expiry tests.
|
"""Create sample data for password expiry tests.
|
||||||
|
|
||||||
The test environment will consist of a single domain, containing
|
The test environment will consist of a single domain, containing
|
||||||
|
@ -64,7 +64,7 @@ class IdentityTestProtectedCase(test_v3.RestfulTestCase):
|
|||||||
user_id=self.user1['id'],
|
user_id=self.user1['id'],
|
||||||
password=self.user1['password'])
|
password=self.user1['password'])
|
||||||
|
|
||||||
def load_sample_data(self, enable_sqlite_foreign_key=False):
|
def load_sample_data(self):
|
||||||
self._populate_default_domain()
|
self._populate_default_domain()
|
||||||
|
|
||||||
# Start by creating a couple of domains
|
# Start by creating a couple of domains
|
||||||
@ -395,7 +395,7 @@ class IdentityTestProtectedCase(test_v3.RestfulTestCase):
|
|||||||
class IdentityTestPolicySample(test_v3.RestfulTestCase):
|
class IdentityTestPolicySample(test_v3.RestfulTestCase):
|
||||||
"""Test policy enforcement of the policy.json file."""
|
"""Test policy enforcement of the policy.json file."""
|
||||||
|
|
||||||
def load_sample_data(self, enable_sqlite_foreign_key=False):
|
def load_sample_data(self):
|
||||||
self._populate_default_domain()
|
self._populate_default_domain()
|
||||||
|
|
||||||
self.just_a_user = unit.create_user(
|
self.just_a_user = unit.create_user(
|
||||||
@ -687,7 +687,7 @@ class IdentityTestv3CloudPolicySample(test_v3.RestfulTestCase,
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def load_sample_data(self, enable_sqlite_foreign_key=False):
|
def load_sample_data(self):
|
||||||
# Start by creating a couple of domains
|
# Start by creating a couple of domains
|
||||||
self._populate_default_domain()
|
self._populate_default_domain()
|
||||||
self.domainA = unit.new_domain_ref()
|
self.domainA = unit.new_domain_ref()
|
||||||
|
@ -35,7 +35,7 @@ class ResourceTestCase(test_v3.RestfulTestCase,
|
|||||||
"""Test domains and projects."""
|
"""Test domains and projects."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ResourceTestCase, self).setUp(enable_sqlite_foreign_key=True)
|
super(ResourceTestCase, self).setUp()
|
||||||
self.useFixture(
|
self.useFixture(
|
||||||
ksfixtures.KeyRepository(
|
ksfixtures.KeyRepository(
|
||||||
self.config_fixture,
|
self.config_fixture,
|
||||||
|
@ -28,6 +28,7 @@ import keystone.conf
|
|||||||
from keystone import exception
|
from keystone import exception
|
||||||
from keystone.federation import constants as federation_constants
|
from keystone.federation import constants as federation_constants
|
||||||
from keystone.tests import unit
|
from keystone.tests import unit
|
||||||
|
from keystone.tests.unit import default_fixtures
|
||||||
from keystone.tests.unit import ksfixtures
|
from keystone.tests.unit import ksfixtures
|
||||||
from keystone.tests.unit.ksfixtures import database
|
from keystone.tests.unit.ksfixtures import database
|
||||||
from keystone.token import provider
|
from keystone.token import provider
|
||||||
@ -57,6 +58,8 @@ class TestValidate(unit.TestCase):
|
|||||||
super(TestValidate, self).setUp()
|
super(TestValidate, self).setUp()
|
||||||
self.useFixture(database.Database())
|
self.useFixture(database.Database())
|
||||||
self.load_backends()
|
self.load_backends()
|
||||||
|
PROVIDERS.resource_api.create_domain(
|
||||||
|
default_fixtures.ROOT_DOMAIN['id'], default_fixtures.ROOT_DOMAIN)
|
||||||
|
|
||||||
def config_overrides(self):
|
def config_overrides(self):
|
||||||
super(TestValidate, self).config_overrides()
|
super(TestValidate, self).config_overrides()
|
||||||
|
7
releasenotes/notes/bug-1744195-a7154ac2e8556efc.yaml
Normal file
7
releasenotes/notes/bug-1744195-a7154ac2e8556efc.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
[`bug 1744195 <https://bugs.launchpad.net/keystone/+bug/1744195>`_]
|
||||||
|
The SQL Foreign Key is enabled for Keystone unit tests now. This is not an
|
||||||
|
end user impact fixed. But for the downstream teams, please take care of
|
||||||
|
it for your private test code changes.
|
Loading…
x
Reference in New Issue
Block a user