summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorMonsyne Dragon <mdragon@rackspace.com>2011-03-10 22:14:53 +0000
committerMonsyne Dragon <mdragon@rackspace.com>2011-03-10 22:14:53 +0000
commitbe66b329d5b94ffbfb782355ef342eadbaed72a5 (patch)
tree5d23e1bccc5d52cee5acf7fe3c1ddcee60329d12 /nova
parent9f1847ca334b3a35130d3f6113808d7b2a949877 (diff)
downloadnova-be66b329d5b94ffbfb782355ef342eadbaed72a5.tar.gz
nova-be66b329d5b94ffbfb782355ef342eadbaed72a5.tar.xz
nova-be66b329d5b94ffbfb782355ef342eadbaed72a5.zip
Fix a fer nits jaypipes found in review.
Diffstat (limited to 'nova')
-rw-r--r--nova/api/openstack/accounts.py18
-rw-r--r--nova/api/openstack/users.py4
-rw-r--r--nova/tests/api/openstack/test_accounts.py6
-rw-r--r--nova/tests/api/openstack/test_auth.py15
-rw-r--r--nova/tests/api/openstack/test_users.py2
5 files changed, 25 insertions, 20 deletions
diff --git a/nova/api/openstack/accounts.py b/nova/api/openstack/accounts.py
index 3b90d2776..dd88c3390 100644
--- a/nova/api/openstack/accounts.py
+++ b/nova/api/openstack/accounts.py
@@ -21,6 +21,7 @@ from nova import log as logging
from nova import wsgi
from nova.auth import manager
+from nova.api.openstack import faults
FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.api.openstack')
@@ -44,11 +45,17 @@ class Controller(wsgi.Controller):
self.manager = manager.AuthManager()
def _check_admin(self, context):
- """ We cannot depend on the db layer to check for admin access
- for the auth manager, so we do it here """
+ """We cannot depend on the db layer to check for admin access
+ for the auth manager, so we do it here"""
if not context.is_admin:
raise exception.NotAuthorized(_("Not admin user."))
+ def index(self, req):
+ raise faults.Fault(exc.HTTPNotImplemented())
+
+ def detail(self, req):
+ raise faults.Fault(exc.HTTPNotImplemented())
+
def show(self, req, id):
"""Return data about the given account id"""
account = self.manager.get_project(id)
@@ -59,8 +66,13 @@ class Controller(wsgi.Controller):
self.manager.delete_project(id)
return {}
+ def create(self, req):
+ """We use update with create-or-update semantics
+ because the id comes from an external source"""
+ raise faults.Fault(exc.HTTPNotImplemented())
+
def update(self, req, id):
- """ This is really create or update. """
+ """This is really create or update."""
self._check_admin(req.environ['nova.context'])
env = self._deserialize(req.body, req)
description = env['account'].get('description')
diff --git a/nova/api/openstack/users.py b/nova/api/openstack/users.py
index 83ebec964..5bb20a718 100644
--- a/nova/api/openstack/users.py
+++ b/nova/api/openstack/users.py
@@ -45,8 +45,8 @@ class Controller(wsgi.Controller):
self.manager = manager.AuthManager()
def _check_admin(self, context):
- """ We cannot depend on the db layer to check for admin access
- for the auth manager, so we do it here """
+ """We cannot depend on the db layer to check for admin access
+ for the auth manager, so we do it here"""
if not context.is_admin:
raise exception.NotAuthorized(_("Not admin user"))
diff --git a/nova/tests/api/openstack/test_accounts.py b/nova/tests/api/openstack/test_accounts.py
index 746f02f57..78fceb47c 100644
--- a/nova/tests/api/openstack/test_accounts.py
+++ b/nova/tests/api/openstack/test_accounts.py
@@ -14,9 +14,10 @@
# under the License.
+import json
+
import stubout
import webob
-import json
import nova.api
import nova.api.openstack.auth
@@ -47,8 +48,7 @@ class AccountsTest(test.TestCase):
fake_init)
self.stubs.Set(nova.api.openstack.accounts.Controller, '_check_admin',
fake_admin_check)
- fakes.FakeAuthManager.auth_data = {}
- fakes.FakeAuthManager.projects = {}
+ fakes.FakeAuthManager.clear_fakes()
fakes.FakeAuthDatabase.data = {}
fakes.stub_out_networking(self.stubs)
fakes.stub_out_rate_limiting(self.stubs)
diff --git a/nova/tests/api/openstack/test_auth.py b/nova/tests/api/openstack/test_auth.py
index 49f90879d..437a79ec5 100644
--- a/nova/tests/api/openstack/test_auth.py
+++ b/nova/tests/api/openstack/test_auth.py
@@ -51,9 +51,7 @@ class Test(test.TestCase):
def test_authorize_user(self):
f = fakes.FakeAuthManager()
- u = nova.auth.manager.User(1, 'herp', None, None, None)
- f.add_user('derp', u)
- f.create_project('test', u)
+ 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'
@@ -67,9 +65,7 @@ class Test(test.TestCase):
def test_authorize_token(self):
f = fakes.FakeAuthManager()
- u = nova.auth.manager.User(1, 'herp', None, None, None)
- f.add_user('derp', u)
- f.create_project('test', u)
+ f.add_user('derp', nova.auth.manager.User(1, 'herp', None, None, None))
req = webob.Request.blank('/v1.0/', {'HTTP_HOST': 'foo'})
req.headers['X-Auth-User'] = 'herp'
@@ -86,7 +82,7 @@ class Test(test.TestCase):
token = result.headers['X-Auth-Token']
self.stubs.Set(nova.api.openstack, 'APIRouter',
fakes.FakeRouter)
- req = webob.Request.blank('/v1.0/test/fake')
+ req = webob.Request.blank('/v1.0/fake')
req.headers['X-Auth-Token'] = token
result = req.get_response(fakes.wsgi_app())
self.assertEqual(result.status, '200 OK')
@@ -180,9 +176,6 @@ class TestLimiter(test.TestCase):
def test_authorize_token(self):
f = fakes.FakeAuthManager()
- u = nova.auth.manager.User(1, 'herp', None, None, None)
- f.add_user('derp', u)
- f.create_project('test', u)
f.add_user('derp', nova.auth.manager.User(1, 'herp', None, None, None))
req = webob.Request.blank('/v1.0/')
@@ -194,7 +187,7 @@ class TestLimiter(test.TestCase):
token = result.headers['X-Auth-Token']
self.stubs.Set(nova.api.openstack, 'APIRouter',
fakes.FakeRouter)
- req = webob.Request.blank('/v1.0/test/fake')
+ req = webob.Request.blank'/v1.0/fake')
req.method = 'POST'
req.headers['X-Auth-Token'] = token
result = req.get_response(fakes.wsgi_app())
diff --git a/nova/tests/api/openstack/test_users.py b/nova/tests/api/openstack/test_users.py
index 14c7897f0..1edefe713 100644
--- a/nova/tests/api/openstack/test_users.py
+++ b/nova/tests/api/openstack/test_users.py
@@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+import json
import stubout
import webob
-import json
import nova.api
import nova.api.openstack.auth