From 6f87111a924cc04e7782c767ecaa3eb7fc019cde Mon Sep 17 00:00:00 2001 From: Ghanshyam Mann Date: Tue, 30 Nov 2021 12:37:13 -0600 Subject: [PATCH] Explicitly check policy name in policy warning tests This commit makes keystone tests for oslo policy warning to check policy name explicitly. oslo policy 3.10 modified the warning text to include the policy name as well as the check-str so new warning message verified in keystone test will not work on old oslo policy (<3.10), so bumping the oslo.policy in requirements.txt Change-Id: I14132dfced48ddc93c29ce2b4c20ed2cabc1dbd6 --- keystone/tests/unit/test_policy.py | 6 ++---- lower-constraints.txt | 2 +- requirements.txt | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/keystone/tests/unit/test_policy.py b/keystone/tests/unit/test_policy.py index 8f009768e8..e04d89096f 100644 --- a/keystone/tests/unit/test_policy.py +++ b/keystone/tests/unit/test_policy.py @@ -151,16 +151,14 @@ 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 = ( - 'failed scope check. The token used to make the ' + 'Policy "foo": "" 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_once() - warn_msg = mock_warn.call_args[0][0] - self.assertIn(expected_msg, warn_msg) + mock_warn.assert_called_with(expected_msg) class PolicyJsonTestCase(unit.TestCase): diff --git a/lower-constraints.txt b/lower-constraints.txt index 3ceae8a1da..71f497fbd2 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -32,7 +32,7 @@ oslo.i18n==3.15.3 oslo.log==3.44.0 oslo.messaging==5.29.0 oslo.middleware==3.31.0 -oslo.policy==3.7.0 +oslo.policy==3.10.0 oslo.serialization==2.18.0 oslo.upgradecheck==1.3.0 oslo.utils==3.33.0 diff --git a/requirements.txt b/requirements.txt index f77c246652..c7e4605f33 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ oslo.db>=6.0.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 oslo.log>=3.44.0 # Apache-2.0 oslo.middleware>=3.31.0 # Apache-2.0 -oslo.policy>=3.7.0 # Apache-2.0 +oslo.policy>=3.10.0 # Apache-2.0 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 oslo.upgradecheck>=1.3.0 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0