summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorEric Day <eday@oddments.org>2010-10-14 18:17:56 -0700
committerEric Day <eday@oddments.org>2010-10-14 18:17:56 -0700
commita340d3fe1b8e1f657351c8a32ff74b3cbcc3a8ff (patch)
treed22a01658c5abae6c2cc4d8427a4c4c1a8c571c4 /nova/tests
parent7013fb5c8f5883bae46c2407b3a7beb4412081bc (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()