Skip to content
Snippets Groups Projects

Separate authentication tests into new test modules

Merged Duncan Macleod requested to merge duncanmmacleod/gwdatafind-server:test_auth into master
Files
5
+ 3
34
@@ -5,46 +5,15 @@
"""Test configuration for gwdatafind_server
"""
import os
from pathlib import Path
from unittest import mock
import pytest
from gwdatafind_server import create_app
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.rsa import generate_private_key
@pytest.fixture(scope="session") # one per suite is fine
def private_key():
return generate_private_key(
public_exponent=65537,
key_size=2048,
backend=default_backend(),
)
@pytest.fixture(scope="session")
def public_key(private_key):
return private_key.public_key()
@pytest.fixture(scope="session")
def public_pem(public_key):
return public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo,
)
from utils import create_test_app
@mock.patch.dict("os.environ")
@pytest.fixture
def app():
os.environ["LDR_LOCATION"] = str(Path(__file__).parent)
return create_app()
# default app to noauth for ease
return create_test_app(auth="None")
@pytest.fixture
Loading