Merge lp:~justin-fathomdb/nova/justinsb-api-fix-auth into lp:~hudson-openstack/nova/trunk

Proposed by justinsb
Status: Merged
Approved by: Soren Hansen
Approved revision: 702
Merged at revision: 709
Proposed branch: lp:~justin-fathomdb/nova/justinsb-api-fix-auth
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 71 lines (+11/-7)
3 files modified
nova/api/openstack/auth.py (+2/-2)
nova/tests/api/openstack/fakes.py (+6/-2)
nova/tests/api/openstack/test_auth.py (+3/-3)
To merge this branch: bzr merge lp:~justin-fathomdb/nova/justinsb-api-fix-auth
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Devin Carlen (community) Approve
Review via email: mp+50409@code.launchpad.net

Description of the change

The OpenStack API was using the 'secret' as the 'access key'. There is an 'access key' and there is a 'secret key'. Access key ~= username. Secret key ~= password. This fix is necessary for the OpenStack Python API bindings to log in.

To post a comment you must log in.
702. By justinsb

Fix FakeAuthManager so that unit tests pass; I believe it was matching the wrong field

Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Jay Pipes (jaypipes) wrote :

A bit worrying that this issue is just now showing up, and that our test cases didn't catch this properly...but regardless, good catch and fix.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/openstack/auth.py'
2--- nova/api/openstack/auth.py 2011-02-14 22:54:04 +0000
3+++ nova/api/openstack/auth.py 2011-02-19 07:36:32 +0000
4@@ -121,8 +121,8 @@
5 req - webob.Request object
6 """
7 ctxt = context.get_admin_context()
8- user = self.auth.get_user_from_access_key(key)
9- if user and user.name == username:
10+ user = self.auth.get_user_from_access_key(username)
11+ if user and user.secret == key:
12 token_hash = hashlib.sha1('%s%s%f' % (username, key,
13 time.time())).hexdigest()
14 token_dict = {}
15
16=== modified file 'nova/tests/api/openstack/fakes.py'
17--- nova/tests/api/openstack/fakes.py 2011-01-17 18:49:11 +0000
18+++ nova/tests/api/openstack/fakes.py 2011-02-19 07:36:32 +0000
19@@ -221,7 +221,8 @@
20 class FakeAuthManager(object):
21 auth_data = {}
22
23- def add_user(self, key, user):
24+ def add_user(self, user):
25+ key = user.id
26 FakeAuthManager.auth_data[key] = user
27
28 def get_user(self, uid):
29@@ -234,7 +235,10 @@
30 return None
31
32 def get_user_from_access_key(self, key):
33- return FakeAuthManager.auth_data.get(key, None)
34+ for k, v in FakeAuthManager.auth_data.iteritems():
35+ if v.access == key:
36+ return v
37+ return None
38
39
40 class FakeRateLimiter(object):
41
42=== modified file 'nova/tests/api/openstack/test_auth.py'
43--- nova/tests/api/openstack/test_auth.py 2011-01-06 07:08:01 +0000
44+++ nova/tests/api/openstack/test_auth.py 2011-02-19 07:36:32 +0000
45@@ -48,7 +48,7 @@
46
47 def test_authorize_user(self):
48 f = fakes.FakeAuthManager()
49- f.add_user('derp', nova.auth.manager.User(1, 'herp', None, None, None))
50+ f.add_user(nova.auth.manager.User(1, 'herp', 'herp', 'derp', None))
51
52 req = webob.Request.blank('/v1.0/')
53 req.headers['X-Auth-User'] = 'herp'
54@@ -62,7 +62,7 @@
55
56 def test_authorize_token(self):
57 f = fakes.FakeAuthManager()
58- f.add_user('derp', nova.auth.manager.User(1, 'herp', None, None, None))
59+ f.add_user(nova.auth.manager.User(1, 'herp', 'herp', 'derp', None))
60
61 req = webob.Request.blank('/v1.0/', {'HTTP_HOST': 'foo'})
62 req.headers['X-Auth-User'] = 'herp'
63@@ -144,7 +144,7 @@
64
65 def test_authorize_token(self):
66 f = fakes.FakeAuthManager()
67- f.add_user('derp', nova.auth.manager.User(1, 'herp', None, None, None))
68+ f.add_user(nova.auth.manager.User(1, 'herp', 'herp', 'derp', None))
69
70 req = webob.Request.blank('/v1.0/')
71 req.headers['X-Auth-User'] = 'herp'