Skip to content
Snippets Groups Projects
Verified Commit b527aa98 authored by Mark's avatar Mark
Browse files

Add backend independent test image

parent 441e2a3a
No related branches found
No related tags found
1 merge request!3Change login provider backend to graphql
Pipeline #283 failed with stages
in 2 minutes and 7 seconds
...@@ -28,6 +28,19 @@ login-provider: ...@@ -28,6 +28,19 @@ login-provider:
- login_provider/**/* - login_provider/**/*
- .gitlab-ci.yml - .gitlab-ci.yml
login-provider-mock:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context ${CI_PROJECT_DIR}/login_provider/test/behave --dockerfile ${CI_PROJECT_DIR}/login_provider/test/behave/Dockerfile --destination $CI_REGISTRY_IMAGE/login_provider_mock:${CI_COMMIT_REF_NAME} --build-arg baseimage=$CI_REGISTRY_IMAGE/login_provider:${CI_COMMIT_REF_NAME}
only:
changes:
- login_provider/**/*
- .gitlab-ci.yml
login-provider-test: login-provider-test:
stage: build stage: build
image: image:
...@@ -43,13 +56,17 @@ login-provider-test: ...@@ -43,13 +56,17 @@ login-provider-test:
behave-login: behave-login:
stage: application-test stage: application-test
variables:
TESTUSER_USERNAME: "admin"
TESTUSER_EMAIL: "admin@example.net"
TESTUSER_PASSWORD: "password"
services: services:
- name: ${CI_REGISTRY_IMAGE}/login_provider:${CI_COMMIT_REF_NAME} - name: ${CI_REGISTRY_IMAGE}/login_provider_mock:${CI_COMMIT_REF_NAME}
alias: login_provider alias: login_provider
image: ${CI_REGISTRY_IMAGE}/login_provider_ci_test:${CI_COMMIT_REF_NAME} image: ${CI_REGISTRY_IMAGE}/login_provider_ci_test:${CI_COMMIT_REF_NAME}
script: script:
- cd login_provider/test/behave/ - cd login_provider/test/behave/
- python3 -m behave -D headless=True -D url=http://login_provider:5000 -D email=example@oas.example.com -D password=password - python3 -m behave -D headless=True -D url=http://login_provider:5000 -D username=$TESTUSER_USERNAME -D password=$TESTUSER_PASSWORD
artifacts: artifacts:
paths: paths:
- login_provider/test/behave/screenshots/ - login_provider/test/behave/screenshots/
......
ARG baseimage=open.greenhost.net:4567/openappstack/single-sign-on/login_provider
FROM $baseimage
ENV TESTUSER_USERNAME
ENV TESTUSER_EMAIL
ENV TESTUSER_PASSWORD
COPY mock/db.py db.py
from os import environ
from flask_login import UserMixin
USERNAME = environ["TESTUSER_USERNAME"]
PASSWORD = environ["TESTUSER_PASSWORD"]
EMAIL = environ["TESTUSER_EMAIL"]
users = {USERNAME: {"password": PASSWORD, "email": EMAIL, "active": True}}
class User(UserMixin):
def __init__(self, username):
self.id = username
self.username = username
self.active = False
self._load_remote_user_info()
def _load_remote_user_info(self):
if self.username in users:
self.active = users[self.username]["active"]
self.email = users[self.username]["email"]
def _verify_password(self, password):
return users[self.username]["password"] == password
def authenticate(self, password):
return self.active and self._verify_password(password)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment