Merge "Make default domain usage consistent"

This commit is contained in:
Jenkins 2016-12-02 01:17:18 +00:00 committed by Gerrit Code Review
commit e83069a2c3
5 changed files with 21 additions and 12 deletions

View File

@ -41,7 +41,7 @@ from openstack_dashboard import policy
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
DEFAULT_ROLE = None DEFAULT_ROLE = None
DEFAULT_DOMAIN = getattr(settings, 'OPENSTACK_KEYSTONE_DEFAULT_DOMAIN', DEFAULT_DOMAIN = getattr(settings, 'OPENSTACK_KEYSTONE_DEFAULT_DOMAIN',
'default') 'Default')
# Set up our data structure for managing Identity API versions, and # Set up our data structure for managing Identity API versions, and
@ -295,11 +295,14 @@ def get_default_domain(request, get_name=True):
def get_effective_domain_id(request): def get_effective_domain_id(request):
"""Gets the id of the default domain to use when creating Identity objects. """Gets the id of the default domain to use when creating Identity
If the requests default domain is the same as DEFAULT_DOMAIN, return None. objects. If the requests default domain is the same as DEFAULT_DOMAIN,
return None.
""" """
domain_id = get_default_domain(request).get('id') default_domain = get_default_domain(request)
return None if domain_id == DEFAULT_DOMAIN else domain_id domain_id = default_domain.get('id')
domain_name = default_domain.get('name')
return None if domain_name == DEFAULT_DOMAIN else domain_id
def is_cloud_admin(request): def is_cloud_admin(request):

View File

@ -157,7 +157,7 @@ class DomainsViewTests(test.BaseAdminViewTests):
@test.create_stubs({api.keystone: ('domain_get', @test.create_stubs({api.keystone: ('domain_get',
'domain_list', )}) 'domain_list', )})
def test_set_clear_domain_context(self): def test_set_clear_domain_context(self):
domain = self.domains.get(id="1") domain = self.domains.get(id="3")
api.keystone.domain_get(IgnoreArg(), domain.id).AndReturn(domain) api.keystone.domain_get(IgnoreArg(), domain.id).AndReturn(domain)
api.keystone.domain_get(IgnoreArg(), domain.id).AndReturn(domain) api.keystone.domain_get(IgnoreArg(), domain.id).AndReturn(domain)
@ -171,7 +171,7 @@ class DomainsViewTests(test.BaseAdminViewTests):
self.assertTemplateUsed(res, constants.DOMAINS_INDEX_VIEW_TEMPLATE) self.assertTemplateUsed(res, constants.DOMAINS_INDEX_VIEW_TEMPLATE)
self.assertItemsEqual(res.context['table'].data, [domain, ]) self.assertItemsEqual(res.context['table'].data, [domain, ])
self.assertContains(res, "<em>test_domain:</em>") self.assertContains(res, "<em>another_test_domain:</em>")
formData = {'action': 'domains__clear_domain_context__%s' % domain.id} formData = {'action': 'domains__clear_domain_context__%s' % domain.id}
res = self.client.post(DOMAINS_INDEX_URL, formData) res = self.client.post(DOMAINS_INDEX_URL, formData)
@ -179,6 +179,7 @@ class DomainsViewTests(test.BaseAdminViewTests):
self.assertTemplateUsed(res, constants.DOMAINS_INDEX_VIEW_TEMPLATE) self.assertTemplateUsed(res, constants.DOMAINS_INDEX_VIEW_TEMPLATE)
self.assertItemsEqual(res.context['table'].data, self.domains.list()) self.assertItemsEqual(res.context['table'].data, self.domains.list())
self.assertNotContains(res, "<em>test_domain:</em>") self.assertNotContains(res, "<em>test_domain:</em>")
self.assertNotContains(res, "<em>another_test_domain:</em>")
class CreateDomainWorkflowTests(test.BaseAdminViewTests): class CreateDomainWorkflowTests(test.BaseAdminViewTests):

View File

@ -152,7 +152,7 @@ class GroupsViewTests(test.BaseAdminViewTests):
@test.create_stubs({api.keystone: ('group_create',)}) @test.create_stubs({api.keystone: ('group_create',)})
def test_create_with_domain(self): def test_create_with_domain(self):
domain = self.domains.get(id="1") domain = self.domains.get(id="3")
group = self.groups.get(id="1") group = self.groups.get(id="1")
self.setSessionValues(domain_context=domain.id, self.setSessionValues(domain_context=domain.id,

View File

@ -67,11 +67,11 @@ WEBROOT = '/'
# Overrides the default domain used when running on single-domain model # Overrides the default domain used when running on single-domain model
# with Keystone V3. All entities will be created in the default domain. # with Keystone V3. All entities will be created in the default domain.
# NOTE: This value must be the ID of the default domain, NOT the name. # NOTE: This value must be the name of the default domain, NOT the ID.
# Also, you will most likely have a value in the keystone policy file like this # Also, you will most likely have a value in the keystone policy file like this
# "cloud_admin": "rule:admin_required and domain_id:<your domain id>" # "cloud_admin": "rule:admin_required and domain_id:<your domain id>"
# This value must match the domain id specified there. # This value must be the name of the domain whose ID is specified there.
#OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = 'default' #OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = 'Default'
# Set this to True to enable panels that provide the ability for users to # Set this to True to enable panels that provide the ability for users to
# manage Identity Providers (IdPs) and establish a set of rules to map # manage Identity Providers (IdPs) and establish a set of rules to map

View File

@ -149,9 +149,14 @@ def data(TEST):
'name': 'disabled_domain', 'name': 'disabled_domain',
'description': "a disabled test domain.", 'description': "a disabled test domain.",
'enabled': False} 'enabled': False}
domain_dict_3 = {'id': "3",
'name': 'another_test_domain',
'description': "another test domain.",
'enabled': True}
domain = domains.Domain(domains.DomainManager, domain_dict) domain = domains.Domain(domains.DomainManager, domain_dict)
disabled_domain = domains.Domain(domains.DomainManager, domain_dict_2) disabled_domain = domains.Domain(domains.DomainManager, domain_dict_2)
TEST.domains.add(domain, disabled_domain) another_domain = domains.Domain(domains.DomainManager, domain_dict_3)
TEST.domains.add(domain, disabled_domain, another_domain)
TEST.domain = domain # Your "current" domain TEST.domain = domain # Your "current" domain
user_dict = {'id': "1", user_dict = {'id': "1",