summaryrefslogtreecommitdiff
path: root/keystoneclient/tests/functional
diff options
context:
space:
mode:
authorRodrigo Duarte <rduartes@redhat.com>2016-03-15 13:47:49 -0300
committerRodrigo Duarte <rduartes@redhat.com>2016-04-29 11:55:26 -0300
commitf663c66c103b44c9d1b2b94f46f753e8db73804d (patch)
tree3b6d0218c6c240e497422c9fe954b4c6d48e3cab /keystoneclient/tests/functional
parenta4ca83b840b831e1324eef6c517065b92575b558 (diff)
downloadpython-keystoneclient-f663c66c103b44c9d1b2b94f46f753e8db73804d.tar.gz
Add federation related tests
This patch adds the test_federation file with some tests for Identity Providers, the tests are not supposed to be exhaustive, they are rather simple and intend to cover the basic actions in the Identity Provider handling. More complete tests should be added later. Change-Id: Ibe618dcd646912060b1785d8d72fd526dd4a083b
Diffstat (limited to 'keystoneclient/tests/functional')
-rw-r--r--keystoneclient/tests/functional/v3/test_federation.py106
1 files changed, 106 insertions, 0 deletions
diff --git a/keystoneclient/tests/functional/v3/test_federation.py b/keystoneclient/tests/functional/v3/test_federation.py
new file mode 100644
index 0000000..da31266
--- /dev/null
+++ b/keystoneclient/tests/functional/v3/test_federation.py
@@ -0,0 +1,106 @@
+# 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.
+
+import uuid
+
+from keystoneauth1.exceptions import http
+
+from keystoneclient.tests.functional import base
+
+
+class TestIdentityProviders(base.V3ClientTestCase):
+
+ def test_idp_create(self):
+ idp_id = uuid.uuid4().hex
+ # Create an identity provider just passing an ID
+ idp = self.client.federation.identity_providers.create(id=idp_id)
+ self.addCleanup(
+ self.client.federation.identity_providers.delete, idp_id)
+
+ self.assertEqual(idp_id, idp.id)
+ self.assertEqual([], idp.remote_ids)
+ self.assertFalse(idp.enabled)
+
+ def test_idp_create_enabled_true(self):
+ # Create an enabled identity provider
+ idp_id = uuid.uuid4().hex
+ idp = self.client.federation.identity_providers.create(
+ id=idp_id, enabled=True)
+ self.addCleanup(
+ self.client.federation.identity_providers.delete, idp_id)
+
+ self.assertEqual(idp_id, idp.id)
+ self.assertEqual([], idp.remote_ids)
+ self.assertTrue(idp.enabled)
+
+ def test_idp_create_with_remote_ids(self):
+ # Create an enabled identity provider with remote IDs
+ idp_id = uuid.uuid4().hex
+ remote_ids = [uuid.uuid4().hex, uuid.uuid4().hex]
+ idp = self.client.federation.identity_providers.create(
+ id=idp_id, enabled=True, remote_ids=remote_ids)
+ self.addCleanup(
+ self.client.federation.identity_providers.delete, idp_id)
+
+ self.assertEqual(idp_id, idp.id)
+ self.assertIn(remote_ids[0], idp.remote_ids)
+ self.assertIn(remote_ids[1], idp.remote_ids)
+ self.assertTrue(idp.enabled)
+
+ def test_idp_list(self):
+ idp_ids = []
+ for _ in range(3):
+ idp_id = uuid.uuid4().hex
+ self.client.federation.identity_providers.create(id=idp_id)
+ self.addCleanup(
+ self.client.federation.identity_providers.delete, idp_id)
+ idp_ids.append(idp_id)
+
+ idp_list = self.client.federation.identity_providers.list()
+ fetched_ids = [fetched_idp.id for fetched_idp in idp_list]
+ for idp_id in idp_ids:
+ self.assertIn(idp_id, fetched_ids)
+
+ def test_idp_get(self):
+ idp_id = uuid.uuid4().hex
+ remote_ids = [uuid.uuid4().hex, uuid.uuid4().hex]
+ idp_create = self.client.federation.identity_providers.create(
+ id=idp_id, enabled=True, remote_ids=remote_ids)
+ self.addCleanup(
+ self.client.federation.identity_providers.delete, idp_id)
+
+ idp_get = self.client.federation.identity_providers.get(idp_id)
+ self.assertEqual(idp_create.id, idp_get.id)
+ self.assertEqual(idp_create.enabled, idp_get.enabled)
+ self.assertIn(idp_create.remote_ids[0], idp_get.remote_ids)
+ self.assertIn(idp_create.remote_ids[1], idp_get.remote_ids)
+
+ def test_idp_delete(self):
+ idp_id = uuid.uuid4().hex
+ self.client.federation.identity_providers.create(id=idp_id)
+
+ # Get should not raise an error
+ self.client.federation.identity_providers.get(idp_id)
+
+ # Delete it
+ self.client.federation.identity_providers.delete(idp_id)
+
+ # Now get should raise an error
+ self.assertRaises(
+ http.NotFound,
+ self.client.federation.identity_providers.get,
+ idp_id)
+
+ # Should not be present in the identity provider list
+ idp_list = self.client.federation.identity_providers.list()
+ fetched_ids = [fetched_idp.id for fetched_idp in idp_list]
+ self.assertNotIn(idp_id, fetched_ids)