From cd98e063eb3bbf5e2e574f61f1062f611707321d Mon Sep 17 00:00:00 2001
From: Kelvin Lui <kelvinlittle@yahoo.com>
Date: Thu, 30 Jul 2015 14:04:31 -0400
Subject: [PATCH] Introduce functional test for Identity Provider

Identity Provider currently doesn't have test coverage.

Change-Id: Iea2e705f9d2303f58516f08a7526135988032025
---
 functional/tests/identity/v3/test_identity.py | 19 ++++++++++++++++++
 functional/tests/identity/v3/test_idp.py      | 20 +++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 functional/tests/identity/v3/test_idp.py

diff --git a/functional/tests/identity/v3/test_identity.py b/functional/tests/identity/v3/test_identity.py
index cd11e200af..bf3da167fa 100644
--- a/functional/tests/identity/v3/test_identity.py
+++ b/functional/tests/identity/v3/test_identity.py
@@ -42,6 +42,8 @@ class IdentityTests(test.TestCase):
     ENDPOINT_LIST_HEADERS = ['ID', 'Region', 'Service Name', 'Service Type',
                              'Enabled', 'Interface', 'URL']
 
+    IDENTITY_PROVIDER_FIELDS = ['description', 'enabled', 'id', 'remote_ids']
+
     @classmethod
     def setUpClass(cls):
         if hasattr(super(IdentityTests, cls), 'setUpClass'):
@@ -253,3 +255,20 @@ class IdentityTests(test.TestCase):
                 self.openstack,
                 'endpoint delete %s' % endpoint['id'])
         return endpoint['id']
+
+    def _create_dummy_idp(self, add_clean_up=True):
+        identity_provider = data_utils.rand_name('IdentityProvider')
+        description = data_utils.rand_name('description')
+        raw_output = self.openstack(
+            'identity provider create '
+            ' %(name)s '
+            '--description %(description)s '
+            '--enable ' % {'name': identity_provider,
+                           'description': description})
+        items = self.parse_show(raw_output)
+        self.assert_show_fields(items, self.IDENTITY_PROVIDER_FIELDS)
+        if add_clean_up:
+            self.addCleanup(
+                self.openstack,
+                'identity provider delete %s' % identity_provider)
+        return identity_provider
diff --git a/functional/tests/identity/v3/test_idp.py b/functional/tests/identity/v3/test_idp.py
new file mode 100644
index 0000000000..6a07f158d0
--- /dev/null
+++ b/functional/tests/identity/v3/test_idp.py
@@ -0,0 +1,20 @@
+#    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 functional.tests.identity.v3 import test_identity
+
+
+class IdentityProviderTests(test_identity.IdentityTests):
+    # Introduce functional test case for command 'Identity Provider'
+
+    def test_idp_create(self):
+        self._create_dummy_idp()