diff options
| author | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-02-25 19:54:40 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-02-25 19:54:40 +0000 |
| commit | 18e16ab9f5be77764a810b2d6ac5ae8c5be6bb52 (patch) | |
| tree | e012d607f5cd709ae69ff7257f0d208f931d84f0 /nova/api | |
| parent | 8b37ae8c291a38407654859d7ff659ced92c0270 (diff) | |
| parent | fa6778586ab303f9e65aa3c50b80d20a4f097c6f (diff) | |
Add tests for 718999, fix a little brittle code introduced by the committed fix.
Also fix and test for a 500 if the auth token doesn't exist in the database.
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/auth.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py index dff69a7f2..6011e6115 100644 --- a/nova/api/openstack/auth.py +++ b/nova/api/openstack/auth.py @@ -26,6 +26,7 @@ import webob.dec from nova import auth from nova import context from nova import db +from nova import exception from nova import flags from nova import manager from nova import utils @@ -103,11 +104,14 @@ class AuthMiddleware(wsgi.Middleware): 2 days ago. """ ctxt = context.get_admin_context() - token = self.db.auth_token_get(ctxt, token_hash) + try: + token = self.db.auth_token_get(ctxt, token_hash) + except exception.NotFound: + return None if token: delta = datetime.datetime.now() - token.created_at if delta.days >= 2: - self.db.auth_token_destroy(ctxt, token.id) + self.db.auth_token_destroy(ctxt, token.token_hash) else: return self.auth.get_user(token.user_id) return None |
