diff options
author | Julie Pichon <jpichon@redhat.com> | 2018-10-09 11:37:22 +0100 |
---|---|---|
committer | Julie Pichon <jpichon@redhat.com> | 2018-10-15 09:31:12 +0000 |
commit | cda854c6775bf0a24263f83ee4e350fc43fa7fed (patch) | |
tree | b0a942ba4072cf08d980dd9d8d21e288ba770be7 | |
parent | a12cee60c745b6eabb7c791eafd7c9adad0a916e (diff) | |
download | python-openstackclient-cda854c6775bf0a24263f83ee4e350fc43fa7fed.tar.gz |
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: 27004
Change-Id: I7340e01f509e3515f07cb46f175fb603f1ce8b67
(cherry picked from commit 91a2d888625488da3f65ad372b4248e9747b9a3e)
-rw-r--r-- | openstackclient/identity/v3/endpoint.py | 2 | ||||
-rw-r--r-- | openstackclient/tests/unit/identity/v3/test_endpoint.py | 41 |
2 files changed, 42 insertions, 1 deletions
diff --git a/openstackclient/identity/v3/endpoint.py b/openstackclient/identity/v3/endpoint.py index 3229240e..858b5036 100644 --- a/openstackclient/identity/v3/endpoint.py +++ b/openstackclient/identity/v3/endpoint.py @@ -199,7 +199,7 @@ class ListEndpoint(command.Lister): metavar='<project>', help=_('Project to list filters (name or ID)'), ) - common.add_project_domain_option_to_parser(list_group) + common.add_project_domain_option_to_parser(parser) return parser def take_action(self, parsed_args): diff --git a/openstackclient/tests/unit/identity/v3/test_endpoint.py b/openstackclient/tests/unit/identity/v3/test_endpoint.py index bfe930d6..62dcf58d 100644 --- a/openstackclient/tests/unit/identity/v3/test_endpoint.py +++ b/openstackclient/tests/unit/identity/v3/test_endpoint.py @@ -439,6 +439,47 @@ class TestEndpointList(TestEndpoint): ) self.assertEqual(datalist, tuple(data)) + def test_endpoint_list_project_with_project_domain(self): + project = identity_fakes.FakeProject.create_one_project() + domain = identity_fakes.FakeDomain.create_one_domain() + + self.ep_filter_mock.list_endpoints_for_project.return_value = [ + self.endpoint + ] + self.projects_mock.get.return_value = project + + arglist = [ + '--project', project.name, + '--project-domain', domain.name + ] + verifylist = [ + ('project', project.name), + ('project_domain', domain.name), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # In base command class Lister in cliff, abstract method take_action() + # returns a tuple containing the column names and an iterable + # containing the data to be listed. + columns, data = self.cmd.take_action(parsed_args) + self.ep_filter_mock.list_endpoints_for_project.assert_called_with( + project=project.id + ) + + self.assertEqual(self.columns, columns) + datalist = ( + ( + self.endpoint.id, + self.endpoint.region, + self.service.name, + self.service.type, + True, + self.endpoint.interface, + self.endpoint.url, + ), + ) + self.assertEqual(datalist, tuple(data)) + class TestEndpointSet(TestEndpoint): |