summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNisha Yadav <ynisha11@gmail.com>2016-08-03 00:57:57 +0530
committerSteve Martinelli <s.martinelli@gmail.com>2016-08-17 20:33:27 +0000
commit95478c7ebeed3956c7d9b6de2dc41615dfa2c1e2 (patch)
tree77c33c614ee698ebabb0fae3212e07484031ed6f
parent63d039032cd425ef379ffa83af034b23cc80a674 (diff)
downloadpython-keystoneclient-95478c7ebeed3956c7d9b6de2dc41615dfa2c1e2.tar.gz
Add ec2 functional tests
Adds functional tests for ec2. Change-Id: I19988661e2d92a3e501a04e2a0e2d773ddcc36e9
-rw-r--r--keystoneclient/tests/functional/v3/client_fixtures.py18
-rw-r--r--keystoneclient/tests/functional/v3/test_ec2.py70
2 files changed, 88 insertions, 0 deletions
diff --git a/keystoneclient/tests/functional/v3/client_fixtures.py b/keystoneclient/tests/functional/v3/client_fixtures.py
index 7f6a5b8..4b54b88 100644
--- a/keystoneclient/tests/functional/v3/client_fixtures.py
+++ b/keystoneclient/tests/functional/v3/client_fixtures.py
@@ -201,3 +201,21 @@ class Credential(Base):
'project': self.project}
self.entity = self.client.credentials.create(**self.ref)
self.addCleanup(self.client.credentials.delete, self.entity)
+
+
+class EC2(Base):
+
+ def __init__(self, client, user_id, project_id):
+ super(EC2, self).__init__(client)
+ self.user_id = user_id
+ self.project_id = project_id
+
+ def setUp(self):
+ super(EC2, self).setUp()
+
+ self.ref = {'user_id': self.user_id,
+ 'project_id': self.project_id}
+ self.entity = self.client.ec2.create(**self.ref)
+ self.addCleanup(self.client.ec2.delete,
+ self.user_id,
+ self.entity.access)
diff --git a/keystoneclient/tests/functional/v3/test_ec2.py b/keystoneclient/tests/functional/v3/test_ec2.py
new file mode 100644
index 0000000..6bdc68b
--- /dev/null
+++ b/keystoneclient/tests/functional/v3/test_ec2.py
@@ -0,0 +1,70 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from keystoneauth1.exceptions import http
+
+from keystoneclient.tests.functional import base
+from keystoneclient.tests.functional.v3 import client_fixtures as fixtures
+
+
+class EC2TestCase(base.V3ClientTestCase):
+
+ def check_ec2(self, ec2, ec2_ref=None):
+ self.assertIn('self', ec2.links)
+ self.assertIn('/users/%s/credentials/OS-EC2/%s'
+ % (ec2.user_id, ec2.access), ec2.links['self'])
+
+ if ec2_ref:
+ self.assertEqual(ec2_ref['user_id'], ec2.user_id)
+ self.assertEqual(ec2_ref['project_id'], ec2.tenant_id)
+
+ else:
+ self.assertIsNotNone(ec2.user_id)
+ self.assertIsNotNone(ec2.tenant_id)
+
+ def test_create_ec2(self):
+ user = fixtures.User(self.client, self.project_domain_id)
+ self.useFixture(user)
+ project = fixtures.Project(self.client, self.project_domain_id)
+ self.useFixture(project)
+
+ ec2_ref = {'user_id': user.id,
+ 'project_id': project.id}
+ ec2 = self.client.ec2.create(**ec2_ref)
+
+ self.addCleanup(self.client.ec2.delete, user.id, ec2.access)
+ self.check_ec2(ec2, ec2_ref)
+
+ def test_get_ec2(self):
+ user = fixtures.User(self.client, self.project_domain_id)
+ self.useFixture(user)
+ project = fixtures.Project(self.client, self.project_domain_id)
+ self.useFixture(project)
+
+ ec2 = fixtures.EC2(self.client, user_id=user.id, project_id=project.id)
+ self.useFixture(ec2)
+
+ ec2_ret = self.client.ec2.get(user.id, ec2.access)
+ self.check_ec2(ec2_ret, ec2.ref)
+
+ def test_delete_ec2(self):
+ user = fixtures.User(self.client, self.project_domain_id)
+ self.useFixture(user)
+ project = fixtures.Project(self.client, self.project_domain_id)
+ self.useFixture(project)
+
+ ec2 = self.client.ec2.create(user.id, project.id)
+
+ self.client.ec2.delete(user.id, ec2.access)
+ self.assertRaises(http.NotFound,
+ self.client.ec2.get,
+ user.id, ec2.access)