Clear the auth cache when testing the same url twice with different results

This commit is contained in:
Min RK
2018-11-12 14:35:47 +01:00
parent 3a0bacde3a
commit 7f1c91d8f4
2 changed files with 9 additions and 0 deletions

View File

@@ -99,6 +99,11 @@ class _ExpiringDict(dict):
except KeyError: except KeyError:
return default return default
def clear(self):
"""Clear the cache"""
self.values.clear()
self.timestamps.clear()
class HubAuth(SingletonConfigurable): class HubAuth(SingletonConfigurable):
"""A class for authenticating with JupyterHub """A class for authenticating with JupyterHub

View File

@@ -170,6 +170,10 @@ def test_hub_authenticated(request):
assert r.status_code == 302 assert r.status_code == 302
assert auth.login_url in r.headers['Location'] assert auth.login_url in r.headers['Location']
# clear the cache because we are going to request
# the same url again with a different result
auth.cache.clear()
# upstream 403 # upstream 403
m.get(bad_url, status_code=403) m.get(bad_url, status_code=403)
r = requests.get('http://127.0.0.1:%i' % port, r = requests.get('http://127.0.0.1:%i' % port,