diff options
author | Chris Dent <chdent@redhat.com> | 2015-06-18 09:49:56 +0000 |
---|---|---|
committer | gordon chung <gord@live.ca> | 2015-11-24 15:16:18 +0000 |
commit | ea821de5d5d4117c2b6694e00f40014f708efff7 (patch) | |
tree | 4fd4c7dd72cd1195fb1f4efc00d9fc5e10bbab09 | |
parent | 38358e0f324d704921c86d2b51145d4784495feb (diff) | |
download | ceilometer-ea821de5d5d4117c2b6694e00f40014f708efff7.tar.gz |
Make acl_scenarios tests' keystonemiddleware cache work flexibly
Token cache keys in keystonemiddleware 2.0 are sha256 hashes of the
token key. This is _not_ the case in keystonemiddleware <2.0. This
change adjusts the FakeMemcache to support both types of key.
Closes-Bug: #1519382
Change-Id: Idcba48b227e8921a67f5af27f723810704ae790b
(cherry picked from commit 41d2cc9bf2f87fcb24de05e71a879ab7a7829409)
-rw-r--r-- | ceilometer/tests/api/v2/test_acl_scenarios.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ceilometer/tests/api/v2/test_acl_scenarios.py b/ceilometer/tests/api/v2/test_acl_scenarios.py index b00ec7b1..05fa9e68 100644 --- a/ceilometer/tests/api/v2/test_acl_scenarios.py +++ b/ceilometer/tests/api/v2/test_acl_scenarios.py @@ -15,6 +15,7 @@ """Test ACL.""" import datetime +import hashlib import json from oslo_utils import timeutils @@ -32,9 +33,13 @@ VALID_TOKEN2 = '4562138218392832' class FakeMemcache(object): - @staticmethod - def get(key): - if key == "tokens/%s" % VALID_TOKEN: + + TOKEN_HASH = hashlib.sha256(VALID_TOKEN).hexdigest() + TOKEN2_HASH = hashlib.sha256(VALID_TOKEN2).hexdigest() + + def get(self, key): + if (key == "tokens/%s" % VALID_TOKEN or + key == "tokens/%s" % self.TOKEN_HASH): dt = timeutils.utcnow() + datetime.timedelta(minutes=5) return json.dumps(({'access': { 'token': {'id': VALID_TOKEN, @@ -48,7 +53,8 @@ class FakeMemcache(object): {'name': 'admin'}, ]}, }}, timeutils.isotime(dt))) - if key == "tokens/%s" % VALID_TOKEN2: + if (key == "tokens/%s" % VALID_TOKEN2 or + key == "tokens/%s" % self.TOKEN2_HASH): dt = timeutils.utcnow() + datetime.timedelta(minutes=5) return json.dumps(({'access': { 'token': {'id': VALID_TOKEN2, |