diff --git a/e2e/docker-compose.yml b/e2e/docker-compose.yml index 9a8d71f93..1786d5c5e 100644 --- a/e2e/docker-compose.yml +++ b/e2e/docker-compose.yml @@ -1,34 +1,11 @@ version: '3.7' services: - # hub: - # image: dosel/zalenium - # command: start - # ports: - # - 4444:4444 - # environment: - # PULL_SELENIUM_IMAGE: 'true' - # volumes: - # - /var/run/docker.sock:/var/run/docker.sock - # - /tmp/videos:/home/seluser/videos - # privileged: true chrome: - image: selenium/node-chrome:3.14.0-gallium + image: selenium/standalone-chrome-debug:3.141.59-20200525 volumes: - /dev/shm:/dev/shm - depends_on: - - hub - environment: - HUB_HOST: hub - networks: - - e2e - - hub: - image: selenium/hub:3.14.0-gallium - ports: - - "4444:4444" - networks: - - e2e + network_mode: host postgresql: image: postgres:11 @@ -36,24 +13,8 @@ services: environment: POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_DB: passbook - networks: - - e2e + network_mode: host redis: image: redis restart: always - networks: - - e2e - passbook: - image: beryju/passbook - command: /bin/bash -c "sleep infinity" - volumes: - - ../:/testing - environment: - PASSBOOK_ENV: docker - user: root - working_dir: /testing - networks: - - e2e - -networks: - e2e: + network_mode: host diff --git a/e2e/requirements.txt b/e2e/requirements.txt new file mode 100644 index 000000000..c87e8eb53 --- /dev/null +++ b/e2e/requirements.txt @@ -0,0 +1,2 @@ +selenium +docker diff --git a/e2e/setup.sh b/e2e/setup.sh new file mode 100755 index 000000000..7859a76e9 --- /dev/null +++ b/e2e/setup.sh @@ -0,0 +1,20 @@ +#!/bin/bash -x +sudo apt update +sudo apt install -y python3.8 python3-pip apt-transport-https ca-certificates curl gnupg-agent software-properties-common +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +sudo add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" +sudo apt-get install -y docker-ce docker-ce-cli containerd.io +sudo usermod -a -G docker ubuntu +sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +sudo chmod +x /usr/local/bin/docker-compose +sudo pip3 install pipenv + +cd e2e +sudo docker-compose up -d +cd .. +pipenv sync --dev +pipenv run pip install -r e2e/requirements.txt +pipenv shell diff --git a/e2e/test_enroll_2_step.py b/e2e/test_enroll_2_step.py index 3a99fe1f8..b8f83cd33 100644 --- a/e2e/test_enroll_2_step.py +++ b/e2e/test_enroll_2_step.py @@ -17,11 +17,9 @@ from e2e.utils import apply_default_data class TestEnroll2Step(StaticLiveServerTestCase): """Test 2-step enroll flow""" - host = "passbook" - def setUp(self): self.driver = webdriver.Remote( - command_executor="http://hub:4444/wd/hub", + command_executor="http://localhost:4444/wd/hub", desired_capabilities=DesiredCapabilities.CHROME, ) self.driver.implicitly_wait(5) diff --git a/e2e/test_login_default.py b/e2e/test_login_default.py index d989ff907..f4db6a5b8 100644 --- a/e2e/test_login_default.py +++ b/e2e/test_login_default.py @@ -10,11 +10,9 @@ from e2e.utils import apply_default_data class TestLogin(StaticLiveServerTestCase): """test default login flow""" - host = "passbook" - def setUp(self): self.driver = webdriver.Remote( - command_executor="http://hub:4444/wd/hub", + command_executor="http://localhost:4444/wd/hub", desired_capabilities=DesiredCapabilities.CHROME, ) self.driver.implicitly_wait(5) diff --git a/passbook/policies/expression/evaluator.py b/passbook/policies/expression/evaluator.py index 825c23ebf..968e29834 100644 --- a/passbook/policies/expression/evaluator.py +++ b/passbook/policies/expression/evaluator.py @@ -22,7 +22,7 @@ class PolicyEvaluator(BaseEvaluator): super().__init__() self._messages = [] self._context["pb_message"] = self.expr_func_message - self._filename = policy_name + self._filename = policy_name or "PolicyEvaluator" def expr_func_message(self, message: str): """Wrapper to append to messages list, which is returned with PolicyResult""" diff --git a/passbook/providers/oidc/views.py b/passbook/providers/oidc/views.py index cd81f9c59..2d9e5bb89 100644 --- a/passbook/providers/oidc/views.py +++ b/passbook/providers/oidc/views.py @@ -1,5 +1,6 @@ """passbook OIDC Views""" from django.contrib import messages +from django.contrib.auth.mixins import LoginRequiredMixin from django.http import HttpRequest, HttpResponse, JsonResponse from django.shortcuts import get_object_or_404, redirect, reverse from django.views import View @@ -28,7 +29,7 @@ LOGGER = get_logger() PLAN_CONTEXT_PARAMS = "params" -class AuthorizationFlowInitView(AccessMixin, View): +class AuthorizationFlowInitView(AccessMixin, LoginRequiredMixin, View): """OIDC Flow initializer, checks access to application and starts flow""" # pylint: disable=unused-argument diff --git a/passbook/stages/email/templates/stages/email/waiting_message.html b/passbook/stages/email/templates/stages/email/waiting_message.html index a1c0a2a64..98f961333 100644 --- a/passbook/stages/email/templates/stages/email/waiting_message.html +++ b/passbook/stages/email/templates/stages/email/waiting_message.html @@ -15,7 +15,7 @@ {% block beneath_form %} {% endblock %}