From b4fc32afac139483b5f43f7e6ac50ee589823cbb Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 14 Aug 2020 18:09:49 +0200 Subject: [PATCH] e2e: fix typo, log when docker healthcheck fails --- e2e/test_flows_enroll.py | 6 +++++- e2e/test_provider_oauth.py | 4 ++++ e2e/test_provider_oidc.py | 4 ++++ e2e/test_provider_saml.py | 4 ++++ e2e/test_source_saml.py | 6 +++++- e2e/test_sources_oauth.py | 3 +++ 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/e2e/test_flows_enroll.py b/e2e/test_flows_enroll.py index cb25e8482..19b10f66b 100644 --- a/e2e/test_flows_enroll.py +++ b/e2e/test_flows_enroll.py @@ -4,6 +4,7 @@ from time import sleep from django.test import override_settings from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec +from structlog import get_logger from docker import DockerClient, from_env from docker.models.containers import Container @@ -18,6 +19,8 @@ from passbook.stages.prompt.models import FieldTypes, Prompt, PromptStage from passbook.stages.user_login.models import UserLoginStage from passbook.stages.user_write.models import UserWriteStage +LOGGER = get_logger() + class TestFlowsEnroll(SeleniumTestCase): """Test Enroll flow""" @@ -30,7 +33,7 @@ class TestFlowsEnroll(SeleniumTestCase): """Setup test IdP container""" client: DockerClient = from_env() container = client.containers.run( - image="mailhog/mailhog:v.1.0.1", + image="mailhog/mailhog:v1.0.1", detach=True, network_mode="host", auto_remove=True, @@ -45,6 +48,7 @@ class TestFlowsEnroll(SeleniumTestCase): status = container.attrs.get("State", {}).get("Health", {}).get("Status") if status == "healthy": return container + LOGGER.info("Container failed healthcheck") sleep(1) def tearDown(self): diff --git a/e2e/test_provider_oauth.py b/e2e/test_provider_oauth.py index 8733a15e7..6c8f348f0 100644 --- a/e2e/test_provider_oauth.py +++ b/e2e/test_provider_oauth.py @@ -4,6 +4,7 @@ from time import sleep from oauth2_provider.generators import generate_client_id, generate_client_secret from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys +from structlog import get_logger from docker import DockerClient, from_env from docker.models.containers import Container @@ -15,6 +16,8 @@ from passbook.policies.expression.models import ExpressionPolicy from passbook.policies.models import PolicyBinding from passbook.providers.oauth.models import OAuth2Provider +LOGGER = get_logger() + class TestProviderOAuth(SeleniumTestCase): """test OAuth Provider flow""" @@ -61,6 +64,7 @@ class TestProviderOAuth(SeleniumTestCase): status = container.attrs.get("State", {}).get("Health", {}).get("Status") if status == "healthy": return container + LOGGER.info("Container failed healthcheck") sleep(1) def tearDown(self): diff --git a/e2e/test_provider_oidc.py b/e2e/test_provider_oidc.py index 779a048bf..fa8ff6531 100644 --- a/e2e/test_provider_oidc.py +++ b/e2e/test_provider_oidc.py @@ -7,6 +7,7 @@ from oidc_provider.models import Client, ResponseType from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as ec +from structlog import get_logger from docker import DockerClient, from_env from docker.models.containers import Container @@ -18,6 +19,8 @@ from passbook.policies.expression.models import ExpressionPolicy from passbook.policies.models import PolicyBinding from passbook.providers.oidc.models import OpenIDProvider +LOGGER = get_logger() + class TestProviderOIDC(SeleniumTestCase): """test OpenID Provider flow""" @@ -63,6 +66,7 @@ class TestProviderOIDC(SeleniumTestCase): status = container.attrs.get("State", {}).get("Health", {}).get("Status") if status == "healthy": return container + LOGGER.info("Container failed healthcheck") sleep(1) def tearDown(self): diff --git a/e2e/test_provider_saml.py b/e2e/test_provider_saml.py index 8151d24e8..1fbd1a774 100644 --- a/e2e/test_provider_saml.py +++ b/e2e/test_provider_saml.py @@ -3,6 +3,7 @@ from time import sleep from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys +from structlog import get_logger from docker import DockerClient, from_env from docker.models.containers import Container @@ -19,6 +20,8 @@ from passbook.providers.saml.models import ( SAMLProvider, ) +LOGGER = get_logger() + class TestProviderSAML(SeleniumTestCase): """test SAML Provider flow""" @@ -54,6 +57,7 @@ class TestProviderSAML(SeleniumTestCase): status = container.attrs.get("State", {}).get("Health", {}).get("Status") if status == "healthy": return container + LOGGER.info("Container failed healthcheck") sleep(1) def tearDown(self): diff --git a/e2e/test_source_saml.py b/e2e/test_source_saml.py index 4ea9b2d6d..99fa37fb3 100644 --- a/e2e/test_source_saml.py +++ b/e2e/test_source_saml.py @@ -4,6 +4,7 @@ from time import sleep from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as ec +from structlog import get_logger from docker import DockerClient, from_env from docker.models.containers import Container @@ -13,6 +14,8 @@ from passbook.crypto.models import CertificateKeyPair from passbook.flows.models import Flow from passbook.sources.saml.models import SAMLBindingTypes, SAMLSource +LOGGER = get_logger() + IDP_CERT = """-----BEGIN CERTIFICATE----- MIIDXTCCAkWgAwIBAgIJALmVVuDWu4NYMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX @@ -76,7 +79,7 @@ class TestSourceSAML(SeleniumTestCase): """Setup test IdP container""" client: DockerClient = from_env() container = client.containers.run( - image="kristophjunge/test-saml-idp", + image="kristophjunge/test-saml-idp:1.15", detach=True, network_mode="host", auto_remove=True, @@ -97,6 +100,7 @@ class TestSourceSAML(SeleniumTestCase): status = container.attrs.get("State", {}).get("Health", {}).get("Status") if status == "healthy": return container + LOGGER.info("Container failed healthcheck") sleep(1) def tearDown(self): diff --git a/e2e/test_sources_oauth.py b/e2e/test_sources_oauth.py index b9dafa20a..62f0255cc 100644 --- a/e2e/test_sources_oauth.py +++ b/e2e/test_sources_oauth.py @@ -6,6 +6,7 @@ from oauth2_provider.generators import generate_client_secret from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as ec +from structlog import get_logger from yaml import safe_dump from docker import DockerClient, from_env @@ -17,6 +18,7 @@ from passbook.sources.oauth.models import OAuthSource TOKEN_URL = "http://127.0.0.1:5556/dex/token" CONFIG_PATH = "/tmp/dex.yml" +LOGGER = get_logger() class TestSourceOAuth(SeleniumTestCase): @@ -86,6 +88,7 @@ class TestSourceOAuth(SeleniumTestCase): status = container.attrs.get("State", {}).get("Health", {}).get("Status") if status == "healthy": return container + LOGGER.info("Container failed healthcheck") sleep(1) def create_objects(self):