Commit 1ed1c5c
committed
fix: resolve 36 test failures and add detailed explanatory comments
Root causes and fixes:
1. SaTokenPermissionImpl (NEW)
- Without StpInterface, Sa-Token returns empty permissions for all users,
causing every @SaCheckPermission check to unconditionally fail with 403.
- loginId must be parsed via toString() first: Sa-Token serializes it as
String internally even when StpUtil.login(Long) was called.
2. GlobalExceptionHandler
- NotPermissionException.getCode() returns the integer scene code (-1),
not the permission string. Fixed to getPermission() which returns the
actual missing permission name (e.g. "user:center:read").
3. AbstractWebIntegrationTest + BackendApplicationTests
- SPRING_DATASOURCE_URL env var (pointing to Neon PostgreSQL) has higher
Spring priority than application-test.properties, causing H2 context
load failure. Fixed via @SpringBootTest(properties) which overrides all
env vars.
- JustAuth UrlValidator rejects localhost redirect URIs; overridden with
a syntactically valid placeholder URL.
4. AuthControllerIntegrationTests
- Sa-Token NOT_TOKEN scenario now maps to "未提供 Token", not the old
generic "未登录或登录状态已失效" message.
5. UserCenterControllerIntegrationTests
- All URLs updated: /api/user-center/* paths were removed; current routes
are /auth/me, /users, /users/{id}, /users/{id}/authorization.
- Permission error message updated to match GlobalExceptionHandler output:
"拒绝访问: 缺少权限 [<permission>]".
6. OpenAiStreamControllerIntegrationTests
- DTO field renamed: message (String) -> messages (List), aligning with
Vercel AI SDK payload format.
- Async test uses asyncDispatch two-step pattern (required for
StreamingResponseBody); polling getContentAsString() never sees data.
- Stub returns OpenAI SSE format choices[0].delta.content so relayEvents()
can extract the text and emit Vercel Stream prefix "0:".
All 78 tests now pass.
https://claude.ai/code/session_016Z9qEQdrSXSTAhCp1YMgnk1 parent 749c21c commit 1ed1c5c
7 files changed
Lines changed: 236 additions & 28 deletions
File tree
- src
- main/java/com/involutionhell/backend/common
- config
- error
- test/java/com/involutionhell/backend
- openai/controller
- support
- usercenter/controller
Lines changed: 33 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
12 | 29 | | |
13 | 30 | | |
14 | 31 | | |
| |||
19 | 36 | | |
20 | 37 | | |
21 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
22 | 48 | | |
23 | 49 | | |
| 50 | + | |
24 | 51 | | |
25 | 52 | | |
26 | 53 | | |
27 | 54 | | |
28 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
29 | 60 | | |
30 | 61 | | |
31 | 62 | | |
| |||
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
| |||
Lines changed: 21 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
9 | 25 | | |
| 26 | + | |
10 | 27 | | |
11 | 28 | | |
12 | 29 | | |
13 | 30 | | |
14 | 31 | | |
15 | 32 | | |
| 33 | + | |
16 | 34 | | |
17 | 35 | | |
18 | 36 | | |
| |||
21 | 39 | | |
22 | 40 | | |
23 | 41 | | |
24 | | - | |
| 42 | + | |
25 | 43 | | |
26 | 44 | | |
27 | 45 | | |
| |||
Lines changed: 55 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
24 | 52 | | |
25 | 53 | | |
26 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
27 | 60 | | |
28 | 61 | | |
29 | 62 | | |
30 | | - | |
| 63 | + | |
| 64 | + | |
31 | 65 | | |
32 | 66 | | |
33 | 67 | | |
| |||
39 | 73 | | |
40 | 74 | | |
41 | 75 | | |
42 | | - | |
| 76 | + | |
| 77 | + | |
43 | 78 | | |
44 | 79 | | |
45 | 80 | | |
46 | 81 | | |
47 | 82 | | |
48 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
49 | 88 | | |
50 | 89 | | |
51 | 90 | | |
| |||
60 | 99 | | |
61 | 100 | | |
62 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
63 | 106 | | |
64 | 107 | | |
65 | 108 | | |
| |||
81 | 124 | | |
82 | 125 | | |
83 | 126 | | |
84 | | - | |
| 127 | + | |
| 128 | + | |
85 | 129 | | |
86 | 130 | | |
87 | 131 | | |
| |||
92 | 136 | | |
93 | 137 | | |
94 | 138 | | |
95 | | - | |
96 | | - | |
97 | | - | |
| 139 | + | |
98 | 140 | | |
99 | 141 | | |
100 | 142 | | |
101 | 143 | | |
102 | 144 | | |
103 | | - | |
104 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
105 | 152 | | |
106 | 153 | | |
107 | 154 | | |
| |||
Lines changed: 30 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
18 | 40 | | |
| 41 | + | |
19 | 42 | | |
20 | 43 | | |
21 | 44 | | |
22 | 45 | | |
23 | 46 | | |
24 | 47 | | |
25 | | - | |
26 | | - | |
| 48 | + | |
27 | 49 | | |
28 | 50 | | |
29 | 51 | | |
| |||
36 | 58 | | |
37 | 59 | | |
38 | 60 | | |
39 | | - | |
| 61 | + | |
40 | 62 | | |
41 | 63 | | |
42 | 64 | | |
| |||
54 | 76 | | |
55 | 77 | | |
56 | 78 | | |
57 | | - | |
58 | | - | |
59 | | - | |
| 79 | + | |
60 | 80 | | |
61 | 81 | | |
62 | 82 | | |
63 | 83 | | |
64 | | - | |
65 | | - | |
66 | | - | |
| 84 | + | |
67 | 85 | | |
68 | 86 | | |
69 | 87 | | |
70 | 88 | | |
71 | | - | |
72 | | - | |
73 | | - | |
| 89 | + | |
74 | 90 | | |
75 | 91 | | |
76 | 92 | | |
| |||
src/test/java/com/involutionhell/backend/usercenter/controller/AuthControllerIntegrationTests.java
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
12 | 32 | | |
13 | 33 | | |
14 | 34 | | |
| |||
70 | 90 | | |
71 | 91 | | |
72 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
73 | 97 | | |
74 | 98 | | |
75 | 99 | | |
| |||
87 | 111 | | |
88 | 112 | | |
89 | 113 | | |
| 114 | + | |
90 | 115 | | |
91 | 116 | | |
92 | 117 | | |
93 | 118 | | |
94 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
95 | 124 | | |
96 | 125 | | |
97 | 126 | | |
| |||
0 commit comments