)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":841,"name":"Akihiro Motoki","email":"amotoki@gmail.com","username":"amotoki"},"change_message_id":"41d11dee792ffb4ea378d1919e6143bd646c752d","unresolved":false,"context_lines":[{"line_number":4,"context_line":"Commit:     Ihar Hrachyshka \u003cihrachys@redhat.com\u003e"},{"line_number":5,"context_line":"CommitDate: 2014-10-14 22:58:48 +0200"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"WIP: Sync policy from oslo-incubator"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Common policy has not been synced with oslo-incubator for a"},{"line_number":10,"context_line":"long time and is seriously outdated."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":8,"id":"baa201ad_76389dd3","line":7,"updated":"2014-10-15 08:06:21.000000000","message":"Is it still WIP or ready for review?","commit_id":"1b735439e14e82a6481964a7f653bbf4a88cebb1"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"58ac2c8ee62787d67ee8df0218155118aeec3e99","unresolved":false,"context_lines":[{"line_number":4,"context_line":"Commit:     Ihar Hrachyshka \u003cihrachys@redhat.com\u003e"},{"line_number":5,"context_line":"CommitDate: 2014-10-14 22:58:48 +0200"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"WIP: Sync policy from oslo-incubator"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Common policy has not been synced with oslo-incubator for a"},{"line_number":10,"context_line":"long time and is seriously outdated."}],"source_content_type":"text/x-gerrit-commit-message","patch_set":8,"id":"baa201ad_98c8cb56","line":7,"in_reply_to":"baa201ad_76389dd3","updated":"2014-10-15 10:19:05.000000000","message":"Yes, it is ready to be reviewed","commit_id":"1b735439e14e82a6481964a7f653bbf4a88cebb1"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"b6388af5e7eb84c06fe141ced8170187ead29ffa","unresolved":false,"context_lines":[{"line_number":12,"context_line":"This change pulls in fresh code from oslo-incubator which"},{"line_number":13,"context_line":"introduces the Enforcer class to replace the old check function."},{"line_number":14,"context_line":""},{"line_number":15,"context_line":"Rewrite neutron.policy and related unit tests"},{"line_number":16,"context_line":"accordingly."},{"line_number":17,"context_line":"Remove neutron.common.exceptions.PolicyNotAuthorized and switch"},{"line_number":18,"context_line":"to neutron.openstack.common.policy.PolicyNotAuthorized"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":21,"id":"5a890539_a6e673b2","line":15,"updated":"2014-11-13 10:25:25.000000000","message":"may want to mention that neutron.policy was rewrited based on Nova","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"82bd085f1b8f9dae615f997801535e0df7e264b9","unresolved":false,"context_lines":[{"line_number":12,"context_line":"This change pulls in fresh code from oslo-incubator which"},{"line_number":13,"context_line":"introduces the Enforcer class to replace the old check function."},{"line_number":14,"context_line":""},{"line_number":15,"context_line":"Rewrite neutron.policy and related unit tests"},{"line_number":16,"context_line":"accordingly."},{"line_number":17,"context_line":"Remove neutron.common.exceptions.PolicyNotAuthorized and switch"},{"line_number":18,"context_line":"to neutron.openstack.common.policy.PolicyNotAuthorized"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":21,"id":"5a890539_bc8f64cb","line":15,"in_reply_to":"5a890539_21142d4d","updated":"2014-11-13 11:02:16.000000000","message":"Done","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"9f33bb81217ff5ab9f2c6130127fe00ec131e948","unresolved":false,"context_lines":[{"line_number":12,"context_line":"This change pulls in fresh code from oslo-incubator which"},{"line_number":13,"context_line":"introduces the Enforcer class to replace the old check function."},{"line_number":14,"context_line":""},{"line_number":15,"context_line":"Rewrite neutron.policy and related unit tests"},{"line_number":16,"context_line":"accordingly."},{"line_number":17,"context_line":"Remove neutron.common.exceptions.PolicyNotAuthorized and switch"},{"line_number":18,"context_line":"to neutron.openstack.common.policy.PolicyNotAuthorized"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":21,"id":"5a890539_21142d4d","line":15,"in_reply_to":"5a890539_a6e673b2","updated":"2014-11-13 10:38:07.000000000","message":"Alright , I will add this info","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"}],"neutron/api/v2/base.py":[{"author":{"_account_id":1653,"name":"garyk","email":"gkotton@vmware.com","username":"garyk"},"change_message_id":"7f8ea5adaed77bf4d3dc736d46689c5f0548a137","unresolved":false,"context_lines":[{"line_number":40,"context_line":"             exceptions.InUse: webob.exc.HTTPConflict,"},{"line_number":41,"context_line":"             exceptions.BadRequest: webob.exc.HTTPBadRequest,"},{"line_number":42,"context_line":"             exceptions.ServiceUnavailable: webob.exc.HTTPServiceUnavailable,"},{"line_number":43,"context_line":"             exceptions.NotAuthorized: webob.exc.HTTPForbidden,"},{"line_number":44,"context_line":"             netaddr.AddrFormatError: webob.exc.HTTPBadRequest,"},{"line_number":45,"context_line":"             common_policy.PolicyNotAuthorized: webob.exc.HTTPForbidden"},{"line_number":46,"context_line":"             }"}],"source_content_type":"text/x-python","patch_set":19,"id":"5a890539_4f4a9b84","line":43,"updated":"2014-11-10 13:38:12.000000000","message":"do we still need this one?","commit_id":"3ac1c9501be067a2c84e86f823a1e5ddb08fd14f"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"4af351f113fff7e8b9ab397db1c30ac701569d4d","unresolved":false,"context_lines":[{"line_number":40,"context_line":"             exceptions.InUse: webob.exc.HTTPConflict,"},{"line_number":41,"context_line":"             exceptions.BadRequest: webob.exc.HTTPBadRequest,"},{"line_number":42,"context_line":"             exceptions.ServiceUnavailable: webob.exc.HTTPServiceUnavailable,"},{"line_number":43,"context_line":"             exceptions.NotAuthorized: webob.exc.HTTPForbidden,"},{"line_number":44,"context_line":"             netaddr.AddrFormatError: webob.exc.HTTPBadRequest,"},{"line_number":45,"context_line":"             common_policy.PolicyNotAuthorized: webob.exc.HTTPForbidden"},{"line_number":46,"context_line":"             }"}],"source_content_type":"text/x-python","patch_set":19,"id":"5a890539_b8dd0245","line":43,"in_reply_to":"5a890539_4f4a9b84","updated":"2014-11-10 17:53:50.000000000","message":"I think we do because NotAuthorized and AdminRequired exception, which derives from NotAuthorized, are still raised around the code.","commit_id":"3ac1c9501be067a2c84e86f823a1e5ddb08fd14f"}],"neutron/policy.py":[{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":73,"context_line":"    if not _POLICY_PATH:"},{"line_number":74,"context_line":"        _POLICY_PATH \u003d utils.find_config_file({}, cfg.CONF.policy_file)"},{"line_number":75,"context_line":"        if not _POLICY_PATH:"},{"line_number":76,"context_line":"            raise exceptions.PolicyFileNotFound(path\u003dcfg.CONF.policy_file)"},{"line_number":77,"context_line":"    # pass _set_brain to read_cached_file so that the policy brain"},{"line_number":78,"context_line":"    # is reset only if the file has changed"},{"line_number":79,"context_line":"    utils.read_cached_file(_POLICY_PATH, _POLICY_CACHE,"}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_98c0a451","side":"PARENT","line":76,"updated":"2014-10-16 14:06:14.000000000","message":"Shouldn\u0027t we also remove the exception that we don\u0027t use now?","commit_id":"61c3908f524fa548e2419bf1e9f9609c59f232e4"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":65,"context_line":""},{"line_number":66,"context_line":""},{"line_number":67,"context_line":"def init(policy_file\u003dcfg.CONF.policy_file, rules\u003dNone,"},{"line_number":68,"context_line":"         default_rule\u003dNone, use_conf\u003dTrue):"},{"line_number":69,"context_line":"    \"\"\"Init an instance of the Enforcer class."},{"line_number":70,"context_line":""},{"line_number":71,"context_line":"    :param policy_file Custom policy file to use, if none is"}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_f872907a","line":68,"updated":"2014-10-16 14:06:14.000000000","message":"I don\u0027t think we need to expose most or all of those options to users.","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":86,"context_line":"                                    rules\u003drules,"},{"line_number":87,"context_line":"                                    default_rule\u003ddefault_rule,"},{"line_number":88,"context_line":"                                    use_conf\u003duse_conf)"},{"line_number":89,"context_line":"        # Method _get_policy_path in common.policy can not always locate"},{"line_number":90,"context_line":"        # neutron policy file, so set it explicitly."},{"line_number":91,"context_line":"        _ENFORCER.policy_path \u003d utils.find_config_file({}, policy_file)"},{"line_number":92,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_f8a3709b","line":89,"updated":"2014-10-16 14:06:14.000000000","message":"Could you please elaborate? Is there a bug in the synced code?","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":91,"context_line":"        _ENFORCER.policy_path \u003d utils.find_config_file({}, policy_file)"},{"line_number":92,"context_line":""},{"line_number":93,"context_line":""},{"line_number":94,"context_line":"def set_rules(policies, overwrite\u003dTrue, use_conf\u003dFalse):"},{"line_number":95,"context_line":"    \"\"\"Set rules based on the provided dict of rules."},{"line_number":96,"context_line":""},{"line_number":97,"context_line":"    :param policies: New policies to use. It should be an instance of dict."}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_f8c45093","line":94,"updated":"2014-10-16 14:06:14.000000000","message":"again, why do we expose e.g. use_conf and overwrite here? I don\u0027t think we should expose each API option that is available in neutron.common.policy, unless we really need it.","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":398,"context_line":"    return _ENFORCER.enforce(*(_prepare_check(context, action, target)))"},{"line_number":399,"context_line":""},{"line_number":400,"context_line":""},{"line_number":401,"context_line":"def enforce(context, action, target, plugin\u003dNone, do_raise\u003dFalse, exc\u003dNone):"},{"line_number":402,"context_line":"    \"\"\"Verifies that the action is valid on the target in this context."},{"line_number":403,"context_line":""},{"line_number":404,"context_line":"    :param context: neutron context"}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_75006901","line":401,"updated":"2014-10-16 14:06:14.000000000","message":"So with do_raise\u003dFalse, we still may raise if result is False. That\u0027s not the best way to implement API, to say the least. Why do we even need to expose those arguments to consumers of neutron.policy module?","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":419,"context_line":"    \"\"\""},{"line_number":420,"context_line":"    rule, target, credentials \u003d _prepare_check(context, action, target)"},{"line_number":421,"context_line":"    result \u003d _ENFORCER.enforce(rule, target, credentials,"},{"line_number":422,"context_line":"                               do_raise\u003ddo_raise, action\u003daction, exc\u003dexc)"},{"line_number":423,"context_line":"    if not result:"},{"line_number":424,"context_line":"        LOG.debug(_(\"Failed policy check for \u0027%s\u0027\"), action)"},{"line_number":425,"context_line":"        raise exceptions.PolicyNotAuthorized(action\u003daction)"}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_d5b675f8","line":422,"updated":"2014-10-16 14:06:14.000000000","message":"If we don\u0027t expose exc to users (I don\u0027t see a reason to do it), we won\u0027t need to pass action\u003daction either, since it\u0027s used when raising custom exception only.","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":422,"context_line":"                               do_raise\u003ddo_raise, action\u003daction, exc\u003dexc)"},{"line_number":423,"context_line":"    if not result:"},{"line_number":424,"context_line":"        LOG.debug(_(\"Failed policy check for \u0027%s\u0027\"), action)"},{"line_number":425,"context_line":"        raise exceptions.PolicyNotAuthorized(action\u003daction)"},{"line_number":426,"context_line":"    return result"},{"line_number":427,"context_line":""},{"line_number":428,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_0378cac2","line":425,"updated":"2014-10-16 14:06:14.000000000","message":"The exception is available in new version of policy module. I think we should reuse it (and drop neutron specific exception type from neutron.common.exception). Or is it not used here to retain backwards compatibility? [do we assume the method as part of public dev API?]\n\n[If we replace the exception, we will need to catch the exception first to LOG.debug before bailing out of the method.]\n\n[If we don\u0027t replace it, I still think we should not expose exc\u003d to users, and then we\u0027re able to pass exc\u003dexceptions.PolicyNotAuthorized to .enforce().]","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"faad7e5bd5035c1ba09d572a1bad551e6736c88c","unresolved":false,"context_lines":[{"line_number":64,"context_line":"        _ENFORCER \u003d None"},{"line_number":65,"context_line":""},{"line_number":66,"context_line":""},{"line_number":67,"context_line":"def init(policy_file\u003dcfg.CONF.policy_file):"},{"line_number":68,"context_line":"    \"\"\"Init an instance of the Enforcer class."},{"line_number":69,"context_line":""},{"line_number":70,"context_line":"    :param policy_file Custom policy file to use, if none is"}],"source_content_type":"text/x-python","patch_set":10,"id":"baa201ad_4a79e2c6","line":67,"updated":"2014-10-17 15:38:08.000000000","message":"I think we can also get rid of that argument. We don\u0027t use custom policy files that are set outside of configuration file, and Enforcer will access that configuration option on its own. As for explicit policy_path setting, we may just hardcode cfg.CONF.policy_file there.","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"faad7e5bd5035c1ba09d572a1bad551e6736c88c","unresolved":false,"context_lines":[{"line_number":77,"context_line":"        _ENFORCER \u003d policy.Enforcer(policy_file\u003dpolicy_file)"},{"line_number":78,"context_line":"        # NOTE: Method _get_policy_path in common.policy can not always locate"},{"line_number":79,"context_line":"        # neutron policy file (when init() is called in tests),"},{"line_number":80,"context_line":"        # so set it explicitly until there is a fixture for policy in tests."},{"line_number":81,"context_line":"        _ENFORCER.policy_path \u003d utils.find_config_file({}, policy_file)"},{"line_number":82,"context_line":"        _ENFORCER.load_rules(True)"},{"line_number":83,"context_line":""}],"source_content_type":"text/x-python","patch_set":10,"id":"baa201ad_6a5b0654","line":80,"updated":"2014-10-17 15:38:08.000000000","message":"It becomes more clear why we need the hack. Could you please report a bug against oslo (?) to add the needed fixture?","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"b69a622ac490570487fdd977f3addd988c810bef","unresolved":false,"context_lines":[{"line_number":77,"context_line":"        _ENFORCER \u003d policy.Enforcer(policy_file\u003dpolicy_file)"},{"line_number":78,"context_line":"        # NOTE: Method _get_policy_path in common.policy can not always locate"},{"line_number":79,"context_line":"        # neutron policy file (when init() is called in tests),"},{"line_number":80,"context_line":"        # so set it explicitly until there is a fixture for policy in tests."},{"line_number":81,"context_line":"        _ENFORCER.policy_path \u003d utils.find_config_file({}, policy_file)"},{"line_number":82,"context_line":"        _ENFORCER.load_rules(True)"},{"line_number":83,"context_line":""}],"source_content_type":"text/x-python","patch_set":10,"id":"9aa7fdbe_2ac4653f","line":80,"in_reply_to":"baa201ad_6a5b0654","updated":"2014-10-20 09:48:55.000000000","message":"I guess I used the wrong term here.\nThe problem is that find_file in oslo.config searches for config files in the following directories:\n[\u0027neutron/tests/etc\u0027, \u0027/tmp/tmpl4dTsq/tmpEMNf_p/.neutron\u0027, \u0027/tmp/tmpl4dTsq/tmpEMNf_p\u0027, \u0027/etc/neutron\u0027, \u0027/etc\u0027]\n(The first path is there because self.config_file value is \u0027neutron/tests/etc/neutron.conf.test\u0027)\n\nWhile utils.find_config_file searches a wider range of dirs:\n[\u0027/home/elena/neutron/etc\u0027, \u0027/tmp/tmp0TBK1R/tmpN7Jln_/.neutron-venv/etc/neutron\u0027, \u0027/tmp/tmp0TBK1R/tmpN7Jln_\u0027, \u0027/tmp/tmp0TBK1R/tmprZr7EY/etc\u0027, \u0027/tmp/tmp0TBK1R/tmprZr7EY/etc/neutron\u0027, \u0027/tmp/tmp0TBK1R/tmpN7Jln_/.local/etc/neutron\u0027, \u0027/usr/etc/neutron\u0027, \u0027/usr/local/etc/neutron\u0027, \u0027/etc/neutron/\u0027, \u0027/etc\u0027]\n\nThus find_config_file finds policy.json, which is situated in \u0027/home/elena/neutron/etc\u0027, while find_file doesn\u0027t.\n\nMy idea was either to use the hack or to create a new policy file policy.json.test in neutron/tests/etc directory and use it in all tests.","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"faad7e5bd5035c1ba09d572a1bad551e6736c88c","unresolved":false,"context_lines":[{"line_number":82,"context_line":"        _ENFORCER.load_rules(True)"},{"line_number":83,"context_line":""},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"def set_rules(policies, overwrite\u003dTrue):"},{"line_number":86,"context_line":"    \"\"\"Set rules based on the provided dict of rules."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"    :param policies: New policies to use. It should be an instance of dict."}],"source_content_type":"text/x-python","patch_set":10,"id":"baa201ad_aa7a4eb7","line":85,"updated":"2014-10-17 15:38:08.000000000","message":"Why\u0027s the need to add overwrite\u003d argument here?","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"b69a622ac490570487fdd977f3addd988c810bef","unresolved":false,"context_lines":[{"line_number":82,"context_line":"        _ENFORCER.load_rules(True)"},{"line_number":83,"context_line":""},{"line_number":84,"context_line":""},{"line_number":85,"context_line":"def set_rules(policies, overwrite\u003dTrue):"},{"line_number":86,"context_line":"    \"\"\"Set rules based on the provided dict of rules."},{"line_number":87,"context_line":""},{"line_number":88,"context_line":"    :param policies: New policies to use. It should be an instance of dict."}],"source_content_type":"text/x-python","patch_set":10,"id":"9aa7fdbe_0a9321a4","line":85,"in_reply_to":"baa201ad_aa7a4eb7","updated":"2014-10-20 09:48:55.000000000","message":"It is needed in case when we  want to update the current policies with new rules without losing existing ones.","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"f0e324636f827e05bf835f9bc0986ea6e45c4782","unresolved":false,"context_lines":[{"line_number":79,"context_line":"        _ENFORCER.load_rules(True)"},{"line_number":80,"context_line":""},{"line_number":81,"context_line":""},{"line_number":82,"context_line":"def refresh():"},{"line_number":83,"context_line":"    \"\"\"Reset policy and init a new instance of Enforcer."},{"line_number":84,"context_line":"    \"\"\""},{"line_number":85,"context_line":"    reset()"}],"source_content_type":"text/x-python","patch_set":13,"id":"9aa7fdbe_d5a29a99","line":82,"updated":"2014-10-20 10:06:17.000000000","message":"+1.","commit_id":"75c3b73bf0bb9877121d70778153f9267414bb42"},{"author":{"_account_id":6854,"name":"YAMAMOTO Takashi","email":"yamamoto@midokura.com","username":"yamamoto"},"change_message_id":"47a674534d8ce7629c1673a42624bb9f31749bb7","unresolved":false,"context_lines":[{"line_number":411,"context_line":"    try:"},{"line_number":412,"context_line":"        result \u003d _ENFORCER.enforce(rule, target, credentials,"},{"line_number":413,"context_line":"                                   action\u003daction, do_raise\u003dTrue)"},{"line_number":414,"context_line":"    except policy.PolicyNotAuthorized:"},{"line_number":415,"context_line":"        LOG.debug(\"Failed policy check for \u0027%s\u0027\", action)"},{"line_number":416,"context_line":"        raise"},{"line_number":417,"context_line":"    return result"}],"source_content_type":"text/x-python","patch_set":15,"id":"9aa7fdbe_97bb51e4","line":414,"updated":"2014-10-23 03:48:44.000000000","message":"please use save_and_reraise_exception here","commit_id":"67128511623d220cb6a949bfcbf4000033f985f7"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"5da1a13a3b6e63ecce9aa463646f3caa5462afb0","unresolved":false,"context_lines":[{"line_number":411,"context_line":"    try:"},{"line_number":412,"context_line":"        result \u003d _ENFORCER.enforce(rule, target, credentials,"},{"line_number":413,"context_line":"                                   action\u003daction, do_raise\u003dTrue)"},{"line_number":414,"context_line":"    except policy.PolicyNotAuthorized:"},{"line_number":415,"context_line":"        LOG.debug(\"Failed policy check for \u0027%s\u0027\", action)"},{"line_number":416,"context_line":"        raise"},{"line_number":417,"context_line":"    return result"}],"source_content_type":"text/x-python","patch_set":15,"id":"9aa7fdbe_ed720eac","line":414,"in_reply_to":"9aa7fdbe_97bb51e4","updated":"2014-10-23 06:27:21.000000000","message":"Done","commit_id":"67128511623d220cb6a949bfcbf4000033f985f7"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"b6388af5e7eb84c06fe141ced8170187ead29ffa","unresolved":false,"context_lines":[{"line_number":67,"context_line":""},{"line_number":68,"context_line":"def init():"},{"line_number":69,"context_line":"    \"\"\"Init an instance of the Enforcer class."},{"line_number":70,"context_line":"    \"\"\""},{"line_number":71,"context_line":""},{"line_number":72,"context_line":"    global _ENFORCER"},{"line_number":73,"context_line":"    if not _ENFORCER:"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_060ae7d1","line":70,"updated":"2014-11-13 10:25:25.000000000","message":"nit: should be one-liner","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"9f33bb81217ff5ab9f2c6130127fe00ec131e948","unresolved":false,"context_lines":[{"line_number":67,"context_line":""},{"line_number":68,"context_line":"def init():"},{"line_number":69,"context_line":"    \"\"\"Init an instance of the Enforcer class."},{"line_number":70,"context_line":"    \"\"\""},{"line_number":71,"context_line":""},{"line_number":72,"context_line":"    global _ENFORCER"},{"line_number":73,"context_line":"    if not _ENFORCER:"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_c17d29b3","line":70,"in_reply_to":"5a890539_060ae7d1","updated":"2014-11-13 10:38:07.000000000","message":"OK, will amend it","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"82bd085f1b8f9dae615f997801535e0df7e264b9","unresolved":false,"context_lines":[{"line_number":67,"context_line":""},{"line_number":68,"context_line":"def init():"},{"line_number":69,"context_line":"    \"\"\"Init an instance of the Enforcer class."},{"line_number":70,"context_line":"    \"\"\""},{"line_number":71,"context_line":""},{"line_number":72,"context_line":"    global _ENFORCER"},{"line_number":73,"context_line":"    if not _ENFORCER:"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_9cab881c","line":70,"in_reply_to":"5a890539_c17d29b3","updated":"2014-11-13 11:02:16.000000000","message":"Done","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"b6388af5e7eb84c06fe141ced8170187ead29ffa","unresolved":false,"context_lines":[{"line_number":80,"context_line":"        _ENFORCER.load_rules(True)"},{"line_number":81,"context_line":""},{"line_number":82,"context_line":""},{"line_number":83,"context_line":"def refresh():"},{"line_number":84,"context_line":"    \"\"\"Reset policy and init a new instance of Enforcer."},{"line_number":85,"context_line":"    \"\"\""},{"line_number":86,"context_line":"    reset()"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_c67d3fb3","line":83,"updated":"2014-11-13 10:25:25.000000000","message":"not seeing this used anywhere (except unit tests)..","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"f6613b88605385a5ec685b3f5e13ac3c87a70c92","unresolved":false,"context_lines":[{"line_number":80,"context_line":"        _ENFORCER.load_rules(True)"},{"line_number":81,"context_line":""},{"line_number":82,"context_line":""},{"line_number":83,"context_line":"def refresh():"},{"line_number":84,"context_line":"    \"\"\"Reset policy and init a new instance of Enforcer."},{"line_number":85,"context_line":"    \"\"\""},{"line_number":86,"context_line":"    reset()"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_bc3044e9","line":83,"in_reply_to":"5a890539_a14addc2","updated":"2014-11-13 10:44:59.000000000","message":"thanks for clarification!","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"9f33bb81217ff5ab9f2c6130127fe00ec131e948","unresolved":false,"context_lines":[{"line_number":80,"context_line":"        _ENFORCER.load_rules(True)"},{"line_number":81,"context_line":""},{"line_number":82,"context_line":""},{"line_number":83,"context_line":"def refresh():"},{"line_number":84,"context_line":"    \"\"\"Reset policy and init a new instance of Enforcer."},{"line_number":85,"context_line":"    \"\"\""},{"line_number":86,"context_line":"    reset()"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_a14addc2","line":83,"in_reply_to":"5a890539_c67d3fb3","updated":"2014-11-13 10:38:07.000000000","message":"It was decided to add this function to simplify refreshing policy in unit tests after discussion with Ihar. It still may come handy in the future so we decided to put it here","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"b6388af5e7eb84c06fe141ced8170187ead29ffa","unresolved":false,"context_lines":[{"line_number":129,"context_line":"    _ENFORCER.set_rules(policies, overwrite)"},{"line_number":130,"context_line":""},{"line_number":131,"context_line":""},{"line_number":132,"context_line":"def get_resource_and_action(action):"},{"line_number":133,"context_line":"    \"\"\"Extract resource and action (write, read) from api operation.\"\"\""},{"line_number":134,"context_line":"    data \u003d action.split(\u0027:\u0027, 1)[0].split(\u0027_\u0027, 1)"},{"line_number":135,"context_line":"    return (\"%ss\" % data[-1], data[0] !\u003d \u0027get\u0027)"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_a694b3e2","line":132,"updated":"2014-11-13 10:25:25.000000000","message":"seems this was not changed but just moved, consider not moving to reduce the diff","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"82bd085f1b8f9dae615f997801535e0df7e264b9","unresolved":false,"context_lines":[{"line_number":129,"context_line":"    _ENFORCER.set_rules(policies, overwrite)"},{"line_number":130,"context_line":""},{"line_number":131,"context_line":""},{"line_number":132,"context_line":"def get_resource_and_action(action):"},{"line_number":133,"context_line":"    \"\"\"Extract resource and action (write, read) from api operation.\"\"\""},{"line_number":134,"context_line":"    data \u003d action.split(\u0027:\u0027, 1)[0].split(\u0027_\u0027, 1)"},{"line_number":135,"context_line":"    return (\"%ss\" % data[-1], data[0] !\u003d \u0027get\u0027)"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_bca68451","line":132,"in_reply_to":"5a890539_210eed8d","updated":"2014-11-13 11:02:16.000000000","message":"Done","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"9f33bb81217ff5ab9f2c6130127fe00ec131e948","unresolved":false,"context_lines":[{"line_number":129,"context_line":"    _ENFORCER.set_rules(policies, overwrite)"},{"line_number":130,"context_line":""},{"line_number":131,"context_line":""},{"line_number":132,"context_line":"def get_resource_and_action(action):"},{"line_number":133,"context_line":"    \"\"\"Extract resource and action (write, read) from api operation.\"\"\""},{"line_number":134,"context_line":"    data \u003d action.split(\u0027:\u0027, 1)[0].split(\u0027_\u0027, 1)"},{"line_number":135,"context_line":"    return (\"%ss\" % data[-1], data[0] !\u003d \u0027get\u0027)"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_210eed8d","line":132,"in_reply_to":"5a890539_a694b3e2","updated":"2014-11-13 10:38:07.000000000","message":"Okay, I will move it up","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"b6388af5e7eb84c06fe141ced8170187ead29ffa","unresolved":false,"context_lines":[{"line_number":265,"context_line":"                reason\u003derr_reason)"},{"line_number":266,"context_line":"        super(OwnerCheck, self).__init__(kind, match)"},{"line_number":267,"context_line":""},{"line_number":268,"context_line":"    def __call__(self, target, creds, enforcer):"},{"line_number":269,"context_line":"        if self.target_field not in target:"},{"line_number":270,"context_line":"            # policy needs a plugin check"},{"line_number":271,"context_line":"            # target field is in the form resource:field"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_21f50dee","line":268,"updated":"2014-11-13 10:25:25.000000000","message":"So this changes the public API but I don\u0027t see any neutron changes related to this change. Where is it used?","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"f6613b88605385a5ec685b3f5e13ac3c87a70c92","unresolved":false,"context_lines":[{"line_number":265,"context_line":"                reason\u003derr_reason)"},{"line_number":266,"context_line":"        super(OwnerCheck, self).__init__(kind, match)"},{"line_number":267,"context_line":""},{"line_number":268,"context_line":"    def __call__(self, target, creds, enforcer):"},{"line_number":269,"context_line":"        if self.target_field not in target:"},{"line_number":270,"context_line":"            # policy needs a plugin check"},{"line_number":271,"context_line":"            # target field is in the form resource:field"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_bce3e431","line":268,"in_reply_to":"5a890539_016811f4","updated":"2014-11-13 10:44:59.000000000","message":"I see, thanks","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":7293,"name":"Elena Ezhova","email":"ezhovaelena19@gmail.com","username":"elena"},"change_message_id":"9f33bb81217ff5ab9f2c6130127fe00ec131e948","unresolved":false,"context_lines":[{"line_number":265,"context_line":"                reason\u003derr_reason)"},{"line_number":266,"context_line":"        super(OwnerCheck, self).__init__(kind, match)"},{"line_number":267,"context_line":""},{"line_number":268,"context_line":"    def __call__(self, target, creds, enforcer):"},{"line_number":269,"context_line":"        if self.target_field not in target:"},{"line_number":270,"context_line":"            # policy needs a plugin check"},{"line_number":271,"context_line":"            # target field is in the form resource:field"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_016811f4","line":268,"in_reply_to":"5a890539_21f50dee","updated":"2014-11-13 10:38:07.000000000","message":"Enforcer is required by the __call__method in common_policy.BaseCheck class from which all custom checks derive.","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"b6388af5e7eb84c06fe141ced8170187ead29ffa","unresolved":false,"context_lines":[{"line_number":349,"context_line":"        self.field \u003d field"},{"line_number":350,"context_line":"        self.value \u003d conv_func(value)"},{"line_number":351,"context_line":""},{"line_number":352,"context_line":"    def __call__(self, target_dict, cred_dict, enforcer):"},{"line_number":353,"context_line":"        target_value \u003d target_dict.get(self.field)"},{"line_number":354,"context_line":"        # target_value might be a boolean, explicitly compare with None"},{"line_number":355,"context_line":"        if target_value is None:"}],"source_content_type":"text/x-python","patch_set":21,"id":"5a890539_a1bf3dfa","line":352,"updated":"2014-11-13 10:25:25.000000000","message":"ditto","commit_id":"8d3714615ae2968a3f60eb51e7a7ae3d66de8aca"}],"neutron/tests/unit/test_api_v2.py":[{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":1028,"context_line":"        policy.init()"},{"line_number":1029,"context_line":"        rules \u003d {\u0027get_network:name\u0027: common_policy.parse_rule("},{"line_number":1030,"context_line":"            \"rule:admin_only\")}"},{"line_number":1031,"context_line":"        policy._ENFORCER.load_rules()"},{"line_number":1032,"context_line":"        policy.set_rules(rules, overwrite\u003dFalse)"},{"line_number":1033,"context_line":"        res \u003d self._test_get(tenant_id, tenant_id, 200)"},{"line_number":1034,"context_line":"        res \u003d self.deserialize(res)"}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_1852f466","line":1031,"updated":"2014-10-16 14:06:14.000000000","message":"Why do we need to call to load_rules() here?","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":1035,"context_line":"        try:"},{"line_number":1036,"context_line":"            self.assertNotIn(\u0027name\u0027, res[\u0027network\u0027])"},{"line_number":1037,"context_line":"        finally:"},{"line_number":1038,"context_line":"            policy._ENFORCER.load_rules(force_reload\u003dTrue)"},{"line_number":1039,"context_line":""},{"line_number":1040,"context_line":"    def _test_update(self, req_tenant_id, real_tenant_id, expected_code,"},{"line_number":1041,"context_line":"                     expect_errors\u003dFalse):"}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_0b3f00b5","line":1038,"updated":"2014-10-16 14:06:14.000000000","message":"Shouldn\u0027t we instead call to reset() + init() here to avoid implementation details? Also, how about either putting all the code including call to set_rules() under finally: clause to make sure we don\u0027t leave test policy cached?","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"fd4476b5c45fdde9b66c7c8564a4fb680af53c93","unresolved":false,"context_lines":[{"line_number":1035,"context_line":"        try:"},{"line_number":1036,"context_line":"            self.assertNotIn(\u0027name\u0027, res[\u0027network\u0027])"},{"line_number":1037,"context_line":"        finally:"},{"line_number":1038,"context_line":"            policy._ENFORCER.load_rules(force_reload\u003dTrue)"},{"line_number":1039,"context_line":""},{"line_number":1040,"context_line":"    def _test_update(self, req_tenant_id, real_tenant_id, expected_code,"},{"line_number":1041,"context_line":"                     expect_errors\u003dFalse):"}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_0e662eed","line":1038,"in_reply_to":"baa201ad_0b3f00b5","updated":"2014-10-16 14:12:20.000000000","message":"...or register the cleanup function via addCleanup before proceeding with testing?","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"faad7e5bd5035c1ba09d572a1bad551e6736c88c","unresolved":false,"context_lines":[{"line_number":1034,"context_line":"        try:"},{"line_number":1035,"context_line":"            self.assertNotIn(\u0027name\u0027, res[\u0027network\u0027])"},{"line_number":1036,"context_line":"        finally:"},{"line_number":1037,"context_line":"            policy.reset()"},{"line_number":1038,"context_line":""},{"line_number":1039,"context_line":"    def _test_update(self, req_tenant_id, real_tenant_id, expected_code,"},{"line_number":1040,"context_line":"                     expect_errors\u003dFalse):"}],"source_content_type":"text/x-python","patch_set":10,"id":"baa201ad_05250b5b","line":1037,"updated":"2014-10-17 15:38:08.000000000","message":"So what if e.g. _test_get crashes? will we be left with dirty enforcer?\n\n[I know that the issue is also present in the original version of code, but while we\u0027re at it, maybe it\u0027s worth making the test a bit more fail proof.]","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"}],"neutron/tests/unit/test_policy.py":[{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":53,"context_line":"        policy.enforce(self.context, action, self.target)"},{"line_number":54,"context_line":"        with open(tmpfilename, \"w\") as policyfile:"},{"line_number":55,"context_line":"            policyfile.write(\"\"\"{\"example:test\": \"!\"}\"\"\")"},{"line_number":56,"context_line":"        policy._ENFORCER.load_rules(True)"},{"line_number":57,"context_line":"        self.assertRaises(exceptions.PolicyNotAuthorized,"},{"line_number":58,"context_line":"                          policy.enforce,"},{"line_number":59,"context_line":"                          self.context,"}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_185cb44a","line":56,"updated":"2014-10-16 14:06:14.000000000","message":"I don\u0027t think we should rely on implementation details here. How about reloading rules by calling to reset() + init()?","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":78,"context_line":"            \"example:lowercase_admin\": \"role:admin or role:sysadmin\","},{"line_number":79,"context_line":"            \"example:uppercase_admin\": \"role:ADMIN or role:sysadmin\","},{"line_number":80,"context_line":"        }"},{"line_number":81,"context_line":"        policy.reset()"},{"line_number":82,"context_line":"        policy.init()"},{"line_number":83,"context_line":"        # NOTE(vish): then overload underlying rules"},{"line_number":84,"context_line":"        policy.set_rules(dict((k, common_policy.parse_rule(v))"}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_6b9c0cc1","line":81,"updated":"2014-10-16 14:06:14.000000000","message":"I suspect that reset() + init() pair is a good candidate to get its own utility function since it\u0027s called in several places to reset policy.","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":178,"context_line":"        self.context \u003d context.Context(\u0027fake\u0027, \u0027fake\u0027)"},{"line_number":179,"context_line":""},{"line_number":180,"context_line":"    def _set_rules(self, default_rule):"},{"line_number":181,"context_line":"        policy.reset()"},{"line_number":182,"context_line":"        rules \u003d dict((k, common_policy.parse_rule(v))"},{"line_number":183,"context_line":"                     for k, v in self.rules.items())"},{"line_number":184,"context_line":"        policy.init(rules\u003drules, default_rule\u003ddefault_rule, use_conf\u003dFalse)"}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_eb7c7c22","line":181,"updated":"2014-10-16 14:06:14.000000000","message":"How about writing the policy rules to a file and load them via public API? I guess this is why we needed to expose those default_rule and use_conf arguments, but I don\u0027t think we should make our API bloated just because of testing needs that we may easily overcome.","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"44d07aa7a9f543166ef39d033f927b7049db2c8d","unresolved":false,"context_lines":[{"line_number":191,"context_line":"        policy.enforce(self.context, \"example:noexist\", {})"},{"line_number":192,"context_line":""},{"line_number":193,"context_line":"    def test_default_not_found(self):"},{"line_number":194,"context_line":"        self._set_rules(\"default_noexist\")"},{"line_number":195,"context_line":"        self.assertRaises(exceptions.PolicyNotAuthorized, policy.enforce,"},{"line_number":196,"context_line":"                          self.context, \"example:noexist\", {})"},{"line_number":197,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"baa201ad_eb02bc3c","line":194,"updated":"2014-10-16 14:06:14.000000000","message":"It is the only place where you really need to set default_rule, and I doubt that the test is needed at all. Now that policy module raises PolicyNotAuthorized itself on KeyError due to missing default rule, all the code that we test here is really from oslo-incubator.\n\nI\u0027m for dropping the test case completely and removing default_rule and use_conf arguments from policy.init().","commit_id":"5b40007c746a697ba6e11e6184a1a54cbbdabd47"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"faad7e5bd5035c1ba09d572a1bad551e6736c88c","unresolved":false,"context_lines":[{"line_number":50,"context_line":"        action \u003d \"example:test\""},{"line_number":51,"context_line":"        with open(tmpfilename, \"w\") as policyfile:"},{"line_number":52,"context_line":"            policyfile.write(\"\"\"{\"example:test\": \"\"}\"\"\")"},{"line_number":53,"context_line":"        policy.init(policy_file\u003dtmpfilename)"},{"line_number":54,"context_line":"        policy.enforce(self.context, action, self.target)"},{"line_number":55,"context_line":"        with open(tmpfilename, \"w\") as policyfile:"},{"line_number":56,"context_line":"            policyfile.write(\"\"\"{\"example:test\": \"!\"}\"\"\")"}],"source_content_type":"text/x-python","patch_set":10,"id":"baa201ad_05dc2b45","line":53,"updated":"2014-10-17 15:38:08.000000000","message":"Why not setting the custom policy_file via cfg.CONF.policy_file? Then we\u0027ll be able to kill that remaining argument for init(), making API as clean and dumb as possible.","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"faad7e5bd5035c1ba09d572a1bad551e6736c88c","unresolved":false,"context_lines":[{"line_number":54,"context_line":"        policy.enforce(self.context, action, self.target)"},{"line_number":55,"context_line":"        with open(tmpfilename, \"w\") as policyfile:"},{"line_number":56,"context_line":"            policyfile.write(\"\"\"{\"example:test\": \"!\"}\"\"\")"},{"line_number":57,"context_line":"        # policy._ENFORCER.load_rules(True)"},{"line_number":58,"context_line":"        policy.reset()"},{"line_number":59,"context_line":"        policy.init(policy_file\u003dtmpfilename)"},{"line_number":60,"context_line":"        self.assertRaises(common_policy.PolicyNotAuthorized,"}],"source_content_type":"text/x-python","patch_set":10,"id":"baa201ad_a5135fff","line":57,"updated":"2014-10-17 15:38:08.000000000","message":"This line is probably leftover. If so, should be killed.","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"faad7e5bd5035c1ba09d572a1bad551e6736c88c","unresolved":false,"context_lines":[{"line_number":55,"context_line":"        with open(tmpfilename, \"w\") as policyfile:"},{"line_number":56,"context_line":"            policyfile.write(\"\"\"{\"example:test\": \"!\"}\"\"\")"},{"line_number":57,"context_line":"        # policy._ENFORCER.load_rules(True)"},{"line_number":58,"context_line":"        policy.reset()"},{"line_number":59,"context_line":"        policy.init(policy_file\u003dtmpfilename)"},{"line_number":60,"context_line":"        self.assertRaises(common_policy.PolicyNotAuthorized,"},{"line_number":61,"context_line":"                          policy.enforce,"}],"source_content_type":"text/x-python","patch_set":10,"id":"baa201ad_45a553a0","line":58,"updated":"2014-10-17 15:38:08.000000000","message":"That reset() + init() combo call is a good candidate for a tiny utility function. It\u0027s used in multiple places in the file.","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"faad7e5bd5035c1ba09d572a1bad551e6736c88c","unresolved":false,"context_lines":[{"line_number":208,"context_line":"    def setUp(self):"},{"line_number":209,"context_line":"        super(NeutronPolicyTestCase, self).setUp()"},{"line_number":210,"context_line":"        policy.reset()"},{"line_number":211,"context_line":"        # import pdb;pdb.set_trace()"},{"line_number":212,"context_line":"        policy.init()"},{"line_number":213,"context_line":"        self.addCleanup(policy.reset)"},{"line_number":214,"context_line":"        self.admin_only_legacy \u003d \"role:admin\""}],"source_content_type":"text/x-python","patch_set":10,"id":"baa201ad_65925758","line":211,"updated":"2014-10-17 15:38:08.000000000","message":"please kill that leftover line.","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"},{"author":{"_account_id":9656,"name":"Ihar Hrachyshka","email":"ihrachys@redhat.com","username":"ihrachys","status":"Red Hat Networking Systems Engineer"},"change_message_id":"faad7e5bd5035c1ba09d572a1bad551e6736c88c","unresolved":false,"context_lines":[{"line_number":396,"context_line":""},{"line_number":397,"context_line":"    def test_enforce_firewall_policy_shared(self):"},{"line_number":398,"context_line":"        action \u003d \"get_firewall_policy\""},{"line_number":399,"context_line":"        action \u003d \"get_firewall_policy\""},{"line_number":400,"context_line":"        target \u003d {\u0027shared\u0027: True, \u0027tenant_id\u0027: \u0027somebody_else\u0027}"},{"line_number":401,"context_line":"        result \u003d policy.enforce(self.context, action, target)"},{"line_number":402,"context_line":"        self.assertTrue(result)"}],"source_content_type":"text/x-python","patch_set":10,"id":"baa201ad_e58d6732","line":399,"updated":"2014-10-17 15:38:08.000000000","message":"please remove the duplicate.","commit_id":"aaef4b57726c99c412c1b0b8c7795ff73c6687d8"}]}
