Migrate to override_role for network metering tests
Now that override_role has supplanted switch_role (which has
been deprecated) in [0], the RBAC tests need to switch to use
override_role.
This PS switches to override_role for the network test
test_metering_label_rules_rbac.
[0] I670fba358bf321eae0d22d18cea6d2f530f00716
Partially Implements: blueprint rbac-utils-contextmanager
Change-Id: I84177b1c9384be54ae62203118ee80eea11f24a8
diff --git a/patrole_tempest_plugin/tests/api/network/test_metering_label_rules_rbac.py b/patrole_tempest_plugin/tests/api/network/test_metering_label_rules_rbac.py
index 5ffc966..7a9d814 100644
--- a/patrole_tempest_plugin/tests/api/network/test_metering_label_rules_rbac.py
+++ b/patrole_tempest_plugin/tests/api/network/test_metering_label_rules_rbac.py
@@ -70,8 +70,8 @@
RBAC test for the neutron create_metering_label_rule policy
"""
- self.rbac_utils.switch_role(self, toggle_rbac_role=True)
- self._create_metering_label_rule(self.label)
+ with self.rbac_utils.override_role(self):
+ self._create_metering_label_rule(self.label)
@rbac_rule_validation.action(service="neutron",
rule="get_metering_label_rule",
@@ -83,9 +83,9 @@
RBAC test for the neutron get_metering_label_rule policy
"""
label_rule = self._create_metering_label_rule(self.label)
- self.rbac_utils.switch_role(self, toggle_rbac_role=True)
- self.metering_label_rules_client.show_metering_label_rule(
- label_rule['id'])
+ with self.rbac_utils.override_role(self):
+ self.metering_label_rules_client.show_metering_label_rule(
+ label_rule['id'])
@rbac_rule_validation.action(service="neutron",
rule="delete_metering_label_rule",
@@ -97,6 +97,6 @@
RBAC test for the neutron delete_metering_label_rule policy
"""
label_rule = self._create_metering_label_rule(self.label)
- self.rbac_utils.switch_role(self, toggle_rbac_role=True)
- self.metering_label_rules_client.delete_metering_label_rule(
- label_rule['id'])
+ with self.rbac_utils.override_role(self):
+ self.metering_label_rules_client.delete_metering_label_rule(
+ label_rule['id'])