summaryrefslogtreecommitdiff
path: root/keystone/resource
diff options
context:
space:
mode:
authorwangxiyuan <wangxiyuan@huawei.com>2018-04-02 19:28:33 +0800
committerwangxiyuan <wangxiyuan@huawei.com>2018-10-09 09:50:21 +0800
commit012dac29b8dd6ac77e707f916fc4c0ca57d58b14 (patch)
tree9ec43700f83f1bb33d2ed6f8cd91935da4dc6f32 /keystone/resource
parent413d5c18ffc44cf4845994b15bb5b002eb1c3f65 (diff)
downloadkeystone-012dac29b8dd6ac77e707f916fc4c0ca57d58b14.tar.gz
Enable foreign keys for unit test
The unit test uses sqlite for test which closes db foreign keys function by default. This patch enabled the sqlite foreign keys function for unit test by default. The "project" table is a self referencing FK table(id <-> domain_id column). So when the FK is enabled, there must exists a root record before insert data to this table. It's <<keystone.domain.root>>. Usually, the <<keystone.domain.root>> recored is inserted into the table once operators run "keystone-manage db_sync" command when deploy Keystone. But the unit test code doesn't run this command, it initialise the db schema by reading sqlalchemy object model, so the <<keystone.domain.root>> record is missed. Then we can't create any project record, it'll raise FK error. So in this patch, before creating any projects in the test, we must ensure the <<keystone.domain.root>> record exists first. Change-Id: I565d12395ca39a58ba90faf8641a9e02d986aeb9 Closes-Bug: #1744195
Diffstat (limited to 'keystone/resource')
-rw-r--r--keystone/resource/core.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/keystone/resource/core.py b/keystone/resource/core.py
index e427dfb67..bc558040e 100644
--- a/keystone/resource/core.py
+++ b/keystone/resource/core.py
@@ -102,7 +102,8 @@ class Manager(manager.Manager):
was not satisfied.
"""
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(
message=_('Multiple domains are not supported'))