summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-08-31 09:46:34 +0000
committerGerrit Code Review <review@openstack.org>2012-08-31 09:46:34 +0000
commit5cbb9d0ed8505f97c082336e7777c72893338b02 (patch)
tree24748a88bd1e8a76da2a0d77140133611555bdb0
parent55c1c97b8466a40725bd1cd9de0a3c6db3328534 (diff)
parent454693d250e7085cefef30e1b43608477f34a345 (diff)
downloadoslo-5cbb9d0ed8505f97c082336e7777c72893338b02.tar.gz
oslo-5cbb9d0ed8505f97c082336e7777c72893338b02.tar.xz
oslo-5cbb9d0ed8505f97c082336e7777c72893338b02.zip
Merge "Allow non-string items in the creds dict."
-rw-r--r--openstack/common/policy.py2
-rw-r--r--tests/unit/test_policy.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/openstack/common/policy.py b/openstack/common/policy.py
index fd1d7d3..4cd5a43 100644
--- a/openstack/common/policy.py
+++ b/openstack/common/policy.py
@@ -296,5 +296,5 @@ def _check_generic(brain, match_kind, match, target_dict, cred_dict):
# TODO(termie): do dict inspection via dot syntax
match = match % target_dict
if match_kind in cred_dict:
- return match == cred_dict[match_kind]
+ return match == unicode(cred_dict[match_kind])
return False
diff --git a/tests/unit/test_policy.py b/tests/unit/test_policy.py
index e7f391f..5d77a6f 100644
--- a/tests/unit/test_policy.py
+++ b/tests/unit/test_policy.py
@@ -406,6 +406,13 @@ class CheckTestCase(unittest.TestCase):
self.assertEqual(result, True)
+ def test_generic_boolean(self):
+ result = policy._check_generic(None, "is_admin", "True",
+ {},
+ dict(is_admin=True))
+
+ self.assertEqual(result, True)
+
def test_generic_no_key(self):
result = policy._check_generic(None, "tenant", "%(tenant_id)s",
dict(tenant_id="spam"),