Specifying project-domain for project
The fix ensures that if a user wants to set a default project,
they must also provide the project domain. If it's missing,
an explicit error message is shown, making it clear that the
project domain is required.
Also adding some unit tests by modifying respective calls.
Change-Id: Ia6e921a53da55ab1bce85a42c8160872a9d47d64
Closes-Bug: #2102146
(cherry picked from commit 2883f3fb95
)
This commit is contained in:

committed by
Stephen Finucane

parent
aeb6bbc0ed
commit
80a4b58281
@@ -612,10 +612,12 @@ class SetUser(command.Command):
|
||||
if parsed_args.description:
|
||||
kwargs['description'] = parsed_args.description
|
||||
if parsed_args.project:
|
||||
project_domain_id = identity_client.find_domain(
|
||||
name_or_id=parsed_args.project_domain,
|
||||
ignore_missing=False,
|
||||
).id
|
||||
project_domain_id = None
|
||||
if parsed_args.project_domain:
|
||||
project_domain_id = identity_client.find_domain(
|
||||
name_or_id=parsed_args.project_domain,
|
||||
ignore_missing=False,
|
||||
).id
|
||||
project_id = identity_client.find_project(
|
||||
name_or_id=parsed_args.project,
|
||||
ignore_missing=False,
|
||||
|
@@ -1206,6 +1206,17 @@ class TestUserSet(identity_fakes.TestIdentityv3):
|
||||
self.identity_sdk_client.update_user.assert_called_with(
|
||||
user=self.user, **kwargs
|
||||
)
|
||||
self.identity_sdk_client.find_domain.assert_not_called()
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'ignore_missing': False,
|
||||
'domain_id': None,
|
||||
}
|
||||
self.identity_sdk_client.find_project.assert_called_once_with(
|
||||
name_or_id=self.project.id, **kwargs
|
||||
)
|
||||
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_user_set_project_domain(self):
|
||||
@@ -1238,6 +1249,11 @@ class TestUserSet(identity_fakes.TestIdentityv3):
|
||||
self.identity_sdk_client.update_user.assert_called_with(
|
||||
user=self.user, **kwargs
|
||||
)
|
||||
|
||||
self.identity_sdk_client.find_domain.assert_called_once_with(
|
||||
name_or_id=self.project.domain_id, ignore_missing=False
|
||||
)
|
||||
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_user_set_enable(self):
|
||||
|
Reference in New Issue
Block a user