Unlimit oslo.utils + Make test_rest keystone cache work with keystonemiddleware 2.0
1. tooz wants a more recent version of oslo.utils
2. 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.
keystonemiddleware also breaks WebTest linting, so turn that off
until there has been progress on fixing that.
(cherry-picked from b33fe3fd81
)
Change-Id: Id7ddffd4ef5175bae5888df32a5e73d2a6eabd80
This commit is contained in:
parent
cdfc4dd180
commit
3fb737740e
|
@ -44,14 +44,18 @@ load_tests = testscenarios.load_tests_apply_scenarios
|
|||
|
||||
class FakeMemcache(object):
|
||||
VALID_TOKEN_ADMIN = '4562138218392830'
|
||||
ADMIN_TOKEN_HASH = hashlib.sha256(
|
||||
VALID_TOKEN_ADMIN.encode('utf-8')).hexdigest()
|
||||
USER_ID_ADMIN = str(uuid.uuid4())
|
||||
PROJECT_ID_ADMIN = str(uuid.uuid4())
|
||||
|
||||
VALID_TOKEN = '4562138218392831'
|
||||
TOKEN_HASH = hashlib.sha256(VALID_TOKEN.encode('utf-8')).hexdigest()
|
||||
USER_ID = str(uuid.uuid4())
|
||||
PROJECT_ID = str(uuid.uuid4())
|
||||
|
||||
VALID_TOKEN_2 = '4562138218392832'
|
||||
TOKEN_2_HASH = hashlib.sha256(VALID_TOKEN_2.encode('utf-8')).hexdigest()
|
||||
# We replace "-" to simulate a middleware that would send UUID in a non
|
||||
# normalized format.
|
||||
USER_ID_2 = str(uuid.uuid4()).replace("-", "")
|
||||
|
@ -61,7 +65,8 @@ class FakeMemcache(object):
|
|||
dt = datetime.datetime(
|
||||
year=datetime.MAXYEAR, month=12, day=31,
|
||||
hour=23, minute=59, second=59)
|
||||
if key == "tokens/%s" % self.VALID_TOKEN_ADMIN:
|
||||
if (key == "tokens/%s" % self.ADMIN_TOKEN_HASH or
|
||||
key == "tokens/%s" % self.VALID_TOKEN_ADMIN):
|
||||
return json.dumps(({'access': {
|
||||
'token': {'id': self.VALID_TOKEN_ADMIN,
|
||||
'expires': timeutils.isotime(dt)},
|
||||
|
@ -74,7 +79,8 @@ class FakeMemcache(object):
|
|||
{'name': 'admin'},
|
||||
]},
|
||||
}}, timeutils.isotime(dt)))
|
||||
elif key == "tokens/%s" % self.VALID_TOKEN:
|
||||
elif (key == "tokens/%s" % self.TOKEN_HASH or
|
||||
key == "tokens/%s" % self.VALID_TOKEN):
|
||||
return json.dumps(({'access': {
|
||||
'token': {'id': self.VALID_TOKEN,
|
||||
'expires': timeutils.isotime(dt)},
|
||||
|
@ -87,7 +93,8 @@ class FakeMemcache(object):
|
|||
{'name': 'member'},
|
||||
]},
|
||||
}}, timeutils.isotime(dt)))
|
||||
elif key == "tokens/%s" % self.VALID_TOKEN_2:
|
||||
elif (key == "tokens/%s" % self.TOKEN_2_HASH or
|
||||
key == "tokens/%s" % self.VALID_TOKEN_2):
|
||||
return json.dumps(({'access': {
|
||||
'token': {'id': self.VALID_TOKEN_2,
|
||||
'expires': timeutils.isotime(dt)},
|
||||
|
@ -173,8 +180,12 @@ class RestTest(tests_base.TestCase, testscenarios.TestWithScenarios):
|
|||
self.conf.set_override("middlewares",
|
||||
self.middlewares, group="api")
|
||||
|
||||
# TODO(chdent) Linting is turned off until a
|
||||
# keystonemiddleware bug is resolved.
|
||||
# See: https://bugs.launchpad.net/keystonemiddleware/+bug/1466499
|
||||
self.app = TestingApp(pecan.load_app(c, cfg=self.conf),
|
||||
auth=bool(self.conf.api.middlewares))
|
||||
auth=bool(self.conf.api.middlewares),
|
||||
lint=False)
|
||||
|
||||
def test_deserialize_force_json(self):
|
||||
with self.app.use_admin_user():
|
||||
|
|
|
@ -4,7 +4,7 @@ oslo.db<1.8.0,>=1.7.0
|
|||
oslo.log<1.1.0,>=1.0.0
|
||||
oslo.policy>=0.3.0
|
||||
oslo.serialization<1.5.0,>=1.4.0
|
||||
oslo.utils<1.5.0,>=1.4.0
|
||||
oslo.utils>=1.4.0
|
||||
oslosphinx>=2.2.0 # Apache-2.0
|
||||
pandas
|
||||
pecan!=0.8
|
||||
|
|
|
@ -4,7 +4,7 @@ oslo.db<1.8.0,>=1.7.0
|
|||
oslo.log<1.1.0,>=1.0.0
|
||||
oslo.policy>=0.3.0
|
||||
oslo.serialization<1.5.0,>=1.4.0
|
||||
oslo.utils<1.5.0,>=1.4.0
|
||||
oslo.utils>=1.4.0
|
||||
oslosphinx>=2.2.0 # Apache-2.0
|
||||
pandas
|
||||
pecan!=0.8
|
||||
|
|
Loading…
Reference in New Issue