Loosen the assertion for logging scope type warnings

We have tests to make sure we raise a 403 Forbidden in the event we
catch an exception from oslo.policy due to InvalidScope. An assertion
in these tests made sure we logged a warning by checking a mock was
called exactly once.

This is going to fail when we start deprecating policies in Stein in
favor of ones that enable system scope checking. Instead of checking
that assertion is called only once, let's just make sure it is called
at least once with the arguments we expect. Otherwise we're going to
catch false positives with the assertion because deprecated policies
are also logged for operators.

Change-Id: I5da718d5b31e90f1aef7d5b457b3c772eb57d1fb
This commit is contained in:
Lance Bragstad 2018-08-28 15:30:44 +00:00
parent 9051d403a3
commit 1edcb35a40
1 changed files with 1 additions and 1 deletions

View File

@ -161,7 +161,7 @@ class PolicyScopeTypesEnforcementTestCase(unit.TestCase):
)
with mock.patch('warnings.warn') as mock_warn:
policy.enforce(self.credentials, self.action, self.target)
mock_warn.assert_called_once_with(expected_msg)
mock_warn.assert_called_with(expected_msg)
class PolicyJsonTestCase(unit.TestCase):