From e0d8189442345e08cc86be80975540e241b935a8 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 29 Sep 2020 11:55:10 +0200 Subject: [PATCH] e2e: update for new saml-test-sp, pull image before run --- e2e/test_provider_oauth2_oidc.py | 1 + e2e/test_provider_proxy.py | 2 ++ e2e/test_provider_saml.py | 38 ++++++++++++++++++++++---------- e2e/utils.py | 1 + 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/e2e/test_provider_oauth2_oidc.py b/e2e/test_provider_oauth2_oidc.py index c59419695..46a6090ba 100644 --- a/e2e/test_provider_oauth2_oidc.py +++ b/e2e/test_provider_oauth2_oidc.py @@ -51,6 +51,7 @@ class TestProviderOAuth2OIDC(SeleniumTestCase): """Setup client saml-sp container which we test SAML against""" sleep(1) client: DockerClient = from_env() + client.images.pull("beryju/oidc-test-client") container = client.containers.run( image="beryju/oidc-test-client", detach=True, diff --git a/e2e/test_provider_proxy.py b/e2e/test_provider_proxy.py index 411ef73a8..7b6e7fc72 100644 --- a/e2e/test_provider_proxy.py +++ b/e2e/test_provider_proxy.py @@ -39,6 +39,7 @@ class TestProviderProxy(SeleniumTestCase): def start_proxy(self, outpost: Outpost) -> Container: """Start proxy container based on outpost created""" client: DockerClient = from_env() + client.images.pull("beryju/oidc-test-client") container = client.containers.run( image="beryju/passbook-proxy:latest", detach=True, @@ -111,6 +112,7 @@ class TestProviderProxyConnect(ChannelsLiveServerTestCase): def start_proxy(self, outpost: Outpost) -> Container: """Start proxy container based on outpost created""" client: DockerClient = from_env() + client.images.pull("beryju/oidc-test-client") container = client.containers.run( image="beryju/passbook-proxy:latest", detach=True, diff --git a/e2e/test_provider_saml.py b/e2e/test_provider_saml.py index ec4afb157..4ea12c948 100644 --- a/e2e/test_provider_saml.py +++ b/e2e/test_provider_saml.py @@ -1,4 +1,5 @@ """test SAML Provider flow""" +from json import loads from sys import platform from time import sleep from unittest.case import skipUnless @@ -35,6 +36,7 @@ class TestProviderSAML(SeleniumTestCase): def setup_client(self, provider: SAMLProvider) -> Container: """Setup client saml-sp container which we test SAML against""" client: DockerClient = from_env() + client.images.pull("beryju/oidc-test-client") container = client.containers.run( image="beryju/saml-test-sp", detach=True, @@ -92,10 +94,14 @@ class TestProviderSAML(SeleniumTestCase): self.driver.find_element(By.ID, "id_password").send_keys(USER().username) self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER) self.wait_for_url("http://localhost:9009/") - self.assertEqual( - self.driver.find_element(By.CSS_SELECTOR, "pre").text, - f"Hello, {USER().name}!", - ) + + body = loads(self.driver.find_element(By.CSS_SELECTOR, "pre").text) + + self.assertEqual(body["attr"]["cn"], [USER().name]) + self.assertEqual(body["attr"]["displayName"], [USER().username]) + self.assertEqual(body["attr"]["eduPersonPrincipalName"], [USER().email]) + self.assertEqual(body["attr"]["mail"], [USER().email]) + self.assertEqual(body["attr"]["uid"], [str(USER().pk)]) def test_sp_initiated_explicit(self): """test SAML Provider flow SP-initiated flow (explicit consent)""" @@ -130,10 +136,14 @@ class TestProviderSAML(SeleniumTestCase): sleep(1) self.driver.find_element(By.CSS_SELECTOR, "[type=submit]").click() self.wait_for_url("http://localhost:9009/") - self.assertEqual( - self.driver.find_element(By.CSS_SELECTOR, "pre").text, - f"Hello, {USER().name}!", - ) + + body = loads(self.driver.find_element(By.CSS_SELECTOR, "pre").text) + + self.assertEqual(body["attr"]["cn"], [USER().name]) + self.assertEqual(body["attr"]["displayName"], [USER().username]) + self.assertEqual(body["attr"]["eduPersonPrincipalName"], [USER().email]) + self.assertEqual(body["attr"]["mail"], [USER().email]) + self.assertEqual(body["attr"]["uid"], [str(USER().pk)]) def test_idp_initiated_implicit(self): """test SAML Provider flow IdP-initiated flow (implicit consent)""" @@ -169,10 +179,14 @@ class TestProviderSAML(SeleniumTestCase): self.driver.find_element(By.ID, "id_password").send_keys(Keys.ENTER) sleep(1) self.wait_for_url("http://localhost:9009/") - self.assertEqual( - self.driver.find_element(By.CSS_SELECTOR, "pre").text, - f"Hello, {USER().name}!", - ) + + body = loads(self.driver.find_element(By.CSS_SELECTOR, "pre").text) + + self.assertEqual(body["attr"]["cn"], [USER().name]) + self.assertEqual(body["attr"]["displayName"], [USER().username]) + self.assertEqual(body["attr"]["eduPersonPrincipalName"], [USER().email]) + self.assertEqual(body["attr"]["mail"], [USER().email]) + self.assertEqual(body["attr"]["uid"], [str(USER().pk)]) def test_sp_initiated_denied(self): """test SAML Provider flow SP-initiated flow (Policy denies access)""" diff --git a/e2e/utils.py b/e2e/utils.py index 151791b5e..e0c7db689 100644 --- a/e2e/utils.py +++ b/e2e/utils.py @@ -47,6 +47,7 @@ class SeleniumTestCase(StaticLiveServerTestCase): def _start_container(self, specs: Dict[str, Any]) -> Container: client: DockerClient = from_env() + client.images.pull(specs['image']) container = client.containers.run(**specs) if "healthcheck" not in specs: return container