e2e: add OIDC Provider test against grafana, more formatting, minor bug fixes

This commit is contained in:
Jens Langhammer
2020-06-19 19:34:27 +02:00
parent 8c6a4a4968
commit 73e7158178
11 changed files with 512 additions and 14 deletions

View File

@ -1,8 +1,10 @@
"""passbook e2e testing utilities"""
from glob import glob
from importlib.util import module_from_spec, spec_from_file_location
from inspect import getmembers, isfunction
from importlib.util import spec_from_file_location, module_from_spec
from Cryptodome.PublicKey import RSA
from django.apps import apps
from django.db import connection, transaction
from django.db.utils import IntegrityError
@ -15,7 +17,7 @@ def apply_default_data():
migration_files = glob("**/migrations/*.py", recursive=True)
matches = []
for migration in migration_files:
with open(migration, 'r+') as migration_file:
with open(migration, "r+") as migration_file:
# Check if they have a `RunPython`
if "RunPython" in migration_file.read():
matches.append(migration)
@ -34,3 +36,13 @@ def apply_default_data():
func(apps, schema_editor)
except IntegrityError:
pass
def ensure_rsa_key():
"""Ensure that at least one RSAKey Object exists, create one if none exist"""
from oidc_provider.models import RSAKey
if not RSAKey.objects.exists():
key = RSA.generate(2048)
rsakey = RSAKey(key=key.exportKey("PEM").decode("utf8"))
rsakey.save()