Add identity providers integration tests
This patch adds a first set of tests in the keystone tempest plugin.
These tests are for the Identity Provider API (part of the Federated
Identity API).
To run the tests install keystone and run (in tempest):
$ tox -e all-plugin -- keystone
Change-Id: I64ebba2e57aa952a2262f9e0ad143cea7de259c0
diff --git a/keystone_tempest_plugin/services/identity/__init__.py b/keystone_tempest_plugin/services/identity/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/keystone_tempest_plugin/services/identity/__init__.py
diff --git a/keystone_tempest_plugin/services/identity/clients.py b/keystone_tempest_plugin/services/identity/clients.py
new file mode 100644
index 0000000..f796cd7
--- /dev/null
+++ b/keystone_tempest_plugin/services/identity/clients.py
@@ -0,0 +1,36 @@
+# Copyright 2016 Red Hat, Inc.
+#
+# 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 tempest import config
+from tempest.lib.common import rest_client
+
+
+CONF = config.CONF
+
+# We only use the identity catalog type
+SERVICE_TYPE = 'identity'
+
+
+class Identity(rest_client.RestClient):
+ """Tempest REST client for keystone."""
+
+ # Used by the superclass to build the correct URL paths
+ api_version = 'v3'
+
+ def __init__(self, auth_provider):
+ super(Identity, self).__init__(
+ auth_provider,
+ SERVICE_TYPE,
+ CONF.identity.region,
+ endpoint_type='adminURL')
diff --git a/keystone_tempest_plugin/services/identity/v3/__init__.py b/keystone_tempest_plugin/services/identity/v3/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/keystone_tempest_plugin/services/identity/v3/__init__.py
diff --git a/keystone_tempest_plugin/services/identity/v3/identity_providers_client.py b/keystone_tempest_plugin/services/identity/v3/identity_providers_client.py
new file mode 100644
index 0000000..38d35df
--- /dev/null
+++ b/keystone_tempest_plugin/services/identity/v3/identity_providers_client.py
@@ -0,0 +1,79 @@
+# Copyright 2016 Red Hat, Inc.
+#
+# 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 json
+
+from tempest.lib.common import rest_client
+
+from keystone_tempest_plugin.services.identity import clients
+
+
+class IdentityProvidersClient(clients.Identity):
+
+ subpath = 'OS-FEDERATION/identity_providers'
+
+ def _build_path(self, idp_id=None):
+ return '%s/%s' % (self.subpath, idp_id) if idp_id else self.subpath
+
+ def create_identity_provider(self, idp_id, **kwargs):
+ """Create an identity provider.
+
+ :param str idp_id: The ID to be used to create the Identity Provider.
+ :param kwargs: All optional attributes: description (str), enabled
+ (boolean) and remote_ids (list).
+ """
+ put_body = json.dumps({'identity_provider': kwargs})
+ url = self._build_path(idp_id)
+ resp, body = self.put(url, put_body)
+ self.expected_success(201, resp.status)
+ body = json.loads(body)
+ idp = rest_client.ResponseBody(resp, body)
+ return idp
+
+ def list_identity_providers(self):
+ """List the identity providers."""
+ url = self._build_path()
+ resp, body = self.get(url)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return rest_client.ResponseBody(resp, body)
+
+ def show_identity_provider(self, idp_id):
+ """Get an identity provider."""
+ url = self._build_path(idp_id)
+ resp, body = self.get(url)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return rest_client.ResponseBody(resp, body)
+
+ def delete_identity_provider(self, idp_id):
+ """Delete an identity provider."""
+ url = self._build_path(idp_id)
+ resp, body = self.delete(url)
+ self.expected_success(204, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
+ def update_identity_provider(self, idp_id, **kwargs):
+ """Update an identity provider.
+
+ :param str idp_id: The ID from the Identity Provider to be updated.
+ :param kwargs: All optional attributes to update: description (str),
+ enabled (boolean) and remote_ids (list).
+ """
+ patch_body = json.dumps({'identity_provider': kwargs})
+ url = self._build_path(idp_id)
+ resp, body = self.patch(url, patch_body)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return rest_client.ResponseBody(resp, body)