e2e: test against standalone chrome instance, start implementing oidc provider test

This commit is contained in:
Jens Langhammer 2020-06-19 18:19:20 +02:00
parent c83216ece0
commit 8c6a4a4968
8 changed files with 32 additions and 52 deletions

View File

@ -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

2
e2e/requirements.txt Normal file
View File

@ -0,0 +1,2 @@
selenium
docker

20
e2e/setup.sh Executable file
View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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"""

View File

@ -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

View File

@ -15,7 +15,7 @@
{% block beneath_form %}
{% endblock %}
<div class="pf-c-form__group pf-m-action">
<button class="pf-c-button pf-m-primary pf-m-block" type="submit">{% trans "Send Recovery Email." %}</button>
<button class="pf-c-button pf-m-primary pf-m-block" type="submit">{% trans "Send Email." %}</button>
</div>
</form>
{% endblock %}