diff options
author | Frederick Muriuki Muriithi | 2024-07-19 13:17:48 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-07-31 09:30:25 -0500 |
commit | 62c5e94349672052ba70fa72ab489d86fdc5da10 (patch) | |
tree | ec8351ce37357413116fd2d6f55e53426a0d58a0 | |
parent | 7a362b31ac5cf3a7013eca74ea9659c1569eaa64 (diff) | |
download | gn-auth-62c5e94349672052ba70fa72ab489d86fdc5da10.tar.gz |
Setup secrets for test to prevent errors.
-rw-r--r-- | tests/unit/conftest.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index dcf4003..53ee062 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -8,6 +8,17 @@ import pytest from gn_auth import create_app +def setup_secrets(rootdir: Path) -> Path: + """Setup secrets directory and file.""" + secretsfile = Path(rootdir).joinpath("secrets/secrets.py") + secretsfile.parent.mkdir(exist_ok=True) + with open(secretsfile, "w", encoding="utf8") as outfile: + outfile.write( + 'SECRET_KEY="qQIrgiK29kXZU6v8D09y4uw_sk8I4cqgNZniYUrRoUk"') + + return secretsfile + + @pytest.fixture(scope="session") def fxtr_app(): """Fixture: setup the test app""" @@ -22,8 +33,8 @@ def fxtr_app(): app = create_app({ "TESTING": True, "AUTH_DB": testdb, + "GN_AUTH_SECRETS": str(setup_secrets(testdir)), "OAUTH2_ACCESS_TOKEN_GENERATOR": "tests.unit.auth.test_token.gen_token", - "SECRET_KEY": "qQIrgiK29kXZU6v8D09y4uw_sk8I4cqgNZniYUrRoUk", "UPLOADS_DIR": testuploadsdir, "SSL_PRIVATE_KEY": f"{testsroot}/test-ssl-private-key.pem", "CLIENTS_SSL_PUBLIC_KEYS_DIR": f"{testsroot}/test-public-keys-dir" |