diff options
| author | Sławek Kapłoński <slawek@kaplonski.pl> | 2018-05-10 17:16:48 +0200 |
|---|---|---|
| committer | Slawek Kaplonski <skaplons@redhat.com> | 2018-05-25 19:45:13 +0000 |
| commit | 8db3933feb35f91f3ff3d121c155286973c66122 (patch) | |
| tree | a7a220a38f0e1176fa8a9aa27a7c5d0c5be08d97 /openstackclient/tests/unit/network | |
| parent | f7e4d31820e797e0d374e7dfde1142373245ea87 (diff) | |
| download | python-openstackclient-8db3933feb35f91f3ff3d121c155286973c66122.tar.gz | |
Don't display router's is_ha and is_distributed attributes always
In case when is_ha or is_distributed attribute of Neutron's router is
set to None, it means that it wasn't returned from server and should
not be displayed.
Otherwise it might be confusing for user is making
openstack router show <router_name>
call as an admin will return e.g. is_ha=True but same call done as
regular user will return False or None.
It might happen like that because returning of those attributes is
forbidden for regular users in Neutron's policy.json
Depends-On: https://review.openstack.org/567606/
Change-Id: I626b5193d9ecb308baad7b27939f9673c32b4182
Closes-Bug: #1689510
Task: 19789
Story: 2002110
Diffstat (limited to 'openstackclient/tests/unit/network')
| -rw-r--r-- | openstackclient/tests/unit/network/v2/test_router.py | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/openstackclient/tests/unit/network/v2/test_router.py b/openstackclient/tests/unit/network/v2/test_router.py index f383c1dd..7a7bcf90 100644 --- a/openstackclient/tests/unit/network/v2/test_router.py +++ b/openstackclient/tests/unit/network/v2/test_router.py @@ -400,9 +400,9 @@ class TestListRouter(TestRouter): 'Name', 'Status', 'State', + 'Project', 'Distributed', 'HA', - 'Project', ) columns_long = columns + ( 'Routes', @@ -423,9 +423,9 @@ class TestListRouter(TestRouter): r.name, r.status, router._format_admin_state(r.admin_state_up), + r.tenant_id, r.distributed, r.ha, - r.tenant_id, )) router_agent_data = [] @@ -496,6 +496,25 @@ class TestListRouter(TestRouter): self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) + def test_router_list_no_ha_no_distributed(self): + _routers = network_fakes.FakeRouter.create_routers({ + 'ha': None, + 'distributed': None}, + count=3) + + arglist = [] + verifylist = [ + ('long', False), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + with mock.patch.object( + self.network, "routers", return_value=_routers): + columns, data = self.cmd.take_action(parsed_args) + + self.assertNotIn("is_distributed", columns) + self.assertNotIn("is_ha", columns) + def test_router_list_long(self): arglist = [ '--long', @@ -1196,6 +1215,26 @@ class TestShowRouter(TestRouter): self.assertEqual(self.columns, columns) self.assertEqual(self.data, data) + def test_show_no_ha_no_distributed(self): + _router = network_fakes.FakeRouter.create_one_router({ + 'ha': None, + 'distributed': None}) + + arglist = [ + _router.name, + ] + verifylist = [ + ('router', _router.name), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + with mock.patch.object( + self.network, "find_router", return_value=_router): + columns, data = self.cmd.take_action(parsed_args) + + self.assertNotIn("is_distributed", columns) + self.assertNotIn("is_ha", columns) + class TestUnsetRouter(TestRouter): |
