Fix oslo policy warning assert in unit tests
oslo.policy 3.10(below commit) changed the warning text to log the complete rule with check_str. - https://review.opendev.org/c/openstack/oslo.policy/+/812469 With that keystone unit test failing in requirement patch updating the oslo.policy constraint to 3.10 - https://review.opendev.org/c/openstack/requirements/+/815820 Fix the unit tests so that it work with both version of oslo.policy. Change-Id: Ibb9ae5ca0894866c920ce6cfe99fb02adfcf6f8f
This commit is contained in:
parent
8d18270863
commit
1154b5fd3c
|
@ -151,14 +151,16 @@ class PolicyScopeTypesEnforcementTestCase(unit.TestCase):
|
|||
def test_warning_message_is_logged_if_enforce_scope_is_false(self):
|
||||
self.config_fixture.config(group='oslo_policy', enforce_scope=False)
|
||||
expected_msg = (
|
||||
'Policy foo failed scope check. The token used to make the '
|
||||
'failed scope check. The token used to make the '
|
||||
'request was project scoped but the policy requires [\'system\'] '
|
||||
'scope. This behavior may change in the future where using the '
|
||||
'intended scope is required'
|
||||
)
|
||||
with mock.patch('warnings.warn') as mock_warn:
|
||||
policy.enforce(self.credentials, self.action, self.target)
|
||||
mock_warn.assert_called_with(expected_msg)
|
||||
mock_warn.assert_called_once()
|
||||
warn_msg = mock_warn.call_args[0][0]
|
||||
self.assertIn(expected_msg, warn_msg)
|
||||
|
||||
|
||||
class PolicyJsonTestCase(unit.TestCase):
|
||||
|
|
Loading…
Reference in New Issue