Reviewed: https://review.openstack.org/275541 Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=52f507c319e05bbdfbd5e28d92fdced7900ebf7d Submitter: Jenkins Branch: master
commit 52f507c319e05bbdfbd5e28d92fdced7900ebf7d Author: Dave Chen <[email protected]> Date: Wed Feb 3 15:02:40 2016 +0800 Reinitialize the policy engine where it is needed Policy engine should be reinitialized in the testcases where policy enforcement is needed so that the `policy.json` from the code base is readable. Previously, it's only reinitialized for V3 restful testcases, but the V2 APIs such as create credential also need to read policy file. Bunches of testcases will fail if run testcases separately. $ python -m unittest keystone.tests.unit.test_v2 ... Ran 122 tests in 18.954s FAILED (errors=73, skipped=3) V2 restful testcases could be pass and escaped detection just because they are run with V3 restful testcases together, and the `policy.json` is loaded from code base and won't loaded any more. Change-Id: I0cbc13f0902db66de0d673c64ec81a56861a2bc3 Closes-Bug: #1541218 ** Changed in: keystone Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Identity (keystone). https://bugs.launchpad.net/bugs/1541218 Title: make tests use test copy of policy.json Status in OpenStack Identity (keystone): Fix Released Bug description: How to reproduce: 1. remove the `/etc/keystone/policy.json` if there is since this file only exists after env is setup, this will make sure the test engine to search the `policy.json` in the code base, for example, load the policy file from here `/opt/stack/keystone/etc/policy.json` 2. run the v2 testcases separately, $ python -m unittest keystone.tests.unit.test_v2 or simply run only one testcases. $ python -m unittest keystone.tests.unit.test_credential.TestCredentialEc2.test_ec2_list_credentials 3. You will hit the following exceptions. enforce identity:validate_token: {'is_delegated_auth': False, 'access_token_id': None, 'user_id': u'180af26c59e9460f81652569d27fc439', 'roles': ['Service'], 'user_domain_id': 'default', 'trustee_id': None, 'trustor_id': None, 'consumer_id': None, 'token': <KeystoneToken (audit_id=AP7_3Z_VRniinKe_jiFZrA, audit_chain_id=AP7_3Z_VRniinKe_jiFZrA) at 0x7f9566d5d2a0>, 'project_id': 'service', 'trust_id': None, 'project_domain_id': 'default'} Failed to find some config files: policy.json Traceback (most recent call last): File "keystone/common/wsgi.py", line 247, in __call__ result = method(context, **params) File "/usr/local/lib/python2.7/dist-packages/oslo_log/versionutils.py", line 165, in wrapped return func_or_cls(*args, **kwargs) File "keystone/common/controller.py", line 179, in inner utils.flatten_dict(policy_dict)) File "keystone/policy/backends/rules.py", line 77, in enforce enforce(credentials, action, target) File "keystone/policy/backends/rules.py", line 69, in enforce return _ENFORCER.enforce(action, target, credentials, **extra) File "/usr/local/lib/python2.7/dist-packages/oslo_policy/policy.py", line 540, in enforce self.load_rules() File "/usr/local/lib/python2.7/dist-packages/oslo_policy/policy.py", line 443, in load_rules self.policy_path = self._get_policy_path(self.policy_file) File "/usr/local/lib/python2.7/dist-packages/oslo_policy/policy.py", line 513, in _get_policy_path raise cfg.ConfigFilesNotFoundError((path,)) ConfigFilesNotFoundError: Failed to find some config files: policy.json }}} Traceback (most recent call last): File "keystone/tests/unit/test_v2.py", line 186, in test_validate_token_service_role token=token) File "keystone/tests/unit/rest.py", line 208, in admin_request return self._request(app=self.admin_app, **kwargs) File "keystone/tests/unit/rest.py", line 197, in _request response = self.restful_request(**kwargs) File "keystone/tests/unit/rest.py", line 182, in restful_request **kwargs) File "keystone/tests/unit/rest.py", line 90, in request **kwargs) File "/usr/local/lib/python2.7/dist-packages/webtest/app.py", line 567, in request expect_errors=expect_errors, File "/usr/local/lib/python2.7/dist-packages/webtest/app.py", line 632, in do_request self._check_status(status, res) File "/usr/local/lib/python2.7/dist-packages/webtest/app.py", line 664, in _check_status res) webtest.app.AppError: Bad response: 500 Internal Server Error (not 200 OK or 3xx redirect for http://localhost/v2.0/tokens/3c69de14762f42ac89852eb1f3c7eab5) '{"error": {"message": "An unexpected error prevented the server from fulfilling your request.", "code": 500, "title": "Internal Server Error"}}' Ran 122 tests in 18.954s FAILED (errors=73, skipped=3) To manage notifications about this bug go to: https://bugs.launchpad.net/keystone/+bug/1541218/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

