Skip to content

Commit 830f033

Browse files
committed
[S-RBAC] Fix policies for the l3_conntrack_helpers APIs
This patch updates l3_conntrack_helpers API policies so that POST, PUT and DELETE actions are allowed for the PARENT_OWNER_MEMBER role and GET is allowed for the PARENT_OWNER_READER. Additionally this patch fixes unit tests for the api policies for that APIs so that owner check is done during unit tests and issues like the one mentioned above can be catched by unit tests. Closes-bug: #2125660 Change-Id: I1dc6eabbb666e5923d9c18465d10cdf95e472915 Signed-off-by: Slawek Kaplonski <[email protected]> (cherry picked from commit cb3331e)
1 parent 5a96fc1 commit 830f033

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

neutron/conf/policies/l3_conntrack_helper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
name='create_router_conntrack_helper',
3333
check_str=neutron_policy.policy_or(
3434
base.ADMIN_OR_PROJECT_MEMBER,
35-
base.RULE_PARENT_OWNER),
35+
base.PARENT_OWNER_MEMBER),
3636
scope_types=['project'],
3737
description='Create a router conntrack helper',
3838
operations=[
@@ -51,7 +51,7 @@
5151
name='get_router_conntrack_helper',
5252
check_str=neutron_policy.policy_or(
5353
base.ADMIN_OR_PROJECT_READER,
54-
base.RULE_PARENT_OWNER),
54+
base.PARENT_OWNER_READER),
5555
scope_types=['project'],
5656
description='Get a router conntrack helper',
5757
operations=[
@@ -74,7 +74,7 @@
7474
name='update_router_conntrack_helper',
7575
check_str=neutron_policy.policy_or(
7676
base.ADMIN_OR_PROJECT_MEMBER,
77-
base.RULE_PARENT_OWNER),
77+
base.PARENT_OWNER_MEMBER),
7878
scope_types=['project'],
7979
description='Update a router conntrack helper',
8080
operations=[
@@ -93,7 +93,7 @@
9393
name='delete_router_conntrack_helper',
9494
check_str=neutron_policy.policy_or(
9595
base.ADMIN_OR_PROJECT_MEMBER,
96-
base.RULE_PARENT_OWNER),
96+
base.PARENT_OWNER_MEMBER),
9797
scope_types=['project'],
9898
description='Delete a router conntrack helper',
9999
operations=[

neutron/tests/unit/conf/policies/test_l3_conntrack_helper.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,29 @@ def setUp(self):
2929
self.router = {
3030
'id': uuidutils.generate_uuid(),
3131
'project_id': self.project_id}
32+
self.alt_router = {
33+
'id': uuidutils.generate_uuid(),
34+
'project_id': self.alt_project_id}
35+
3236
self.target = {
3337
'project_id': self.project_id,
3438
'router_id': self.router['id'],
3539
'ext_parent_router_id': self.router['id']}
36-
3740
self.alt_target = {
3841
'project_id': self.alt_project_id,
39-
'router_id': self.router['id'],
40-
'ext_parent_router_id': self.router['id']}
42+
'router_id': self.alt_router['id'],
43+
'ext_parent_router_id': self.alt_router['id']}
44+
45+
routers = {
46+
self.router['id']: self.router,
47+
self.alt_router['id']: self.alt_router,
48+
}
49+
50+
def get_router(context, router_id, fields=None):
51+
return routers[router_id]
4152

4253
self.plugin_mock = mock.Mock()
43-
self.plugin_mock.get_router.return_value = self.router
54+
self.plugin_mock.get_router.side_effect = get_router
4455
mock.patch(
4556
'neutron_lib.plugins.directory.get_plugin',
4657
return_value=self.plugin_mock).start()

0 commit comments

Comments
 (0)