diff options
author | lin-hua-cheng <os.lcheng@gmail.com> | 2015-08-31 14:45:16 -0700 |
---|---|---|
committer | lin-hua-cheng <os.lcheng@gmail.com> | 2015-09-09 19:50:38 -0700 |
commit | 463b2ff3a616b02edd2ca9c7fd31953bf7c938e5 (patch) | |
tree | bd65b58d74db69b9a2cccb900e5bd8ba881babd5 /openstack_auth/tests/tests.py | |
parent | 87f2158899ddea28fb6e8387889a29ee4d026fd9 (diff) | |
download | django_openstack_auth-463b2ff3a616b02edd2ca9c7fd31953bf7c938e5.tar.gz |
IDP specific websso
Allow handling websso requests per IDP.
Change-Id: Ie20e21eb95c2250e301165012eef5591243620e9
Implements: bp federation-idp-websso
Diffstat (limited to 'openstack_auth/tests/tests.py')
-rw-r--r-- | openstack_auth/tests/tests.py | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/openstack_auth/tests/tests.py b/openstack_auth/tests/tests.py index 39ecfa0..0901429 100644 --- a/openstack_auth/tests/tests.py +++ b/openstack_auth/tests/tests.py @@ -11,6 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import uuid + from django.conf import settings from django.contrib import auth from django.core.urlresolvers import reverse @@ -863,14 +865,24 @@ class OpenStackAuthTestsWebSSO(OpenStackAuthTestsMixin, test.TestCase): self.data = data_v3.generate_test_data() self.ks_client_module = client_v3 + self.idp_id = uuid.uuid4().hex + self.idp_oidc_id = uuid.uuid4().hex + self.idp_saml2_id = uuid.uuid4().hex + settings.OPENSTACK_API_VERSIONS['identity'] = 3 settings.OPENSTACK_KEYSTONE_URL = 'http://localhost:5000/v3' settings.WEBSSO_ENABLED = True settings.WEBSSO_CHOICES = ( ('credentials', 'Keystone Credentials'), ('oidc', 'OpenID Connect'), - ('saml2', 'Security Assertion Markup Language') + ('saml2', 'Security Assertion Markup Language'), + (self.idp_oidc_id, 'IDP OIDC'), + (self.idp_saml2_id, 'IDP SAML2') ) + settings.WEBSSO_IDP_MAPPING = { + self.idp_oidc_id: (self.idp_id, 'oidc'), + self.idp_saml2_id: (self.idp_id, 'saml2') + } self.mox.StubOutClassWithMocks(token_endpoint, 'Token') self.mox.StubOutClassWithMocks(auth_v3, 'Token') @@ -885,8 +897,10 @@ class OpenStackAuthTestsWebSSO(OpenStackAuthTestsMixin, test.TestCase): self.assertContains(response, 'credentials') self.assertContains(response, 'oidc') self.assertContains(response, 'saml2') + self.assertContains(response, self.idp_oidc_id) + self.assertContains(response, self.idp_saml2_id) - def test_websso_redirect(self): + def test_websso_redirect_by_protocol(self): origin = 'http://testserver/auth/websso/' protocol = 'oidc' redirect_url = ('%s/auth/OS-FEDERATION/websso/%s?origin=%s' % @@ -901,6 +915,23 @@ class OpenStackAuthTestsWebSSO(OpenStackAuthTestsMixin, test.TestCase): self.assertRedirects(response, redirect_url, status_code=302, target_status_code=404) + def test_websso_redirect_by_idp(self): + origin = 'http://testserver/auth/websso/' + protocol = 'oidc' + redirect_url = ('%s/auth/OS-FEDERATION/identity_providers/%s' + '/protocols/%s/websso?origin=%s' % + (settings.OPENSTACK_KEYSTONE_URL, self.idp_id, + protocol, origin)) + + form_data = {'auth_type': self.idp_oidc_id, + 'region': settings.OPENSTACK_KEYSTONE_URL} + url = reverse('login') + + # POST to the page and redirect to keystone. + response = self.client.post(url, form_data) + self.assertRedirects(response, redirect_url, status_code=302, + target_status_code=404) + def test_websso_login(self): projects = [self.data.project_one, self.data.project_two] unscoped = self.data.federated_unscoped_access_info |