Skip to content

Commit 91a2d88

Browse files
committed
Allow endpoint filtering on both project and project-domain
The --project and --project-domain flags are currently mutually exclusive for listing endpoints, however the --project-domain argument is supposed to help with filtering projects with colliding names. They should be allowed together. Story: 2004018 Task: 27007 Change-Id: I7340e01f509e3515f07cb46f175fb603f1ce8b67
1 parent 4e6f47e commit 91a2d88

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

openstackclient/identity/v3/endpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def get_parser(self, prog_name):
199199
metavar='<project>',
200200
help=_('Project to list filters (name or ID)'),
201201
)
202-
common.add_project_domain_option_to_parser(list_group)
202+
common.add_project_domain_option_to_parser(parser)
203203
return parser
204204

205205
def take_action(self, parsed_args):

openstackclient/tests/unit/identity/v3/test_endpoint.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,47 @@ def test_endpoint_list_region(self):
439439
)
440440
self.assertEqual(datalist, tuple(data))
441441

442+
def test_endpoint_list_project_with_project_domain(self):
443+
project = identity_fakes.FakeProject.create_one_project()
444+
domain = identity_fakes.FakeDomain.create_one_domain()
445+
446+
self.ep_filter_mock.list_endpoints_for_project.return_value = [
447+
self.endpoint
448+
]
449+
self.projects_mock.get.return_value = project
450+
451+
arglist = [
452+
'--project', project.name,
453+
'--project-domain', domain.name
454+
]
455+
verifylist = [
456+
('project', project.name),
457+
('project_domain', domain.name),
458+
]
459+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
460+
461+
# In base command class Lister in cliff, abstract method take_action()
462+
# returns a tuple containing the column names and an iterable
463+
# containing the data to be listed.
464+
columns, data = self.cmd.take_action(parsed_args)
465+
self.ep_filter_mock.list_endpoints_for_project.assert_called_with(
466+
project=project.id
467+
)
468+
469+
self.assertEqual(self.columns, columns)
470+
datalist = (
471+
(
472+
self.endpoint.id,
473+
self.endpoint.region,
474+
self.service.name,
475+
self.service.type,
476+
True,
477+
self.endpoint.interface,
478+
self.endpoint.url,
479+
),
480+
)
481+
self.assertEqual(datalist, tuple(data))
482+
442483

443484
class TestEndpointSet(TestEndpoint):
444485

0 commit comments

Comments
 (0)