about summary refs log tree commit diff
path: root/test/python/server_test_case.py
diff options
context:
space:
mode:
authorPjotr <wrk@bosa.lan>2026-10-08 14:57:35 +0000
committerPjotr <wrk@bosa.lan>2026-10-08 14:57:35 +0000
commit69aac61b0c5b2d8a4f909de6a6d6af8d6ee293a3 (patch)
tree8c3734e6a3ca0baca7872d6e87cbe3167fb128b6 /test/python/server_test_case.py
parent679136801effc34ff4b50e54abfc40592ee1d64d (diff)
downloadgenenetwork4-69aac61b0c5b2d8a4f909de6a6d6af8d6ee293a3.tar.gz
* src/routes/dev.rs: POST /get-test-token answers local callers only, not tied to dev mode.
The endpoint no longer depends on GENENETWORK4_DEV_MODE or on the bind
address. It decides per request whether to answer.

* src/routes/dev.rs (get_test_token): answers a caller only when the TCP
peer (axum ConnectInfo) is in 127.0.x.x (or ::1, or an IPv4-mapped
127.x) and the request carries no X-Forwarded-For, Forwarded or
X-Real-IP header (a reverse proxy on the same host would otherwise make
every client look local). Anything else, including an unknown peer, is a
403. Local is never established from a header.
* src/main.rs: serve with into_make_service_with_connect_info, which
provides the peer address.
* src/config.rs: remove dev_mode, GENENETWORK4_DEV_MODE and
dev_token_enabled(). Add GENENETWORK4_TEST_TOKEN (on by default); when it
is not a clearly affirmative value (true/1/yes/on) the route is not
registered: a 404, absent from /openapi.json. It fails closed, so a
typo ("flase") turns the endpoint off.
* src/lib.rs: register the route unless that switch is off.

* tests: tests/get_test_token.rs rewritten (remote, unknown and proxied
peers refused; 127.x and ::1 answered; always documented by default);
tests/get_test_token_off.rs for the switch (own process: it sets an
environment variable); common::post_from supplies a peer address to the
in-process requests. Python: test_get_test_token.py rewritten, TOKEN_ENV
is now empty (no setting needed).
* README.md, docs/gn-auth.md, docs/SKILL.md, RELEASE_NOTES.md: document
the check, the switch, and "Behind nginx or in a container" (a bridge
container sees the gateway as the peer; a host-network container behind
nginx sees 127.0.0.1, so block the path in nginx, set X-Forwarded-For,
or switch the endpoint off).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'test/python/server_test_case.py')
-rw-r--r--test/python/server_test_case.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/test/python/server_test_case.py b/test/python/server_test_case.py
index c400661..7561792 100644
--- a/test/python/server_test_case.py
+++ b/test/python/server_test_case.py
@@ -138,7 +138,7 @@ class ServerTestCase(unittest.TestCase):
     """Spawns the genenetwork4 binary for the duration of the test class.
 
     Subclasses that need the server started with extra/overridden
-    environment variables (e.g. GENENETWORK4_DEV_MODE) can set EXTRA_ENV.
+    environment variables (e.g. GN3_URL) can set EXTRA_ENV.
     """
 
     EXTRA_ENV = {}