diff options
Diffstat (limited to 'test/python/test_species.py')
| -rw-r--r-- | test/python/test_species.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/test/python/test_species.py b/test/python/test_species.py index f739d98..99ae794 100644 --- a/test/python/test_species.py +++ b/test/python/test_species.py @@ -1,6 +1,7 @@ -"""Mirrors tests/species.rs. Needs a live MariaDB (SQL_URI); skips with a -message rather than failing when none is reachable (e.g. inside the Guix -build sandbox, which has no network/database access). +"""Mirrors tests/species.rs. Needs a live MariaDB (SQL_URI) and a valid +token (every endpoint needs one now -- see docs/gn-auth.md); skips with +a message rather than failing when either is missing (e.g. inside the +Guix build sandbox, which has no network/database access). """ import http.client @@ -8,6 +9,7 @@ import json import socket import unittest +from auth_helpers import TOKEN_ENV, auth_token from server_test_case import HOST, PORT, ServerTestCase @@ -20,13 +22,18 @@ def database_reachable(): class SpeciesTest(ServerTestCase): + EXTRA_ENV = TOKEN_ENV + def test_species_returns_ok_with_species_list(self): if not database_reachable(): self.skipTest("no database on 127.0.0.1:3306") + token = auth_token() + if not token: + self.skipTest("no token (see docs/gn-auth.md)") conn = http.client.HTTPConnection(HOST, int(PORT), timeout=10) try: - conn.request("GET", "/species") + conn.request("GET", "/species", headers={"Authorization": f"Bearer {token}"}) response = conn.getresponse() body = response.read() finally: |
