Skip to content

Commit 12df139

Browse files
committed
feat(test): 인증이 필요한 컨트롤러 테스트시 사용할 어노테이션 권한 추가
1 parent fdfc8af commit 12df139

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/test/java/com/somemore/CustomSecurityContextFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public SecurityContext createSecurityContext(WithMockCustomUser annotation) {
1717
Authentication auth = new UsernamePasswordAuthenticationToken(
1818
annotation.username(),
1919
"password",
20-
Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER"))
20+
Collections.singletonList(new SimpleGrantedAuthority("ROLE_" + annotation.role()))
2121
);
2222

2323
context.setAuthentication(auth);

src/test/java/com/somemore/WithMockCustomUser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
@WithSecurityContext(factory = CustomSecurityContextFactory.class)
1010
public @interface WithMockCustomUser {
1111
String username() default "123e4567-e89b-12d3-a456-426614174000";
12+
String role() default "VOLUNTEER";
1213
}

0 commit comments

Comments
 (0)