@@ -13,9 +13,11 @@ import { Identity } from "@/auth/identity.decorator";
1313import { ApiKeyService } from "../actor/api-key.service" ;
1414import { UserService } from "../actor/user.service" ;
1515import { ApiKeyAuthGuard } from "./api-key-auth.guard" ;
16+ import { AuthService } from "./auth.service" ;
1617import { CsrfGuard } from "./csrf.guard" ;
1718import { IdentityGuard } from "./identity.guard" ;
1819import { JwtAuthGuard } from "./jwt-auth.guard" ;
20+ import { KeycloakJwtStrategy } from "./keycloak-jwt.strategy" ;
1921import { Public } from "./public.decorator" ;
2022
2123/**
@@ -140,24 +142,32 @@ describe("Guard Composition Integration", () => {
140142 } ;
141143
142144 const mockUserService = {
143- getUserWithGroups : jest . fn ( ) . mockResolvedValue ( {
145+ findUserWithGroups : jest . fn ( ) . mockResolvedValue ( {
146+ user_id : "user-1" ,
144147 userGroups : [ ] ,
145148 is_system_admin : false ,
146149 actor_id : "actor-1" ,
147150 } ) ,
148151 } ;
149152
153+ const mockAuthService = { } ;
154+
155+ const mockKeycloakJwtStrategy = { } ;
156+
150157 beforeAll ( async ( ) => {
151158 const module : TestingModule = await Test . createTestingModule ( {
152159 controllers : [ TestGuardController ] ,
153160 providers : [
154161 Reflector ,
162+ // Register guards in the correct order, only once each, using the stub for JwtAuthGuard
155163 { provide : APP_GUARD , useClass : StubJwtAuthGuard } ,
156164 { provide : APP_GUARD , useClass : ApiKeyAuthGuard } ,
157165 { provide : APP_GUARD , useClass : IdentityGuard } ,
158166 { provide : APP_GUARD , useClass : CsrfGuard } ,
167+ { provide : KeycloakJwtStrategy , useValue : mockKeycloakJwtStrategy } ,
159168 { provide : ApiKeyService , useValue : mockApiKeyService } ,
160169 { provide : UserService , useValue : mockUserService } ,
170+ { provide : AuthService , useValue : mockAuthService } ,
161171 ] ,
162172 } ) . compile ( ) ;
163173
@@ -181,7 +191,7 @@ describe("Guard Composition Integration", () => {
181191 } ,
182192 ) ;
183193
184- mockUserService . getUserWithGroups . mockResolvedValue ( {
194+ mockUserService . findUserWithGroups . mockResolvedValue ( {
185195 userGroups : [ ] ,
186196 is_system_admin : false ,
187197 actor_id : "actor-1" ,
0 commit comments