From 3a05a1df615e0ae8ce0461dbcabcb763ebbe32bc Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Mon, 14 Dec 2015 14:54:42 +0100 Subject: [PATCH] rbac: add some backport compat tests The old rbac wasn't really works only the segregration was applied. Even it's fixed now the legacy policy.json should continue to works. Related-bug: #1504495 Conflicts: aodh/tests/functional/api/v2/test_alarm_scenarios.py Change-Id: I050b2245d78780cb49b47b317a1a245b8e0a58eb (cherry picked from commit 4101ab5d9f423c7a5ecdd1a090919db2bf174886) --- .../functional/api/v2/test_alarm_scenarios.py | 28 +++++++++++++++++++ aodh/tests/policy.json-pre-mikita | 5 ++++ 2 files changed, 33 insertions(+) create mode 100644 aodh/tests/policy.json-pre-mikita diff --git a/aodh/tests/functional/api/v2/test_alarm_scenarios.py b/aodh/tests/functional/api/v2/test_alarm_scenarios.py index 7770249f0..a3e8c892f 100644 --- a/aodh/tests/functional/api/v2/test_alarm_scenarios.py +++ b/aodh/tests/functional/api/v2/test_alarm_scenarios.py @@ -139,6 +139,16 @@ def default_alarms(auth_headers): ] +class LegacyPolicyFileMixin(object): + def setUp(self): + super(LegacyPolicyFileMixin, self).setUp() + self.CONF.set_override( + 'policy_file', + os.path.abspath('aodh/tests/policy.json-pre-mikita'), + group='oslo_policy') + self.app = self._make_app() + + class TestAlarmsBase(v2.FunctionalTest, tests_db.MixinTestsWithBackendScenarios): @@ -1697,6 +1707,10 @@ class TestAlarms(TestAlarmsBase): 'user_id']).issubset(payload.keys())) +class TestAlarmsLegacy(LegacyPolicyFileMixin, TestAlarms): + pass + + class TestAlarmsHistory(TestAlarmsBase): def setUp(self): @@ -2052,6 +2066,10 @@ class TestAlarmsHistory(TestAlarmsBase): self.assertEqual([], history) +class TestAlarmsHistoryLegacy(LegacyPolicyFileMixin, TestAlarmsHistory): + pass + + class TestAlarmsQuotas(TestAlarmsBase): def _test_alarm_quota(self): @@ -2737,6 +2755,11 @@ class TestAlarmsRuleCombination(TestAlarmsBase): self.assertEqual(['c', 'a', 'b'], alarms[0].rule.get('alarm_ids')) +class TestAlarmsRuleCombinationLegacy(LegacyPolicyFileMixin, + TestAlarmsRuleCombination): + pass + + class TestAlarmsRuleGnocchi(TestAlarmsBase): def setUp(self): @@ -2999,6 +3022,11 @@ class TestAlarmsRuleGnocchi(TestAlarmsBase): self._verify_alarm(json, alarms[0]) +class TestAlarmsRuleGnocchiLegacy(LegacyPolicyFileMixin, + TestAlarmsRuleGnocchi): + pass + + class TestAlarmsEvent(TestAlarmsBase): def test_list_alarms(self): diff --git a/aodh/tests/policy.json-pre-mikita b/aodh/tests/policy.json-pre-mikita new file mode 100644 index 000000000..8f0602afb --- /dev/null +++ b/aodh/tests/policy.json-pre-mikita @@ -0,0 +1,5 @@ +{ + "context_is_admin": "role:admin", + "segregation": "rule:context_is_admin", + "default": "" +}