Commit 82bcbd8
authored
fix(tests): collect tests/, and correct the two assertions that never ran (#314)
The issue calls these order-dependent — passing under `pytest`, failing under
`pytest <file>`. They are not. `testpaths` listed `tests/integration`,
`tests/e2e`, `tests/benchmarks` and `tests/perf` but never `tests/` itself, so
the four modules directly under it were not collected by a bare `pytest` at all.
The tests "passed" by not running. 26 tests were in that gap, including a
lifespan hydration test and fifteen audit-log tests.
Replacing the four entries with `"tests"` collects them; the marker filter in
`addopts` still holds e2e and perf out, so nothing new runs in CI that should
not. That leaves exactly the two failures the issue describes, and both are the
test being wrong rather than the code.
`test_host_settings_ignores_env` asserted "HostSettings must NOT read env".
That is not this codebase's contract: precedence is env → DB → default and env
has to keep winning, or an upgrade silently changes a deployment's behaviour.
`HostSettings` declares `env_prefix="SM_"` for that reason. Rewritten as three
tests covering what the prefix actually guarantees — prefixed env wins, an
unprefixed name is ignored, the default applies when neither is set.
`test_session_wins_over_bad_bearer` asserted a valid session rescues a bad
`Authorization: Bearer`. `resolve_user` does the opposite. Keeping the code is
the deliberate call: falling through would make an invalid token
indistinguishable from no token, so a client whose credential expired keeps
working on whatever other identity it carries and its 401s depend on what else
is in the request — while gaining nothing, since the fall-through can only
resolve the session's own identity, which the caller already had. The precedence
is now stated where it is implemented, with a sibling test proving the session
alone still succeeds so the 401 is the header's doing.
Closes #2951 parent c6b0195 commit 82bcbd8
4 files changed
Lines changed: 70 additions & 11 deletions
File tree
- modules/users/users
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
77 | 87 | | |
78 | 88 | | |
79 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
50 | 59 | | |
51 | | - | |
52 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
53 | 78 | | |
54 | 79 | | |
55 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
87 | 103 | | |
88 | 104 | | |
89 | 105 | | |
90 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
91 | 115 | | |
0 commit comments