Repository navigation
Conversation
AuthInterceptor resolves the session once per request since apache#2895, so it calls getAuthenticatedUser only and no longer calls isAuthenticated. This test still stubbed and verified the old pair of calls, which left the server suite red at head: shouldStillRejectAnonymousProtectedRequests Wanted but not invoked: AuthService.isAuthenticated(null) shouldRejectNonAdminMutationBeforeControllerExecution Status expected:<403> but was:<401> Production code is untouched; the test now stubs getAuthenticatedUser for the non-admin case and asserts that isAuthenticated is no longer part of the flow. Signed-off-by: yyqdbngt <btlqql@gmail.com>
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Correct test alignment — the production code switched from isAuthenticated to getAuthenticatedUser, and this PR updates the mocks and verifications accordingly. The changes are minimal, focused, and fix the two failing tests (shouldStillRejectAnonymousProtectedRequests and shouldRejectNonAdminMutationBeforeControllerExecution).
LGTM.
Automated review by github-manager-bot
|
Superseded by the current
void shouldStillRejectAnonymousProtectedRequests() throws Exception {
...
verify(authService).getAuthenticatedUser(null);
}
void shouldRejectNonAdminMutationBeforeControllerExecution() throws Exception {
String authorization = "Bearer reader-token";
when(authService.getAuthenticatedUser(authorization)).thenReturn(Optional.of(
LoginVO.UserInfo.builder().userId(2L).username("reader").admin(false).build()));
...
}The only delta left in this branch is the extra |
|
Closing as superseded - see the comment above. |
Problem
mvn -B -ntp testfails on the currentrocketmq-studiohead (6c24d2ed): 2 of 2151 tests fail, both inAuthCorsIntegrationTest.Run on Ubuntu 22.04 with OpenJDK 21.0.12 and Maven 3.6.3, from
server/, with no local changes.Root cause
#2895(ddf82325, [ISSUE #2892]) madeAuthInterceptorresolve the session once per request. The interceptor now callsauthService.getAuthenticatedUser(...)only —isAuthenticatedis no longer part of the flow:AuthCorsIntegrationTestwas last changed on 2026-08-18 and still stubs and verifies that old pair of calls, so the mock answersOptional.empty()and the anonymous branch is taken beforerequiresAdminis ever evaluated. That is why the non-admin mutation answers 401 instead of the expected 403.The interceptor change is correct; only the test is stale. A/B on the same tree, with nothing but
AuthInterceptor.javaswapped for its pre-#2895revision (test untouched):AuthCorsIntegrationTest6c24d2ed)Tests run: 4, Failures: 2#2895AuthInterceptorTests run: 4, Failures: 0Change
Test only — production code is untouched:
shouldStillRejectAnonymousProtectedRequestsverifiesgetAuthenticatedUser(null)and asserts thatisAuthenticatedis no longer called.shouldRejectNonAdminMutationBeforeControllerExecutionstubsgetAuthenticatedUserwith a non-adminLoginVO.UserInfoinstead ofisAuthenticated+isAdmin, which also pins the 403 the interceptor is supposed to produce for an authenticated non-admin mutation.Verification
Ubuntu 22.04, OpenJDK 21.0.12, Maven 3.6.3, on
6c24d2ed+ this patch:Why this went unnoticed
ci.ymldoes not run on this branch. Every run isstartup_failurewith zero jobs created, including the run for the push of6c24d2editself:93 of the last 100 runs in the repository are
startup_failure(the 5 successes are the scheduled stale-bot runs onmaster). So the server suite has to be run by hand, and it is red at head until this lands — worth knowing for anyone verifying a PR withmvn -B -ntp teston this branch.I have not touched
ci.ymlhere; if you want the workflow running again I can look into it separately.