| Age | Commit message (Collapse) | Author |
|
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>
|
|
Breaking: every success body is now {"data", "meta": {"state",
"took_ms", "request_id"}, "notes", "next"}; clients read `data`. Only
`/` (plain text) and `/openapi.json` are unwrapped.
* src/response.rs (Envelope, Meta, State, Ctx, RequestInfo): handlers
take Ctx first and build the response with ctx.envelope(data), so
timing and the request id are never filled in by hand. `state` is
`complete` or `partial`; notes are server-authored only; `next` are
concrete relative hrefs (path_segment percent-encodes names).
* src/routes/*.rs, src/lib.rs (version): every handler returns
Envelope<..> with next links; /search is `partial` when the locus
lookup fails or a sorted 1000-hit window may be truncated, and
/publications/{pubmed_id}/traits when datasets were left out for
authorization.
* src/error.rs (ApiError): add `took_ms`, an RFC 7807 extension member.
* src/auth.rs (AuthToken): the 401 now carries request_id and took_ms
(it never had a request_id); Ctx stores RequestInfo in the request
extensions for it.
* tests: common::data / envelope_data parse every success body through
the envelope; tests/envelope.rs and test/python/test_envelope.py check
the shape, errors, and that every `next` link resolves;
tests/envelope_partial.rs checks the `partial` search without a
database; tests/openapi.rs fails if a JSON success response is not an
Envelope_* schema.
* README.md, docs/SKILL.md, docs/gn-auth.md, RELEASE_NOTES.md: document
the envelope and took_ms on errors.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
|
_read_packet returns the 4-byte header plus body, but _read_scramble
parsed from offset 1 as if the header were absent. It matched a zero
byte in the header instead of the one ending the server version
string, so the scramble was garbage, the mysql_native_password login
was always denied, and database_reachable() returned False on every
server, skipping the DB-gated tests. Start at offset 5.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
|
credentials, not just the port
Mirrors the Rust-side fix in 4a2cf5b on the Python suites: the old
skip check connected to 127.0.0.1:3306, so tests ran (and failed)
whenever a server was listening but rejected the credentials.
database_reachable() now performs the real
mysql_native_password handshake and skips only when the database is
genuinely unusable; the five DB-mapped test modules use it instead
of their local port probes.
* test/python/test_{groups,group_by_name,group_strains,species,species_by_name}.py
(database_reachable): use the shared probe; drop local copies.
|
|
Calls gn-auth's own password grant (POST /auth/token) for gn-auth's
well-known development user and returns the result, so local testing
no longer needs a manual curl/gn-auth round trip of its own.
Only ever registered -- not just rejected at request time, genuinely
absent from the router and from /openapi.json -- when two new Config
fields are both set: dev_mode (GENENETWORK4_DEV_MODE) and a loopback
bind (GENENETWORK4_BIND, also new). Both are config, not something
genenetwork4 infers from its actual network exposure, by design: dev
mode alone, or a loopback bind alone, each leave it disabled, and the
check (Config::dev_token_enabled) is a plain function so the condition
itself has direct unit test coverage rather than only being exercised
indirectly through the route.
src/main.rs now binds to config.bind instead of a hardcoded "0.0.0.0",
via a proper SocketAddr rather than string formatting -- the latter
would mishandle an IPv6 bind address like "::1" (needs brackets).
GN_AUTH_DEV_CLIENT_ID/_CLIENT_SECRET/_USERNAME/_PASSWORD default to
gn-auth's own published dev fixtures (flask init-dev-clients,
gn_auth/wsgi.py), so this works unconfigured against an unmodified dev
gn-auth instance -- confirmed live, including using the returned token
against a real gated endpoint (/traits/BXD/10001), not just checking
the token response's shape.
tests/dev_token.rs covers all four combinations of the two settings in
one sequential test function (mutating the same two env vars from more
than one #[tokio::test] in a file would race, since they run
concurrently by default) plus the /openapi.json visibility check.
test/python/test_dev_token.py mirrors this using separate test classes
instead, which is safe here since each spawns its own server
subprocess with its own environment (ServerTestCase gains EXTRA_ENV for
this).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDDpXvZBQat9uSgDeEMJ8d
|
|
* .gitignore: Add __pycache__.
* src/lib.rs (app): Add /version route.
(VersionInfo, version): New struct and handler, returning name,
short_name, version, release, date, and git as a JSON record.
* build.rs: New file. Embeds GN4_GIT_HASH and GN4_COMMIT_DATE via
cargo:rustc-env, read from git rev-parse and git show of HEAD.
* Cargo.toml (dependencies): Add serde with derive feature.
[dev-dependencies]: Add serde_json.
* tests/version.rs: New file.
* test/python/server_test_case.py: New file. ServerTestCase,
wait_for_port, BINARY, HOST, PORT moved here from
test/python/test_hello_world.py.
* test/python/test_hello_world.py: Use server_test_case.ServerTestCase
instead of duplicating setUpClass and tearDownClass.
* test/python/test_version.py: New file.
* guix.scm: Add (gnu packages version-control) to use-modules.
(genenetwork4-git)[native-inputs]: Add git-minimal.
(genenetwork4-git)[arguments]<#:phases>[python-rest-test]: Run
test/python with python3 -m unittest discover instead of invoking
test_hello_world.py directly, so test_version.py also runs.
|