summaryrefslogtreecommitdiff
path: root/keystone_tempest_plugin/tests/api/identity/v3/test_service_providers.py
diff options
context:
space:
mode:
Diffstat (limited to 'keystone_tempest_plugin/tests/api/identity/v3/test_service_providers.py')
-rw-r--r--keystone_tempest_plugin/tests/api/identity/v3/test_service_providers.py206
1 files changed, 0 insertions, 206 deletions
diff --git a/keystone_tempest_plugin/tests/api/identity/v3/test_service_providers.py b/keystone_tempest_plugin/tests/api/identity/v3/test_service_providers.py
deleted file mode 100644
index a6522f9..0000000
--- a/keystone_tempest_plugin/tests/api/identity/v3/test_service_providers.py
+++ /dev/null
@@ -1,206 +0,0 @@
1# Copyright 2016 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tempest.lib.common.utils import data_utils
16from tempest.lib import decorators
17from tempest.lib import exceptions as lib_exc
18
19from keystone_tempest_plugin.tests.api.identity.v3 import fixtures
20from keystone_tempest_plugin.tests import base
21
22DEFAULT_RELAY_STATE_PREFIX = 'ss:mem:'
23
24
25class ServiceProvidersTest(base.BaseIdentityTest):
26
27 def _assert_service_provider_attributes(self, sp, sp_id, sp_ref=None):
28 self.assertIn('id', sp)
29 self.assertEqual(sp_id, sp['id'])
30
31 self.assertIn('auth_url', sp)
32 self.assertIn('sp_url', sp)
33
34 # Check the optional attributes have been set
35 self.assertIn('description', sp)
36 self.assertIn('enabled', sp)
37 self.assertIn('relay_state_prefix', sp)
38
39 if sp_ref:
40 self.assertEqual(sp_ref['auth_url'], sp['auth_url'])
41 self.assertEqual(sp_ref['sp_url'], sp['sp_url'])
42 self.assertEqual(sp_ref['description'], sp['description'])
43
44 if 'enabled' in sp_ref:
45 self.assertEqual(sp_ref['enabled'], sp['enabled'])
46
47 if 'relay_state_prefix' in sp_ref:
48 self.assertEqual(
49 sp_ref['relay_state_prefix'], sp['relay_state_prefix'])
50
51 def _add_cleanup(self, sp_id):
52 self.addCleanup(
53 self.sps_client.delete_service_provider, sp_id)
54
55 def _create_sp(self, sp_id, sp_ref):
56 sp = self.sps_client.create_service_provider(
57 sp_id, **sp_ref)['service_provider']
58 self.addCleanup(self.sps_client.delete_service_provider, sp_id)
59 return sp
60
61 @decorators.idempotent_id('6fae0971-5acb-4559-ba25-96f1fd7e5385')
62 def test_service_provider_create(self):
63 sp_id = data_utils.rand_uuid_hex()
64 sp_ref = fixtures.sp_ref()
65 sp = self._create_sp(sp_id, sp_ref)
66
67 # The service provider is disabled by default
68 sp_ref['enabled'] = False
69
70 # The relay_state_prefix should have been set to the default value
71 sp_ref['relay_state_prefix'] = DEFAULT_RELAY_STATE_PREFIX
72
73 self._assert_service_provider_attributes(sp, sp_id, sp_ref)
74
75 @decorators.attr(type=['negative'])
76 @decorators.idempotent_id('d9d7454c-50b7-4966-aedb-b9d520a41409')
77 def test_service_provider_create_without_mandatory_attributes(self):
78 sp_id = data_utils.rand_uuid_hex()
79 self.assertRaises(
80 lib_exc.BadRequest,
81 self.sps_client.create_service_provider,
82 sp_id)
83
84 @decorators.attr(type=['negative'])
85 @decorators.idempotent_id('f77ed1c0-c428-44a7-9364-e8e4362c360a')
86 def test_service_provider_create_with_bad_attributes(self):
87 sp_id = data_utils.rand_uuid_hex()
88 sp_ref = fixtures.sp_ref()
89
90 # The auth_url must follow a URL regex
91 sp_ref['auth_url'] = data_utils.rand_uuid_hex()
92 self.assertRaises(
93 lib_exc.BadRequest,
94 self.sps_client.create_service_provider,
95 sp_id,
96 **sp_ref)
97
98 sp_ref = fixtures.sp_ref()
99
100 # The sp_url must follow a URL regex
101 sp_ref['sp_url'] = data_utils.rand_uuid_hex()
102 self.assertRaises(
103 lib_exc.BadRequest,
104 self.sps_client.create_service_provider,
105 sp_id,
106 **sp_ref)
107
108 @decorators.idempotent_id('8550b419-f212-4e34-a8fa-7ff64f8a7fd3')
109 def test_service_provider_create_with_enabled_true(self):
110 sp_id = data_utils.rand_uuid_hex()
111 sp_ref = fixtures.sp_ref(enabled=True)
112 sp = self._create_sp(sp_id, sp_ref)
113
114 self._assert_service_provider_attributes(sp, sp_id, sp_ref)
115
116 @decorators.idempotent_id('0e319a14-1548-474e-a406-273c6b1c1f2d')
117 def test_service_provider_create_with_relay_state_prefix(self):
118 sp_id = data_utils.rand_uuid_hex()
119 sp_ref = fixtures.sp_ref(
120 enabled=True, relay_state_prefix=data_utils.rand_uuid_hex())
121 sp = self._create_sp(sp_id, sp_ref)
122
123 self._assert_service_provider_attributes(sp, sp_id, sp_ref)
124
125 @decorators.idempotent_id('7df78c7a-9265-4b4f-9630-193b7f07d9eb')
126 def test_service_provider_get(self):
127 sp_id = data_utils.rand_uuid_hex()
128 sp_create = self._create_sp(sp_id, fixtures.sp_ref())
129
130 sp_get = self.sps_client.show_service_provider(sp_id)[
131 'service_provider']
132
133 self._assert_service_provider_attributes(sp_get, sp_id, sp_create)
134
135 @decorators.idempotent_id('9237cea0-fbeb-4d64-8347-46c567e1d78f')
136 def test_service_provider_list(self):
137 sp_ids = []
138 for _ in range(3):
139 sp_id = data_utils.rand_uuid_hex()
140 self._create_sp(sp_id, fixtures.sp_ref())
141 sp_ids.append(sp_id)
142
143 sp_list = self.sps_client.list_service_providers()['service_providers']
144 fetched_ids = [fetched_sp['id'] for fetched_sp in sp_list]
145
146 for sp_id in sp_ids:
147 self.assertIn(sp_id, fetched_ids)
148
149 @decorators.idempotent_id('bb68653f-fbba-4f20-ac1b-7b318a557366')
150 def test_service_provider_update(self):
151 sp_id = data_utils.rand_uuid_hex()
152 sp = self._create_sp(sp_id, fixtures.sp_ref(enabled=True))
153
154 # The service provider should be enabled
155 self.assertTrue(sp['enabled'])
156
157 sp = self.sps_client.update_service_provider(
158 sp_id, enabled=False)['service_provider']
159
160 # The service provider should be now disabled
161 self.assertFalse(sp['enabled'])
162
163 sp_get = self.sps_client.show_service_provider(sp_id)[
164 'service_provider']
165 self.assertFalse(sp_get['enabled'])
166
167 @decorators.attr(type=['negative'])
168 @decorators.idempotent_id('91ce1183-1a15-4598-ae5f-85cfa98a1c77')
169 def test_service_provider_update_with_bad_attributes_fails(self):
170 sp_id = data_utils.rand_uuid_hex()
171 self._create_sp(sp_id, fixtures.sp_ref())
172
173 # The auth_url must follow a URL regex
174 self.assertRaises(
175 lib_exc.BadRequest,
176 self.sps_client.update_service_provider,
177 sp_id,
178 auth_url=data_utils.rand_uuid_hex())
179
180 # The sp_url must follow a URL regex
181 self.assertRaises(
182 lib_exc.BadRequest,
183 self.sps_client.update_service_provider,
184 sp_id,
185 auth_url=data_utils.rand_uuid_hex())
186
187 @decorators.idempotent_id('7553579b-9a9e-45dd-9ada-70d906b516c0')
188 def test_service_providers_in_token(self):
189 # Create some enabled service providers
190 enabled_sps = []
191 for _ in range(2):
192 sp_id = data_utils.rand_uuid_hex()
193 self._create_sp(sp_id, fixtures.sp_ref(enabled=True))
194 enabled_sps.append(sp_id)
195
196 # Create some disabled service providers
197 for _ in range(2):
198 sp_id = data_utils.rand_uuid_hex()
199 self._create_sp(sp_id, fixtures.sp_ref(enabled=False))
200
201 sps_in_token_ids = [
202 sp['id'] for sp in
203 self.sps_client.get_service_providers_in_token()]
204
205 # Should be equal to the enabled_sps list
206 self.assertItemsEqual(enabled_sps, sps_in_token_ids)