Add token scope tests for Execution API routes.#68918
Merged
Merged
Conversation
f202bd4 to
de0d3f8
Compare
ashb
approved these changes
Jun 23, 2026
seanghaeli
approved these changes
Jun 23, 2026
seanghaeli
left a comment
Contributor
There was a problem hiding this comment.
Much needed to programmatically verify token scope compliance. Approved pending CI
We only use APIRoute (for now?), but it looks like it could theoretically be a Mount or APIWebSocketRoute. An `isinstance` with an escape hatch scopes it down and makes mypy happy
kaxil
approved these changes
Jun 23, 2026
cetingokhan
pushed a commit
to cetingokhan/airflow
that referenced
this pull request
Jun 24, 2026
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.
Response to #66608 (tagging @seanghaeli ), these tests would assert that no API token scopes are modified unintentionally.
I ran these tests on main before the revert and they failed on the token-scope creep that @ashb found, then again after rebasing onto the reverted main and the tests all pass.
There is a section in the module docstring explaining how to maintain the test. The policy would be "any new API route which doesn't use ONLY
token:executionneeds to be added to the constant". So the vast majority of existing (and future??) routes are unaffected.To be clear: Execution-only routes are the default by far, so their implementation is unaffected. Someone adding or removing an execution-only route does not have to worry about these tests at all.
Usage/Test Cases
Adding tokens:
test_all_default_routes_are_execution_onlyfails.test_non_default_route_matches_policyfails.Removing tokens:
test_all_default_routes_are_execution_onlyfails [1]test_non_default_route_matches_policyfails.Adding Routes:
test_all_default_routes_are_execution_onlyfails.Removing Routes:
test_non_default_route_still_registeredfails.[1]: Also of note, that leaves a route with no token which likely shouldn't happen... but it's covered.