diff options
Diffstat (limited to 'test/python/test_dataset_probeset_values.py')
| -rw-r--r-- | test/python/test_dataset_probeset_values.py | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/test/python/test_dataset_probeset_values.py b/test/python/test_dataset_probeset_values.py index b9f0f0e..7a934d0 100644 --- a/test/python/test_dataset_probeset_values.py +++ b/test/python/test_dataset_probeset_values.py @@ -1,22 +1,21 @@ """Mirrors tests/dataset_probeset_values.rs. Needs a live MariaDB (SQL_URI); skips with a message rather than failing when none is reachable, same as test_group_by_name.py. Also needs a live gn-auth -(AUTH_SERVER_URL) and GN4_TEST_AUTH_TOKEN (see docs/gn-auth.md), since -this endpoint now requires a bearer token; skips when either is -missing. +(AUTH_SERVER_URL) and a token (see docs/gn-auth.md), since this +endpoint now requires a bearer token; skips when either is missing. +auth_token() tries this server's own POST /get-test-token first +(EXTRA_ENV below makes that possible), falling back to +GN4_TEST_AUTH_TOKEN. """ import http.client import json -import os import socket import unittest -from urllib.parse import urlparse +from auth_helpers import TOKEN_ENV, auth_server_reachable, auth_token from server_test_case import HOST, PORT, ServerTestCase -AUTH_SERVER_URL = os.environ.get("AUTH_SERVER_URL", "http://127.0.0.1:8081/") - def database_reachable(): try: @@ -26,30 +25,16 @@ def database_reachable(): return False -def auth_server_reachable(): - url = urlparse(AUTH_SERVER_URL) - conn = http.client.HTTPConnection(url.hostname, url.port or 80, timeout=2) - try: - conn.request("GET", url.path.rstrip("/") + "/auth/public-jwks") - return conn.getresponse().status == 200 - except OSError: - return False - finally: - conn.close() - - -def auth_token(): - return os.environ.get("GN4_TEST_AUTH_TOKEN") - - class DatasetProbesetValuesTest(ServerTestCase): + EXTRA_ENV = TOKEN_ENV + def require_fixtures(self): if not database_reachable(): self.skipTest("no database on 127.0.0.1:3306") if not auth_token(): - self.skipTest("set GN4_TEST_AUTH_TOKEN (see docs/gn-auth.md)") + self.skipTest("no token (see docs/gn-auth.md)") if not auth_server_reachable(): - self.skipTest(f"no gn-auth reachable at {AUTH_SERVER_URL}") + self.skipTest("no gn-auth reachable") def get(self, path, with_token=True): conn = http.client.HTTPConnection(HOST, int(PORT), timeout=10) |
