summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorEric Day <eday@oddments.org>2010-10-16 08:19:04 +0000
committerTarmac <>2010-10-16 08:19:04 +0000
commitfbe47ae3be6b18007ff8e4a74ad6efe748421dc5 (patch)
tree0749392c4da8a859ce2a6971735aa15682adab12 /nova/tests
parent24de0631b622014323a4348ebc8408fadbafe99a (diff)
parenta340d3fe1b8e1f657351c8a32ff74b3cbcc3a8ff (diff)
Added test case to reproduce bug #660668 and provided a fix by using the user_id from the auth layer instead of the username header.
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/test_auth.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/test_auth.py b/nova/tests/api/openstack/test_auth.py
index bbfb0fcea..61d17d7e8 100644
--- a/nova/tests/api/openstack/test_auth.py
+++ b/nova/tests/api/openstack/test_auth.py
@@ -106,5 +106,40 @@ class Test(unittest.TestCase):
result = req.get_response(nova.api.API())
self.assertEqual(result.status, '401 Unauthorized')
+
+class TestLimiter(unittest.TestCase):
+ def setUp(self):
+ self.stubs = stubout.StubOutForTesting()
+ self.stubs.Set(nova.api.openstack.auth.BasicApiAuthManager,
+ '__init__', fakes.fake_auth_init)
+ fakes.FakeAuthManager.auth_data = {}
+ fakes.FakeAuthDatabase.data = {}
+ fakes.stub_out_networking(self.stubs)
+
+ def tearDown(self):
+ self.stubs.UnsetAll()
+ fakes.fake_data_store = {}
+
+ def test_authorize_token(self):
+ f = fakes.FakeAuthManager()
+ f.add_user('derp', nova.auth.manager.User(1, 'herp', None, None, None))
+
+ req = webob.Request.blank('/v1.0/')
+ req.headers['X-Auth-User'] = 'herp'
+ req.headers['X-Auth-Key'] = 'derp'
+ result = req.get_response(nova.api.API())
+ self.assertEqual(len(result.headers['X-Auth-Token']), 40)
+
+ token = result.headers['X-Auth-Token']
+ self.stubs.Set(nova.api.openstack, 'APIRouter',
+ fakes.FakeRouter)
+ req = webob.Request.blank('/v1.0/fake')
+ req.method = 'POST'
+ req.headers['X-Auth-Token'] = token
+ result = req.get_response(nova.api.API())
+ self.assertEqual(result.status, '200 OK')
+ self.assertEqual(result.headers['X-Test-Success'], 'True')
+
+
if __name__ == '__main__':
unittest.main()