Repository navigation
Conversation
Router tests replaced get_current_user and require_current_user with stubs, so the code that binds the request's principal never ran in a test. Once row-level security reads that principal, every permission test would have passed while proving nothing. Requests now carry a JWT signed with a key made for the test run, or an access key stored for the user, and the real dependency checks either one. Each test makes its request through a client named for the actor, such as owner_client, outsider_client, admin_client, anonymous_client, make_contributor or client_for(user, via=...), instead of switching one shared client. ANONYMOUS replaces None, so an unset persona fails loudly instead of running anonymous, and Jwt(active_roles=...) and ApiKey(role=...) say which credential and roles a request uses. The shared test session now drops its bound principal after each request, because close() keeps session.info and the next query would otherwise run as the last caller. The trusted_signing_key fixture holds the one patch of mavedb internals left, the ORCID public key and audience; it becomes a settings value when settings are read at call time.
Expect: new permission tests make the request under test through a persona fixture, a relation fixture such as make_contributor, or client_for, not through the default client or a dependency override.
Coverage Report for CI Build 46492352014Warning No base build found for commit Coverage: 91.382%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
2 of 3 tasks
# Conflicts: # tests/routers/test_score_set.py
…ient Three CSV streaming tests arrived with 2026.3.4 and passed the app to _get_streamed, which now takes a client so the request carries real credentials.
bencap
changed the base branch from
release-2026.3.5
to
integration/rls-baseline
November 30, 2026 19:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Router tests replaced
get_current_userandrequire_current_userwith stubs, sobind_principalnever ran in a test. Once row-level security reads the principal, a permission test written that way passes without proving anything. This PR makes every test request sign in through the real dependency, and names each request's actor through the client that sends it.Real credentials: a request carries a JWT signed with an RSA key made for the test run, or an access key stored for the user. The
trusted_signing_keyfixture makes the app trust that key for one test by patchingORCID_JWT_SIGNING_PUBLIC_KEYandORCID_JWT_AUDIENCE. It's the only place the tests reach intomavedb, and it becomes a settings value once settings are read at call time.Persona clients: the request under test goes through a client named for its actor:
owner_client,outsider_client,admin_clientandanonymous_clientmake_contributor(urn, Model), which adds the contributor and returns their clientclient_for(user, via=...)for anyone elseclient, signed in asTEST_USER, stays for setup.DependencyOverriderand the three*_app_overridesfixtures are deleted.Credentials and anonymity are explicit:
Jwt()acts with every role the user holds, andJwt(active_roles=[...])sendsX-Active-Roles.ApiKey(role=...)creates a key with at most one role.ANONYMOUSreplacesNone, so a persona that was never set fails rather than quietly running anonymous.Shared session: the test
get_dboverride clears the bound principal after each request.close()keepssession.info, so the next query would otherwise run as the last caller.tests/db/test_principal.py: signs real tokens instead of patchingdecode_jwt.Rule:
.claude/rules/tests.mdasks permission tests to make the request under test through one of these clients.Part of #834
How personas are defined (for #810)
A persona is a user row plus a credential. Constant personas (
TEST_USER,EXTRA_USER,ADMIN_USER,OUTSIDER_USER,CONTRIBUTOR_USER) live intests/helpers/constants.py.client_foradds a constant persona's user if it's missing, so a JWT never sends the app to ORCID for an unknown user. A relationship to data, such as contributor, comes from the fixture that creates it, so the client's name is given where it becomes true. #810's canary adds its own personas (mapper, calibrator, collection members) the same way.Real sign-in has one side effect to know about. The first JWT request in a test writes
last_login, clearsis_first_loginand commits, which expires loaded ORM objects. Tests that assert on login state useApiKey.Tests
tests/routers/test_authentication.pycovers the admin-only user list by credential (admin by JWT with every role, acting as admin or acting with no role; admin key with and without the admin role; ordinary user; anonymous). It also checks that/users/meresolves a JWT and an access key to their user, and that a token signed by an untrusted key gets 403.test_permissions.pyandtest_access_keys.pynow act as real owners and contributors, instead of reassigning ownership or keys by hand. The calibration permission tests also assertinvestigatorProvided.has-logged-intests use an access key, so sign-in doesn't clear the flag they check.bin/checkand the PR set (bin/t tests/ -n 6 -m "not network and not slow"), rebased on the currentrelease-2026.3.4: 5792 passed, 22 skipped.Checklist
release-<year>.<n>.0branch otherwise; nevermainmavedb-uiPR regeneratessrc/schema/openapi.d.ts(no schema change)