summaryrefslogtreecommitdiff
path: root/oslo_policy
diff options
context:
space:
mode:
authorBen Nemec <bnemec@redhat.com>2021-02-25 21:09:11 +0000
committerBen Nemec <bnemec@redhat.com>2021-02-26 00:04:50 +0000
commit56e903dfb6ca5ede9ba6b4bd4cfcc3415bf7a170 (patch)
treefb51becdace4cdd020eb096ab3d630cf640b48ab /oslo_policy
parentd8534850d9238e85ae0ea55bf2ac8583681fdb2b (diff)
downloadoslo-policy-56e903dfb6ca5ede9ba6b4bd4cfcc3415bf7a170.tar.gz
Reinstate double deprecation test logic
This was lost in a previous change, but in the interest of not holding up the merge of the functional part of it I'm fixing the test in this followup. The new version of the test verifies that the rule isn't overwritten by a second call to load_rules, which is what would happen if we called the deprecation handler again. Change-Id: Idc9dd353463da63a2108782f7b141d1d8014d180
Diffstat (limited to 'oslo_policy')
-rw-r--r--oslo_policy/tests/test_policy.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/oslo_policy/tests/test_policy.py b/oslo_policy/tests/test_policy.py
index 0a8bab5..d5c86c3 100644
--- a/oslo_policy/tests/test_policy.py
+++ b/oslo_policy/tests/test_policy.py
@@ -1802,6 +1802,12 @@ class DocumentedRuleDefaultDeprecationTestCase(base.PolicyBaseTestCase):
self.assertEqual(
str(enforcer.rules['foo:create_bar']), str(expected_check))
self.assertEqual(check, rule.check)
+ # Hacky way to check whether _handle_deprecated_rule was called again.
+ # If a second call to load_rules doesn't overwrite our dummy rule then
+ # we know it didn't call the deprecated rule function again.
+ enforcer.rules['foo:create_bar'] = 'foo:bar'
+ enforcer.load_rules()
+ self.assertEqual('foo:bar', enforcer.rules['foo:create_bar'])
class DocumentedRuleDefaultTestCase(base.PolicyBaseTestCase):