Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-oslo.policy for openSUSE:Factory checked in at 2021-12-12 00:57:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-oslo.policy (Old) and /work/SRC/openSUSE:Factory/.python-oslo.policy.new.2520 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-oslo.policy" Sun Dec 12 00:57:34 2021 rev:17 rq:939535 version:3.8.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-oslo.policy/python-oslo.policy.changes 2021-05-10 15:39:50.757449841 +0200 +++ /work/SRC/openSUSE:Factory/.python-oslo.policy.new.2520/python-oslo.policy.changes 2021-12-12 00:57:40.310586944 +0100 @@ -1,0 +2,21 @@ +Tue Oct 26 21:46:46 UTC 2021 - [email protected] + +- update to version 3.8.2 + - Adding tests on cache handler + - Improving documentation about target resources + - Fix a typo in the document + - Add Python3 xena unit tests + - Add debug log in pick_default_policy_file + - Changed minversion in tox to 3.18.0 + - Replace getargspec with getfullargspec + - Correctly handle IO errors at policy file load + - Use py3 as the default runtime for tox + - Add unit tests on cache handler + - Reinstate double deprecation test logic + - Move flake8 as a pre-commit local target. + - Update master for stable/wallaby + - Ussuri+ is python3 only and update python to python3 + - Dropping lower constraints testing + - setup.cfg: Replace dashes with underscores + +------------------------------------------------------------------- Old: ---- oslo.policy-3.7.0.tar.gz New: ---- oslo.policy-3.8.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-oslo.policy.spec ++++++ --- /var/tmp/diff_new_pack.EMvAEA/_old 2021-12-12 00:57:43.790589333 +0100 +++ /var/tmp/diff_new_pack.EMvAEA/_new 2021-12-12 00:57:43.790589333 +0100 @@ -17,13 +17,13 @@ Name: python-oslo.policy -Version: 3.7.0 +Version: 3.8.2 Release: 0 Summary: OpenStack Oslo Policy library License: Apache-2.0 Group: Development/Languages/Python URL: https://docs.openstack.org/oslo.policy -Source0: https://files.pythonhosted.org/packages/source/o/oslo.policy/oslo.policy-3.7.0.tar.gz +Source0: https://files.pythonhosted.org/packages/source/o/oslo.policy/oslo.policy-3.8.2.tar.gz BuildRequires: openstack-macros BuildRequires: python3-PyYAML >= 5.1 BuildRequires: python3-oslo.config >= 6.0.0 @@ -73,7 +73,7 @@ Documentation for the Oslo Policy library. %prep -%autosetup -p1 -n oslo.policy-3.7.0 +%autosetup -p1 -n oslo.policy-3.8.2 %py_req_cleanup %build ++++++ _service ++++++ --- /var/tmp/diff_new_pack.EMvAEA/_old 2021-12-12 00:57:43.818589353 +0100 +++ /var/tmp/diff_new_pack.EMvAEA/_new 2021-12-12 00:57:43.818589353 +0100 @@ -1,8 +1,8 @@ <services> <service mode="disabled" name="renderspec"> - <param name="input-template">https://opendev.org/openstack/rpm-packaging/raw/branch/stable/wallaby/openstack/oslo.policy/oslo.policy.spec.j2</param> + <param name="input-template">https://opendev.org/openstack/rpm-packaging/raw/master/openstack/oslo.policy/oslo.policy.spec.j2</param> <param name="output-name">python-oslo.policy.spec</param> - <param name="requirements">https://opendev.org/openstack/oslo.policy/raw/branch/stable/wallaby/requirements.txt</param> + <param name="requirements">https://opendev.org/openstack/oslo.policy/raw/master/requirements.txt</param> <param name="changelog-email">[email protected]</param> <param name="changelog-provider">gh,openstack,oslo.policy</param> </service> ++++++ oslo.policy-3.7.0.tar.gz -> oslo.policy-3.8.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/.pre-commit-config.yaml new/oslo.policy-3.8.2/.pre-commit-config.yaml --- old/oslo.policy-3.7.0/.pre-commit-config.yaml 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/.pre-commit-config.yaml 2021-08-19 14:38:22.000000000 +0200 @@ -1,15 +1,15 @@ ---- # We from the Oslo project decided to pin repos based on the # commit hash instead of the version tag to prevend arbitrary # code from running in developer's machines. To update to a # newer version, run `pre-commit autoupdate` and then replace # the newer versions with their commit hash. + default_language_version: python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: ebc15addedad713c86ef18ae9632c88e187dd0af # v3.1.0 + rev: 9136088a246768144165fcc3ecc3d31bb686920a # v3.3.0 hooks: - id: trailing-whitespace # Replaces or checks mixed line ending @@ -27,9 +27,13 @@ - id: debug-statements - id: check-yaml files: .*\.(yaml|yml)$ - - repo: https://gitlab.com/pycqa/flake8 - rev: 181bb46098dddf7e2d45319ea654b4b4d58c2840 # 3.8.3 + - repo: local hooks: - id: flake8 + name: flake8 additional_dependencies: - hacking>=3.2.0,<3.3.0 + language: python + entry: flake8 + files: '^.*\.py$' + exclude: '^(doc|releasenotes|tools)/.*$' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/.zuul.yaml new/oslo.policy-3.8.2/.zuul.yaml --- old/oslo.policy-3.7.0/.zuul.yaml 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/.zuul.yaml 2021-08-19 14:38:22.000000000 +0200 @@ -38,8 +38,7 @@ templates: - check-requirements - lib-forward-testing-python3 - - openstack-lower-constraints-jobs - - openstack-python3-wallaby-jobs + - openstack-python3-xena-jobs - periodic-stable-jobs - publish-openstack-docs-pti - release-notes-jobs-python3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/AUTHORS new/oslo.policy-3.8.2/AUTHORS --- old/oslo.policy-3.7.0/AUTHORS 2021-03-03 14:37:24.000000000 +0100 +++ new/oslo.policy-3.8.2/AUTHORS 2021-08-19 14:38:57.000000000 +0200 @@ -16,6 +16,7 @@ Ben Nemec <[email protected]> Brant Knudson <[email protected]> Brian Rosmaita <[email protected]> +BubaVV <[email protected]> Chang Bo Guo <[email protected]> ChangBo Guo(gcb) <[email protected]> Chuck Short <[email protected]> @@ -24,6 +25,7 @@ Corey Wright <[email protected]> Cyril Roelandt <[email protected]> Daisuke Fujita <[email protected]> +Daniel Bengtsson <[email protected]> Davanum Srinivas <[email protected]> David Stanek <[email protected]> Dina Belova <[email protected]> @@ -74,6 +76,7 @@ Nathan Kinder <[email protected]> OpenStack Release Bot <[email protected]> Qi Zhang <[email protected]> +Raildo Mascena <[email protected]> Rodrigo Duarte Sousa <[email protected]> Ronald Bradford <[email protected]> Sami Makki <[email protected]> @@ -108,6 +111,7 @@ ZhongShengping <[email protected]> Zhongyue Luo <[email protected]> caoyuan <[email protected]> +dengzhaosen <[email protected]> fujioka yuuichi <[email protected]> gecong1973 <[email protected]> gengchc2 <[email protected]> @@ -126,7 +130,9 @@ wangqi <[email protected]> wangxiyuan <[email protected]> xuanyandong <[email protected]> +yangyawei <[email protected]> yatinkarel <[email protected]> zhangbailin <[email protected]> zhangyanxian <[email protected]> +zhaoleilc <[email protected]> zhoulinhui <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/ChangeLog new/oslo.policy-3.8.2/ChangeLog --- old/oslo.policy-3.7.0/ChangeLog 2021-03-03 14:37:24.000000000 +0100 +++ new/oslo.policy-3.8.2/ChangeLog 2021-08-19 14:38:57.000000000 +0200 @@ -1,12 +1,38 @@ CHANGES ======= +3.8.2 +----- + +* Fix a typo in the document +* Changed minversion in tox to 3.18.0 + +3.8.1 +----- + +* setup.cfg: Replace dashes with underscores +* Replace getargspec with getfullargspec +* Ussuri+ is python3 only and update python to python3 + +3.8.0 +----- + +* Dropping lower constraints testing +* Add Python3 xena unit tests +* Update master for stable/wallaby +* Move flake8 as a pre-commit local target +* Reinstate double deprecation test logic + 3.7.0 ----- * trivial: Tweak docstrings * Make 'Rule' attributes read-only * Don't modify 'Rule.check' +* Improving documentation about target resources +* Adding tests on cache handler +* Correctly handle IO errors at policy file load +* Add unit tests on cache handler * Add nova/neutron project unit/functional tests job in gate 3.6.2 @@ -19,6 +45,7 @@ * Handle deprecated rule only once * Switch to collections.abc.MutableMapping +* Add debug log in pick\_default\_policy\_file * Add documentation parameters for DeprecatedRule * tests: Unset requests-related environment variables * pre-commit: Resolve dependency conflicts @@ -29,6 +56,7 @@ * Fix oslopolicy-j2y-convertor tool for RuleDefault * Add policy file selection logic when default changing to yaml +* Use py3 as the default runtime for tox * Fix grammar issues * Use TOX\_CONSTRAINTS\_FILE * Remove format option examples in policy generator diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/PKG-INFO new/oslo.policy-3.8.2/PKG-INFO --- old/oslo.policy-3.7.0/PKG-INFO 2021-03-03 14:37:24.436401000 +0100 +++ new/oslo.policy-3.8.2/PKG-INFO 2021-08-19 14:38:57.778637200 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: oslo.policy -Version: 3.7.0 +Version: 3.8.2 Summary: Oslo Policy library Home-page: https://docs.openstack.org/oslo.policy/latest/ Author: OpenStack diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/doc/source/admin/policy-yaml-file.rst new/oslo.policy-3.8.2/doc/source/admin/policy-yaml-file.rst --- old/oslo.policy-3.7.0/doc/source/admin/policy-yaml-file.rst 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/doc/source/admin/policy-yaml-file.rst 2021-08-19 14:38:22.000000000 +0200 @@ -239,7 +239,19 @@ database. For example in the case of the ``"compute:start"`` API, the object is the instance to be started. The policy for starting instances could use the ``%(project_id)s`` attribute, that is the project that -owns the instance. The trailing ``s`` indicates this is a string. +owns the instance. The trailing ``s`` indicates this is a string. The same +case would be valid for API attributes like ``%(user_id)s`` and +``%(domain_id)s``. + +During a debug logging phase, it's common to have the target object +attributes retrieved in the API calls. Comparing the API call on the logs +with the policy enforced for the corresponding API, you can check which API +attribute has been used as the target object. For example in the policy.yaml +for the Nova project you can find ``"compute:start"`` API, the policy will show as +``"rule:admin_or_owner"`` which will point for +``"admin_or_owner": "is_admin:True or project_id:%(project_id)s"`` and in this +way you can check that the target object in the debug logging it needs to be a +``project_id`` attribute. ``is_admin`` indicates that administrative privileges are granted via the admin token mechanism (the ``--os-token`` option of the ``keystone`` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/doc/source/cli/oslopolicy-checker.rst new/oslo.policy-3.8.2/doc/source/cli/oslopolicy-checker.rst --- old/oslo.policy-3.7.0/doc/source/cli/oslopolicy-checker.rst 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/doc/source/cli/oslopolicy-checker.rst 2021-08-19 14:38:22.000000000 +0200 @@ -18,7 +18,7 @@ Description ----------- -The ``oslopolicy-policy-generator`` command can be used to check policy against +The ``oslopolicy-checker`` command can be used to check policy against the OpenStack Identity API access information. The access information is a keystone token response from keystone's `authentication API <https://docs.openstack.org/api-ref/identity/v3/#password-authentication-with-scoped-authorization>`_. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/lower-constraints.txt new/oslo.policy-3.8.2/lower-constraints.txt --- old/oslo.policy-3.7.0/lower-constraints.txt 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/lower-constraints.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1,50 +0,0 @@ -alabaster==0.7.10 -appdirs==1.3.0 -Babel==2.3.4 -bandit==1.4.0 -coverage==4.0 -debtcollector==1.2.0 -docutils==0.12 -dulwich==0.15.0 -extras==1.0.0 -fixtures==3.0.0 -gitdb==0.6.4 -GitPython==1.0.1 -imagesize==0.7.1 -iso8601==0.1.11 -Jinja2==2.10 -keystoneauth1==3.4.0 -linecache2==1.0.0 -MarkupSafe==1.1.1 -mox3==0.20.0 -msgpack-python==0.4.0 -netaddr==0.7.18 -netifaces==0.10.4 -os-client-config==1.28.0 -oslo.config==6.0.0 -oslo.context==2.22.0 -oslo.i18n==3.15.3 -oslo.serialization==2.18.0 -oslo.utils==3.40.0 -oslotest==3.2.0 -pbr==2.0.0 -Pygments==2.2.0 -pyparsing==2.1.0 -python-mimeparse==1.6.0 -python-subunit==1.0.0 -pytz==2013.6 -PyYAML==5.1 -requests==2.14.2 -requests-mock==1.2.0 -requestsexceptions==1.2.0 -rfc3986==0.3.1 -Sphinx==2.0.0 -stestr==2.0.0 -smmap==0.9.0 -snowballstemmer==1.2.1 -stevedore==1.20.0 -testrepository==0.0.18 -testtools==2.2.0 -traceback2==1.4.0 -unittest2==1.1.0 -wrapt==1.7.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/oslo.policy.egg-info/PKG-INFO new/oslo.policy-3.8.2/oslo.policy.egg-info/PKG-INFO --- old/oslo.policy-3.7.0/oslo.policy.egg-info/PKG-INFO 2021-03-03 14:37:24.000000000 +0100 +++ new/oslo.policy-3.8.2/oslo.policy.egg-info/PKG-INFO 2021-08-19 14:38:57.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: oslo.policy -Version: 3.7.0 +Version: 3.8.2 Summary: Oslo Policy library Home-page: https://docs.openstack.org/oslo.policy/latest/ Author: OpenStack diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/oslo.policy.egg-info/SOURCES.txt new/oslo.policy-3.8.2/oslo.policy.egg-info/SOURCES.txt --- old/oslo.policy-3.7.0/oslo.policy.egg-info/SOURCES.txt 2021-03-03 14:37:24.000000000 +0100 +++ new/oslo.policy-3.8.2/oslo.policy.egg-info/SOURCES.txt 2021-08-19 14:38:57.000000000 +0200 @@ -9,7 +9,6 @@ HACKING.rst LICENSE README.rst -lower-constraints.txt requirements.txt setup.cfg setup.py @@ -67,6 +66,7 @@ oslo_policy/locale/en_GB/LC_MESSAGES/oslo_policy.po oslo_policy/tests/__init__.py oslo_policy/tests/base.py +oslo_policy/tests/test_cache_handler.py oslo_policy/tests/test_checks.py oslo_policy/tests/test_external.py oslo_policy/tests/test_fixtures.py @@ -112,6 +112,7 @@ releasenotes/source/unreleased.rst releasenotes/source/ussuri.rst releasenotes/source/victoria.rst +releasenotes/source/wallaby.rst releasenotes/source/_static/.placeholder releasenotes/source/_templates/.placeholder releasenotes/source/locale/en_GB/LC_MESSAGES/releasenotes.po diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/oslo.policy.egg-info/pbr.json new/oslo.policy-3.8.2/oslo.policy.egg-info/pbr.json --- old/oslo.policy-3.7.0/oslo.policy.egg-info/pbr.json 2021-03-03 14:37:24.000000000 +0100 +++ new/oslo.policy-3.8.2/oslo.policy.egg-info/pbr.json 2021-08-19 14:38:57.000000000 +0200 @@ -1 +1 @@ -{"git_version": "d853485", "is_release": true} \ No newline at end of file +{"git_version": "c7fd9f4", "is_release": true} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/oslo_policy/_cache_handler.py new/oslo.policy-3.8.2/oslo_policy/_cache_handler.py --- old/oslo.policy-3.7.0/oslo_policy/_cache_handler.py 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/oslo_policy/_cache_handler.py 2021-08-19 14:38:22.000000000 +0200 @@ -13,9 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. +import errno import logging import os +from oslo_config import cfg + LOG = logging.getLogger(__name__) @@ -33,13 +36,33 @@ delete_cached_file(cache, filename) reloaded = False - mtime = os.path.getmtime(filename) + try: + mtime = os.path.getmtime(filename) + except OSError as err: + msg = err.strerror + LOG.error('Config file not found %(filename)s: %(msg)s', + {'filename': filename, 'msg': msg}) + return True, {} + cache_info = cache.setdefault(filename, {}) if not cache_info or mtime > cache_info.get('mtime', 0): LOG.debug("Reloading cached file %s", filename) - with open(filename) as fap: - cache_info['data'] = fap.read() + try: + with open(filename) as fap: + cache_info['data'] = fap.read() + except IOError as err: + msg = err.strerror + err_code = err.errno + LOG.error('IO error loading %(filename)s: %(msg)s', + {'filename': filename, 'msg': msg}) + if err_code == errno.EACCES: + raise cfg.ConfigFilesPermissionDeniedError((filename,)) + except OSError as err: + msg = err.strerror + LOG.error('Config file not found %(filename)s: %(msg)s', + {'filename': filename, 'msg': msg}) + raise cfg.ConfigFilesNotFoundError((filename,)) cache_info['mtime'] = mtime reloaded = True return (reloaded, cache_info['data']) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/oslo_policy/_checks.py new/oslo.policy-3.8.2/oslo_policy/_checks.py --- old/oslo.policy-3.7.0/oslo_policy/_checks.py 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/oslo_policy/_checks.py 2021-08-19 14:38:22.000000000 +0200 @@ -21,11 +21,6 @@ import stevedore -if hasattr(inspect, 'getfullargspec'): - getargspec = inspect.getfullargspec -else: - getargspec = inspect.getargspec - registered_checks = {} extension_checks = None @@ -77,7 +72,7 @@ """ # Evaluate the rule - argspec = getargspec(rule.__call__) + argspec = inspect.getfullargspec(rule.__call__) rule_args = [target, creds, enforcer] # Check if the rule argument must be included or not if len(argspec.args) > 4: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/oslo_policy/policy.py new/oslo.policy-3.8.2/oslo_policy/policy.py --- old/oslo.policy-3.7.0/oslo_policy/policy.py 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/oslo_policy/policy.py 2021-08-19 14:38:22.000000000 +0200 @@ -371,15 +371,25 @@ new_default_policy_file = 'policy.yaml' old_default_policy_file = 'policy.json' + policy_file = None if ((conf.oslo_policy.policy_file == new_default_policy_file) and fallback_to_json_file): location = conf.get_location('policy_file', 'oslo_policy').location if conf.find_file(conf.oslo_policy.policy_file): - return conf.oslo_policy.policy_file + policy_file = conf.oslo_policy.policy_file elif location in [cfg.Locations.opt_default, cfg.Locations.set_default]: + LOG.debug('Searching old policy.json file.') if conf.find_file(old_default_policy_file): - return old_default_policy_file + policy_file = old_default_policy_file + if policy_file: + LOG.debug( + 'Picking default policy file: %s. Config location: %s', + policy_file, location) + return policy_file + LOG.debug( + 'No default policy file present, picking the configured ' + 'one: %s.', conf.oslo_policy.policy_file) # Return overridden policy file return conf.oslo_policy.policy_file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/oslo_policy/shell.py new/oslo.policy-3.8.2/oslo_policy/shell.py --- old/oslo.policy-3.7.0/oslo_policy/shell.py 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/oslo_policy/shell.py 2021-08-19 14:38:22.000000000 +0200 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/oslo_policy/tests/test_cache_handler.py new/oslo.policy-3.8.2/oslo_policy/tests/test_cache_handler.py --- old/oslo.policy-3.7.0/oslo_policy/tests/test_cache_handler.py 1970-01-01 01:00:00.000000000 +0100 +++ new/oslo.policy-3.8.2/oslo_policy/tests/test_cache_handler.py 2021-08-19 14:38:22.000000000 +0200 @@ -0,0 +1,94 @@ +# Copyright (c) 2020 OpenStack Foundation. +# All Rights Reserved. + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""Test the cache handler module""" + +import os +from unittest import mock + +import fixtures +import oslo_config +from oslotest import base as test_base + +from oslo_policy import _cache_handler as _ch + + +class CacheHandlerTest(test_base.BaseTestCase): + + def setUp(self): + super().setUp() + self.tmpdir = self.useFixture(fixtures.TempDir()) + + def test_read_cached_file(self): + file_cache = {} + + path = os.path.join(self.tmpdir.path, 'tmpfile') + with open(path, 'w+') as fp: + fp.write('test') + + reloaded, data = _ch.read_cached_file(file_cache, path) + self.assertEqual('test', data) + self.assertTrue(reloaded) + + reloaded, data = _ch.read_cached_file(file_cache, path) + self.assertEqual('test', data) + self.assertFalse(reloaded) + + reloaded, data = _ch.read_cached_file( + file_cache, path, force_reload=True) + self.assertEqual('test', data) + self.assertTrue(reloaded) + + def test_read_cached_file_with_updates(self): + file_cache = {} + + path = os.path.join(self.tmpdir.path, 'tmpfile') + with open(path, 'w+') as fp: + fp.write('test') + + reloaded, data = _ch.read_cached_file(file_cache, path) + + # update the timestamps + times = (os.stat(path).st_atime + 1, os.stat(path).st_mtime + 1) + os.utime(path, times) + + reloaded, data = _ch.read_cached_file(file_cache, path) + self.assertTrue(reloaded) + + @mock.patch.object(_ch, 'LOG') + def test_reloading_cache_with_permission_denied(self, mock_log): + file_cache = {} + + path = os.path.join(self.tmpdir.path, 'tmpfile') + with open(path, 'w+') as fp: + fp.write('test') + + os.chmod(path, 000) + self.assertRaises( + oslo_config.cfg.ConfigFilesPermissionDeniedError, + _ch.read_cached_file, file_cache, path) + mock_log.error.assert_called_once() + + @mock.patch.object(_ch, 'LOG') + def test_reloading_on_removed_file(self, mock_log): + file_cache = {} + + # don't actually create the file + path = os.path.join(self.tmpdir.path, 'tmpfile') + + reloaded, data = _ch.read_cached_file(file_cache, path) + self.assertEqual({}, data) + self.assertTrue(reloaded) + mock_log.error.assert_called_once() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/oslo_policy/tests/test_policy.py new/oslo.policy-3.8.2/oslo_policy/tests/test_policy.py --- old/oslo.policy-3.7.0/oslo_policy/tests/test_policy.py 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/oslo_policy/tests/test_policy.py 2021-08-19 14:38:22.000000000 +0200 @@ -1802,6 +1802,12 @@ 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): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/releasenotes/source/index.rst new/oslo.policy-3.8.2/releasenotes/source/index.rst --- old/oslo.policy-3.7.0/releasenotes/source/index.rst 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/releasenotes/source/index.rst 2021-08-19 14:38:22.000000000 +0200 @@ -6,6 +6,7 @@ :maxdepth: 1 unreleased + wallaby victoria ussuri train diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/releasenotes/source/wallaby.rst new/oslo.policy-3.8.2/releasenotes/source/wallaby.rst --- old/oslo.policy-3.7.0/releasenotes/source/wallaby.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/oslo.policy-3.8.2/releasenotes/source/wallaby.rst 2021-08-19 14:38:22.000000000 +0200 @@ -0,0 +1,6 @@ +============================ +Wallaby Series Release Notes +============================ + +.. release-notes:: + :branch: stable/wallaby diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/setup.cfg new/oslo.policy-3.8.2/setup.cfg --- old/oslo.policy-3.7.0/setup.cfg 2021-03-03 14:37:24.436401000 +0100 +++ new/oslo.policy-3.8.2/setup.cfg 2021-08-19 14:38:57.778637200 +0200 @@ -1,12 +1,12 @@ [metadata] name = oslo.policy summary = Oslo Policy library -description-file = +description_file = README.rst author = OpenStack -author-email = [email protected] -home-page = https://docs.openstack.org/oslo.policy/latest/ -python-requires = >=3.6 +author_email = [email protected] +home_page = https://docs.openstack.org/oslo.policy/latest/ +python_requires = >=3.6 classifier = Environment :: OpenStack Intended Audience :: Information Technology diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/oslo.policy-3.7.0/tox.ini new/oslo.policy-3.8.2/tox.ini --- old/oslo.policy-3.7.0/tox.ini 2021-03-03 14:36:47.000000000 +0100 +++ new/oslo.policy-3.8.2/tox.ini 2021-08-19 14:38:22.000000000 +0200 @@ -1,6 +1,6 @@ [tox] -minversion = 3.1 -envlist = py38,pep8,docs +minversion = 3.18.0 +envlist = py3,pep8,docs ignore_basepython_conflict = true [testenv] @@ -25,7 +25,7 @@ commands = {posargs} [testenv:docs] -whitelist_externals = +allowlist_externals = rm deps = {[testenv]deps} @@ -56,14 +56,8 @@ [testenv:releasenotes] deps = -r{toxinidir}/doc/requirements.txt -whitelist_externals = +allowlist_externals = rm commands = rm -rf releasenotes/build sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html - -[testenv:lower-constraints] -deps = - -c{toxinidir}/lower-constraints.txt - -r{toxinidir}/test-requirements.txt - -r{toxinidir}/requirements.txt
