From a9c6fb1d39f84f79f97333f59ef757cfd9dc8fd2 Mon Sep 17 00:00:00 2001 From: Dolph Mathews Date: Sun, 25 Mar 2012 11:40:44 -0700 Subject: ec2-credential-crud 404 (bug 963056) ec2-credential-create ec2-credential-delete ec2-credential-get ec2-credential-list Change-Id: If8bfb77017f55c24738baf18b937c78b179831e5 --- keystone/contrib/ec2/core.py | 2 ++ tests/test_keystoneclient.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/keystone/contrib/ec2/core.py b/keystone/contrib/ec2/core.py index 80604c59..4449b6bb 100644 --- a/keystone/contrib/ec2/core.py +++ b/keystone/contrib/ec2/core.py @@ -239,6 +239,7 @@ class Ec2Controller(wsgi.Application): """ if not self._is_admin(context): self._assert_identity(context, user_id) + self._assert_valid_user_id(context, user_id) creds = self._get_credentials(context, credential_id) return {'credential': creds} @@ -256,6 +257,7 @@ class Ec2Controller(wsgi.Application): self._assert_identity(context, user_id) self._assert_owner(context, user_id, credential_id) + self._assert_valid_user_id(context, user_id) self._get_credentials(context, credential_id) return self.ec2_api.delete_credential(context, credential_id) diff --git a/tests/test_keystoneclient.py b/tests/test_keystoneclient.py index d18ba90d..95a06ecb 100644 --- a/tests/test_keystoneclient.py +++ b/tests/test_keystoneclient.py @@ -481,6 +481,41 @@ class KeystoneClientTests(object): creds = client.ec2.list(user_id=self.user_foo['id']) self.assertEquals(creds, []) + def test_ec2_credentials_create_404(self): + from keystoneclient import exceptions as client_exceptions + client = self.get_client() + self.assertRaises(client_exceptions.NotFound, + client.ec2.create, + user_id=uuid.uuid4().hex, + tenant_id=self.tenant_bar['id']) + self.assertRaises(client_exceptions.NotFound, + client.ec2.create, + user_id=self.user_foo['id'], + tenant_id=uuid.uuid4().hex) + + def test_ec2_credentials_delete_404(self): + from keystoneclient import exceptions as client_exceptions + client = self.get_client() + self.assertRaises(client_exceptions.NotFound, + client.ec2.delete, + user_id=uuid.uuid4().hex, + access=uuid.uuid4().hex) + + def test_ec2_credentials_get_404(self): + from keystoneclient import exceptions as client_exceptions + client = self.get_client() + self.assertRaises(client_exceptions.NotFound, + client.ec2.get, + user_id=uuid.uuid4().hex, + access=uuid.uuid4().hex) + + def test_ec2_credentials_list_404(self): + from keystoneclient import exceptions as client_exceptions + client = self.get_client() + self.assertRaises(client_exceptions.NotFound, + client.ec2.list, + user_id=uuid.uuid4().hex) + def test_ec2_credentials_list_user_forbidden(self): from keystoneclient import exceptions as client_exceptions -- cgit