summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2017-08-02 02:41:15 +0000
committerLinda Wang <wangwulin@huawei.com>2017-08-03 02:20:50 +0000
commita4f8adbb935737122b4800efbb19b9d9b75c7e01 (patch)
tree3531fe4394cfdb0821dae356e06b22a007b299ab
parent13e17646bccbcafbac13b144e24eee14125d33e3 (diff)
Add domain name when creating projects and users
(spisarski) Also clarified the difference between domain ID and name Added helper methods and domain object for Domains JIRA: FUNCTEST-858 Change-Id: Iccd7eef56713a4ad0c23232073f52bc71168bf5c Signed-off-by: Linda Wang <wangwulin@huawei.com>
-rw-r--r--docs/how-to-use/UnitTests.rst6
-rw-r--r--snaps/domain/project.py17
-rw-r--r--snaps/domain/test/project_tests.py20
-rw-r--r--snaps/openstack/create_project.py11
-rw-r--r--snaps/openstack/create_user.py6
-rw-r--r--snaps/openstack/os_credentials.py16
-rw-r--r--snaps/openstack/tests/conf/os_credentials_tests.py48
-rw-r--r--snaps/openstack/tests/create_project_tests.py30
-rw-r--r--snaps/openstack/tests/create_user_tests.py8
-rw-r--r--snaps/openstack/tests/openstack_tests.py2
-rw-r--r--snaps/openstack/utils/keystone_utils.py46
-rw-r--r--snaps/openstack/utils/tests/keystone_utils_tests.py22
-rw-r--r--snaps/test_suite_builder.py8
13 files changed, 169 insertions, 71 deletions
diff --git a/docs/how-to-use/UnitTests.rst b/docs/how-to-use/UnitTests.rst
index 9da89be..ac42892 100644
--- a/docs/how-to-use/UnitTests.rst
+++ b/docs/how-to-use/UnitTests.rst
@@ -120,6 +120,12 @@ ProjectDomainObjectTests
Ensures that all required members are included when constructing a
Project domain object
+DomainDomainObjectTests
+-----------------------
+
+Ensures that all required members are included when constructing a
+Domain domain object
+
RoleDomainObjectTests
---------------------
diff --git a/snaps/domain/project.py b/snaps/domain/project.py
index 73357c7..54407cf 100644
--- a/snaps/domain/project.py
+++ b/snaps/domain/project.py
@@ -32,3 +32,20 @@ class Project:
def __eq__(self, other):
return self.name == other.name and self.id == other.id
+
+
+class Domain:
+ """
+ SNAPS domain object for OpenStack Keystone v3+ domains.
+ """
+ def __init__(self, name, domain_id=None):
+ """
+ Constructor
+ :param name: the project's name
+ :param domain_id: the project's domain id
+ """
+ self.name = name
+ self.id = domain_id
+
+ def __eq__(self, other):
+ return self.name == other.name and self.id == other.id
diff --git a/snaps/domain/test/project_tests.py b/snaps/domain/test/project_tests.py
index 73939f0..3f4fca6 100644
--- a/snaps/domain/test/project_tests.py
+++ b/snaps/domain/test/project_tests.py
@@ -14,12 +14,12 @@
# limitations under the License.
import unittest
-from snaps.domain.project import Project
+from snaps.domain.project import Project, Domain
class ProjectDomainObjectTests(unittest.TestCase):
"""
- Tests the construction of the snaps.domain.test.Project class
+ Tests the construction of the snaps.domain.project.Project class
"""
def test_construction_positional_minimal(self):
@@ -45,3 +45,19 @@ class ProjectDomainObjectTests(unittest.TestCase):
self.assertEqual('foo', project.name)
self.assertEqual('123-456', project.id)
self.assertEqual('hello', project.domain_id)
+
+
+class DomainDomainObjectTests(unittest.TestCase):
+ """
+ Tests the construction of the snaps.domain.project.Domain class
+ """
+
+ def test_construction_positional(self):
+ domain = Domain('foo', '123-456')
+ self.assertEqual('foo', domain.name)
+ self.assertEqual('123-456', domain.id)
+
+ def test_construction_named_minimal(self):
+ domain = Domain(domain_id='123-456', name='foo')
+ self.assertEqual('foo', domain.name)
+ self.assertEqual('123-456', domain.id)
diff --git a/snaps/openstack/create_project.py b/snaps/openstack/create_project.py
index 1fbaef6..bc80789 100644
--- a/snaps/openstack/create_project.py
+++ b/snaps/openstack/create_project.py
@@ -111,18 +111,17 @@ class ProjectSettings:
"""
Constructor
:param name: the project's name (required)
- :param domain: the project's domain name (default 'default'). Field is
- used for v3 clients
+ :param domain or domain_name: the project's domain name
+ (default = 'Default').
+ Field is used for v3 clients
:param description: the description (optional)
:param enabled: denotes whether or not the user is enabled
(default True)
"""
self.name = kwargs.get('name')
- if kwargs.get('domain'):
- self.domain = kwargs['domain']
- else:
- self.domain = 'default'
+ self.domain_name = kwargs.get(
+ 'domain', kwargs.get('domain', 'Default'))
self.description = kwargs.get('description')
if kwargs.get('enabled') is not None:
diff --git a/snaps/openstack/create_user.py b/snaps/openstack/create_user.py
index 18de215..b16cea4 100644
--- a/snaps/openstack/create_user.py
+++ b/snaps/openstack/create_user.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2016 Cable Television Laboratories, Inc. ("CableLabs")
+# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
# and others. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -87,7 +87,9 @@ class OpenStackUser:
auth_url=self.__os_creds.auth_url,
project_name=project_name,
identity_api_version=self.__os_creds.identity_api_version,
+ user_domain_name=self.__os_creds.user_domain_name,
user_domain_id=self.__os_creds.user_domain_id,
+ project_domain_name=self.__os_creds.project_domain_name,
project_domain_id=self.__os_creds.project_domain_id,
interface=self.__os_creds.interface,
proxy_settings=self.__os_creds.proxy_settings,
@@ -115,7 +117,7 @@ class UserSettings:
self.password = kwargs.get('password')
self.project_name = kwargs.get('project_name')
self.email = kwargs.get('email')
- self.domain_name = kwargs.get('domain_name', 'default')
+ self.domain_name = kwargs.get('domain_name', 'Default')
self.enabled = kwargs.get('enabled', True)
self.roles = kwargs.get('roles', dict())
diff --git a/snaps/openstack/os_credentials.py b/snaps/openstack/os_credentials.py
index fbecbfe..d612e05 100644
--- a/snaps/openstack/os_credentials.py
+++ b/snaps/openstack/os_credentials.py
@@ -42,10 +42,10 @@ class OSCreds:
clients
:param heat_api_version: The OpenStack's API version to use for Heat
clients
- :param user_domain_id: Used for v3 APIs (default=None)
- :param user_domain_name: Used for v3 APIs (default='default')
- :param project_domain_id: Used for v3 APIs (default=None)
- :param project_domain_name: Used for v3 APIs (default='default')
+ :param user_domain_id: Used for v3 APIs (default='default')
+ :param user_domain_name: Used for v3 APIs (default='Default')
+ :param project_domain_id: Used for v3 APIs (default='default')
+ :param project_domain_name: Used for v3 APIs (default='Default')
:param interface: Used to specify the endpoint type for keystone as
public, admin, internal
:param proxy_settings: instance of os_credentials.ProxySettings class
@@ -85,17 +85,17 @@ class OSCreds:
else:
self.heat_api_version = float(kwargs['heat_api_version'])
- self.user_domain_id = kwargs.get('user_domain_id')
+ self.user_domain_id = kwargs.get('user_domain_id', 'default')
if kwargs.get('user_domain_name') is None:
- self.user_domain_name = 'default'
+ self.user_domain_name = 'Default'
else:
self.user_domain_name = kwargs['user_domain_name']
- self.project_domain_id = kwargs.get('project_domain_id')
+ self.project_domain_id = kwargs.get('project_domain_id', 'default')
if kwargs.get('project_domain_name') is None:
- self.project_domain_name = 'default'
+ self.project_domain_name = 'Default'
else:
self.project_domain_name = kwargs['project_domain_name']
diff --git a/snaps/openstack/tests/conf/os_credentials_tests.py b/snaps/openstack/tests/conf/os_credentials_tests.py
index 9c6fcdc..333de59 100644
--- a/snaps/openstack/tests/conf/os_credentials_tests.py
+++ b/snaps/openstack/tests/conf/os_credentials_tests.py
@@ -157,10 +157,10 @@ class OSCredsUnitTests(unittest.TestCase):
self.assertEqual(2, os_creds.image_api_version)
self.assertEqual(2, os_creds.compute_api_version)
self.assertEqual(1, os_creds.heat_api_version)
- self.assertIsNone(os_creds.user_domain_id)
- self.assertEqual('default', os_creds.user_domain_name)
- self.assertIsNone(os_creds.project_domain_id)
- self.assertEqual('default', os_creds.project_domain_name)
+ self.assertEqual('default', os_creds.user_domain_id)
+ self.assertEqual('Default', os_creds.user_domain_name)
+ self.assertEqual('default', os_creds.project_domain_id)
+ self.assertEqual('Default', os_creds.project_domain_name)
self.assertEqual('admin', os_creds.interface)
self.assertFalse(os_creds.cacert)
self.assertIsNone(os_creds.proxy_settings)
@@ -178,10 +178,10 @@ class OSCredsUnitTests(unittest.TestCase):
self.assertEqual(2, os_creds.image_api_version)
self.assertEqual(2, os_creds.compute_api_version)
self.assertEqual(1, os_creds.heat_api_version)
- self.assertIsNone(os_creds.user_domain_id)
- self.assertEqual('default', os_creds.user_domain_name)
- self.assertIsNone(os_creds.project_domain_id)
- self.assertEqual('default', os_creds.project_domain_name)
+ self.assertEqual('default', os_creds.user_domain_id)
+ self.assertEqual('Default', os_creds.user_domain_name)
+ self.assertEqual('default', os_creds.project_domain_id)
+ self.assertEqual('Default', os_creds.project_domain_name)
self.assertEqual('admin', os_creds.interface)
self.assertFalse(os_creds.cacert)
self.assertIsNone(os_creds.proxy_settings)
@@ -202,10 +202,10 @@ class OSCredsUnitTests(unittest.TestCase):
self.assertEqual(6, os_creds.image_api_version)
self.assertEqual(7, os_creds.compute_api_version)
self.assertEqual(8.0, os_creds.heat_api_version)
- self.assertIsNone(os_creds.user_domain_id)
- self.assertEqual('default', os_creds.user_domain_name)
- self.assertIsNone(os_creds.project_domain_id)
- self.assertEqual('default', os_creds.project_domain_name)
+ self.assertEqual('default', os_creds.user_domain_id)
+ self.assertEqual('Default', os_creds.user_domain_name)
+ self.assertEqual('default', os_creds.project_domain_id)
+ self.assertEqual('Default', os_creds.project_domain_name)
self.assertEqual('admin', os_creds.interface)
self.assertTrue(os_creds.cacert)
self.assertIsNone(os_creds.proxy_settings)
@@ -226,10 +226,10 @@ class OSCredsUnitTests(unittest.TestCase):
self.assertEqual(6, os_creds.image_api_version)
self.assertEqual(7, os_creds.compute_api_version)
self.assertEqual(8.0, os_creds.heat_api_version)
- self.assertIsNone(os_creds.user_domain_id)
- self.assertEqual('default', os_creds.user_domain_name)
- self.assertIsNone(os_creds.project_domain_id)
- self.assertEqual('default', os_creds.project_domain_name)
+ self.assertEqual('default', os_creds.user_domain_id)
+ self.assertEqual('Default', os_creds.user_domain_name)
+ self.assertEqual('default', os_creds.project_domain_id)
+ self.assertEqual('Default', os_creds.project_domain_name)
self.assertEqual('admin', os_creds.interface)
self.assertTrue(os_creds.cacert)
self.assertIsNone(os_creds.proxy_settings)
@@ -248,10 +248,10 @@ class OSCredsUnitTests(unittest.TestCase):
self.assertEqual(2, os_creds.image_api_version)
self.assertEqual(2, os_creds.compute_api_version)
self.assertEqual(1, os_creds.heat_api_version)
- self.assertIsNone(os_creds.user_domain_id)
- self.assertEqual('default', os_creds.user_domain_name)
- self.assertIsNone(os_creds.project_domain_id)
- self.assertEqual('default', os_creds.project_domain_name)
+ self.assertEqual('default', os_creds.user_domain_id)
+ self.assertEqual('Default', os_creds.user_domain_name)
+ self.assertEqual('default', os_creds.project_domain_id)
+ self.assertEqual('Default', os_creds.project_domain_name)
self.assertEqual('admin', os_creds.interface)
self.assertFalse(os_creds.cacert)
self.assertEqual('foo', os_creds.proxy_settings.host)
@@ -325,10 +325,10 @@ class OSCredsUnitTests(unittest.TestCase):
self.assertEqual(2, os_creds.image_api_version)
self.assertEqual(2, os_creds.compute_api_version)
self.assertEqual(1, os_creds.heat_api_version)
- self.assertIsNone(os_creds.user_domain_id)
- self.assertEqual('default', os_creds.user_domain_name)
- self.assertIsNone(os_creds.project_domain_id)
- self.assertEqual('default', os_creds.project_domain_name)
+ self.assertEqual('default', os_creds.user_domain_id)
+ self.assertEqual('Default', os_creds.user_domain_name)
+ self.assertEqual('default', os_creds.project_domain_id)
+ self.assertEqual('Default', os_creds.project_domain_name)
self.assertEqual('admin', os_creds.interface)
self.assertFalse(os_creds.cacert)
self.assertEqual('foo', os_creds.proxy_settings.host)
diff --git a/snaps/openstack/tests/create_project_tests.py b/snaps/openstack/tests/create_project_tests.py
index 96d71f2..b225e3d 100644
--- a/snaps/openstack/tests/create_project_tests.py
+++ b/snaps/openstack/tests/create_project_tests.py
@@ -45,14 +45,14 @@ class ProjectSettingsUnitTests(unittest.TestCase):
def test_name_only(self):
settings = ProjectSettings(name='foo')
self.assertEqual('foo', settings.name)
- self.assertEqual('default', settings.domain)
+ self.assertEqual('Default', settings.domain_name)
self.assertIsNone(settings.description)
self.assertTrue(settings.enabled)
def test_config_with_name_only(self):
settings = ProjectSettings(**{'name': 'foo'})
self.assertEqual('foo', settings.name)
- self.assertEqual('default', settings.domain)
+ self.assertEqual('Default', settings.domain_name)
self.assertIsNone(settings.description)
self.assertTrue(settings.enabled)
@@ -60,7 +60,7 @@ class ProjectSettingsUnitTests(unittest.TestCase):
settings = ProjectSettings(name='foo', domain='bar',
description='foobar', enabled=False)
self.assertEqual('foo', settings.name)
- self.assertEqual('bar', settings.domain)
+ self.assertEqual('bar', settings.domain_name)
self.assertEqual('foobar', settings.description)
self.assertFalse(settings.enabled)
@@ -69,7 +69,7 @@ class ProjectSettingsUnitTests(unittest.TestCase):
**{'name': 'foo', 'domain': 'bar', 'description': 'foobar',
'enabled': False})
self.assertEqual('foo', settings.name)
- self.assertEqual('bar', settings.domain)
+ self.assertEqual('bar', settings.domain_name)
self.assertEqual('foobar', settings.description)
self.assertFalse(settings.enabled)
@@ -86,7 +86,9 @@ class CreateProjectSuccessTests(OSComponentTestCase):
"""
guid = str(uuid.uuid4())[:-19]
guid = self.__class__.__name__ + '-' + guid
- self.project_settings = ProjectSettings(name=guid + '-name')
+ self.project_settings = ProjectSettings(
+ name=guid + '-name',
+ domain=self.os_creds.project_domain_name)
self.keystone = keystone_utils.keystone_client(self.os_creds)
@@ -106,7 +108,7 @@ class CreateProjectSuccessTests(OSComponentTestCase):
value. This test will not do anything with a keystone v2.0 client.
"""
if self.keystone.version != keystone_utils.V2_VERSION_STR:
- self.project_settings.domain = 'foo'
+ self.project_settings.domain_name = 'foo'
self.project_creator = OpenStackProject(self.os_creds,
self.project_settings)
@@ -182,7 +184,9 @@ class CreateProjectUserTests(OSComponentTestCase):
"""
guid = str(uuid.uuid4())[:-19]
self.guid = self.__class__.__name__ + '-' + guid
- self.project_settings = ProjectSettings(name=self.guid + '-name')
+ self.project_settings = ProjectSettings(
+ name=self.guid + '-name',
+ domain=self.os_creds.project_domain_name)
self.keystone = keystone_utils.keystone_client(self.os_creds)
@@ -218,7 +222,8 @@ class CreateProjectUserTests(OSComponentTestCase):
user_creator = OpenStackUser(
self.os_creds, UserSettings(
name=self.guid + '-user',
- password=self.guid, roles={'admin': 'admin'}))
+ password=self.guid, roles={'admin': 'admin'},
+ domain_name=self.os_creds.user_domain_name))
self.project_creator.assoc_user(user_creator.create())
self.user_creators.append(user_creator)
@@ -247,14 +252,16 @@ class CreateProjectUserTests(OSComponentTestCase):
user_creator_1 = OpenStackUser(
self.os_creds, UserSettings(
name=self.guid + '-user1', password=self.guid,
- roles={'admin': 'admin'}))
+ roles={'admin': 'admin'},
+ domain_name=self.os_creds.user_domain_name))
self.project_creator.assoc_user(user_creator_1.create())
self.user_creators.append(user_creator_1)
user_creator_2 = OpenStackUser(
self.os_creds, UserSettings(
name=self.guid + '-user2', password=self.guid,
- roles={'admin': 'admin'}))
+ roles={'admin': 'admin'},
+ domain_name=self.os_creds.user_domain_name))
self.project_creator.assoc_user(user_creator_2.create())
self.user_creators.append(user_creator_2)
@@ -288,5 +295,6 @@ def validate_project(keystone, project_settings, project):
if keystone.version == keystone_utils.V2_VERSION_STR:
return project_settings.name == project.name
else:
+ domain = keystone_utils.get_domain_by_id(keystone, project.domain_id)
return (project_settings.name == project.name and
- project_settings.domain == project.domain_id)
+ project_settings.domain_name == domain.name)
diff --git a/snaps/openstack/tests/create_user_tests.py b/snaps/openstack/tests/create_user_tests.py
index 7519700..9f08a32 100644
--- a/snaps/openstack/tests/create_user_tests.py
+++ b/snaps/openstack/tests/create_user_tests.py
@@ -102,9 +102,11 @@ class CreateUserSuccessTests(OSComponentTestCase):
"""
guid = str(uuid.uuid4())[:-19]
guid = self.__class__.__name__ + '-' + guid
- self.user_settings = UserSettings(name=guid + '-name',
- password=guid + '-password',
- roles={'admin': 'admin'})
+ self.user_settings = UserSettings(
+ name=guid + '-name',
+ password=guid + '-password',
+ roles={'admin': 'admin'},
+ domain_name=self.os_creds.user_domain_name)
self.keystone = keystone_utils.keystone_client(self.os_creds)
diff --git a/snaps/openstack/tests/openstack_tests.py b/snaps/openstack/tests/openstack_tests.py
index 71d2dc2..9c53bbd 100644
--- a/snaps/openstack/tests/openstack_tests.py
+++ b/snaps/openstack/tests/openstack_tests.py
@@ -126,7 +126,9 @@ def get_credentials(os_env_file=None, proxy_settings_str=None,
'compute_api_version': config.get('compute_api_version'),
'heat_api_version': config.get('heat_api_version'),
'user_domain_id': config.get('user_domain_id'),
+ 'user_domain_name': config.get('user_domain_name'),
'project_domain_id': config.get('project_domain_id'),
+ 'project_domain_name': config.get('project_domain_name'),
'interface': config.get('interface'),
'proxy_settings': proxy_settings,
'cacert': config.get('cacert'),
diff --git a/snaps/openstack/utils/keystone_utils.py b/snaps/openstack/utils/keystone_utils.py
index 99779ee..10ad68a 100644
--- a/snaps/openstack/utils/keystone_utils.py
+++ b/snaps/openstack/utils/keystone_utils.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2016 Cable Television Laboratories, Inc. ("CableLabs")
+# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
# and others. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,7 @@ from keystoneauth1.identity import v3, v2
from keystoneauth1 import session
import requests
-from snaps.domain.project import Project
+from snaps.domain.project import Project, Domain
from snaps.domain.role import Role
from snaps.domain.user import User
@@ -129,7 +129,7 @@ def get_project(keystone=None, os_creds=None, project_settings=None,
elif project_settings:
proj_filter['name'] = project_settings.name
proj_filter['description'] = project_settings.description
- proj_filter['domain'] = project_settings.domain
+ proj_filter['domain_name'] = project_settings.domain_name
proj_filter['enabled'] = project_settings.enabled
if keystone.version == V2_VERSION_STR:
@@ -161,8 +161,12 @@ def create_project(keystone, project_settings):
project_settings.name, project_settings.description,
project_settings.enabled)
else:
+ os_domain = __get_os_domain_by_name(
+ keystone, project_settings.domain_name)
+ if not os_domain:
+ os_domain = project_settings.domain_name
os_project = keystone.projects.create(
- project_settings.name, project_settings.domain,
+ project_settings.name, os_domain,
description=project_settings.description,
enabled=project_settings.enabled)
domain_id = os_project.domain_id
@@ -238,18 +242,21 @@ def create_user(keystone, user_settings):
email=user_settings.email, tenant_id=project_id,
enabled=user_settings.enabled)
else:
+ os_domain = __get_os_domain_by_name(
+ keystone, user_settings.domain_name)
+ if not os_domain:
+ os_domain = user_settings.domain_name
os_user = keystone.users.create(
name=user_settings.name, password=user_settings.password,
email=user_settings.email, project=project,
- domain=user_settings.domain_name, enabled=user_settings.enabled)
+ domain=os_domain, enabled=user_settings.enabled)
for role_name, role_project in user_settings.roles.items():
os_role = get_role_by_name(keystone, role_name)
os_project = get_project(keystone=keystone, project_name=role_project)
if os_role and os_project:
- existing_roles = get_roles_by_user(keystone, os_user,
- os_project)
+ existing_roles = get_roles_by_user(keystone, os_user, os_project)
found = False
for role in existing_roles:
if role.id == os_role.id:
@@ -355,6 +362,31 @@ def grant_user_role_to_project(keystone, role, user, project):
keystone.roles.grant(os_role, user=user, project=project)
+def get_domain_by_id(keystone, domain_id):
+ """
+ Returns the first OpenStack domain with the given name else None
+ :param keystone: the Keystone client
+ :param domain_id: the domain ID to retrieve
+ :return: the SNAPS-OO Domain domain object
+ """
+ domain = keystone.domains.get(domain_id)
+ if domain:
+ return Domain(name=domain.name, domain_id=domain.id)
+
+
+def __get_os_domain_by_name(keystone, domain_name):
+ """
+ Returns the first OpenStack domain with the given name else None
+ :param keystone: the Keystone client
+ :param domain_name: the domain name to lookup
+ :return: the OpenStack domain object
+ """
+ domains = keystone.domains.list(name=domain_name)
+ for domain in domains:
+ if domain.name == domain_name:
+ return domain
+
+
class KeystoneException(Exception):
"""
Exception when calls to the Keystone client cannot be served properly
diff --git a/snaps/openstack/utils/tests/keystone_utils_tests.py b/snaps/openstack/utils/tests/keystone_utils_tests.py
index 3aa275d..a46cbd1 100644
--- a/snaps/openstack/utils/tests/keystone_utils_tests.py
+++ b/snaps/openstack/utils/tests/keystone_utils_tests.py
@@ -85,8 +85,10 @@ class KeystoneUtilsTests(OSComponentTestCase):
"""
Tests the keystone_utils.create_user() function
"""
- user_settings = UserSettings(name=self.username,
- password=str(uuid.uuid4()))
+ user_settings = UserSettings(
+ name=self.username,
+ password=str(uuid.uuid4()),
+ domain_name=self.os_creds.user_domain_name)
self.user = keystone_utils.create_user(self.keystone, user_settings)
self.assertEqual(self.username, self.user.name)
@@ -98,7 +100,8 @@ class KeystoneUtilsTests(OSComponentTestCase):
"""
Tests the keyston_utils.create_project() funtion
"""
- project_settings = ProjectSettings(name=self.project_name)
+ project_settings = ProjectSettings(
+ name=self.project_name, domain=self.os_creds.project_domain_name)
self.project = keystone_utils.create_project(self.keystone,
project_settings)
self.assertEqual(self.project_name, self.project.name)
@@ -108,6 +111,11 @@ class KeystoneUtilsTests(OSComponentTestCase):
self.assertIsNotNone(project)
self.assertEqual(self.project_name, self.project.name)
+ domain = keystone_utils.get_domain_by_id(
+ self.keystone, project.domain_id)
+ self.assertIsNotNone(domain)
+ self.assertEqual(domain.id, project.domain_id)
+
def test_get_endpoint_success(self):
"""
Tests to ensure that proper credentials and proper service type can
@@ -161,12 +169,14 @@ class KeystoneUtilsTests(OSComponentTestCase):
Tests the keystone_utils function grant_user_role_to_project()
:return:
"""
- user_settings = UserSettings(name=self.username,
- password=str(uuid.uuid4()))
+ user_settings = UserSettings(
+ name=self.username, password=str(uuid.uuid4()),
+ domain_name=self.os_creds.user_domain_name)
self.user = keystone_utils.create_user(self.keystone, user_settings)
self.assertEqual(self.username, self.user.name)
- project_settings = ProjectSettings(name=self.project_name)
+ project_settings = ProjectSettings(
+ name=self.project_name, domain=self.os_creds.project_domain_name)
self.project = keystone_utils.create_project(self.keystone,
project_settings)
self.assertEqual(self.project_name, self.project.name)
diff --git a/snaps/test_suite_builder.py b/snaps/test_suite_builder.py
index 24c3e65..cf99a5f 100644
--- a/snaps/test_suite_builder.py
+++ b/snaps/test_suite_builder.py
@@ -23,7 +23,8 @@ from snaps.domain.test.network_tests import (
SecurityGroupDomainObjectTests, SecurityGroupRuleDomainObjectTests,
PortDomainObjectTests, RouterDomainObjectTests,
InterfaceRouterDomainObjectTests, NetworkObjectTests, SubnetObjectTests)
-from snaps.domain.test.project_tests import ProjectDomainObjectTests
+from snaps.domain.test.project_tests import (
+ ProjectDomainObjectTests, DomainDomainObjectTests)
from snaps.domain.test.role_tests import RoleDomainObjectTests
from snaps.domain.test.stack_tests import StackDomainObjectTests
from snaps.domain.test.user_tests import UserDomainObjectTests
@@ -123,6 +124,8 @@ def add_unit_tests(suite):
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
ProjectDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
+ DomainDomainObjectTests))
+ suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
RoleDomainObjectTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
NetworkSettingsUnitTests))
@@ -324,7 +327,8 @@ def add_openstack_integration_tests(suite, os_creds, ext_net_name,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))
suite.addTest(OSIntegrationTestCase.parameterize(
- CreateKeypairsCleanupTests, os_creds=os_creds, ext_net_name=ext_net_name,
+ CreateKeypairsCleanupTests, os_creds=os_creds,
+ ext_net_name=ext_net_name,
use_keystone=use_keystone,
flavor_metadata=flavor_metadata, image_metadata=image_metadata,
log_level=log_level))