Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] fix: AnnotationDelegateInterceptor에 경로 추가하여 ClassCastException 방지 (#804) #805

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public void addInterceptors(InterceptorRegistry registry) {
.addPathPatterns("/member-tickets/**", "/members/**", "/auth/**", "/students/**", "/member-fcm/**")
.excludePathPatterns("/auth/oauth2");
registry.addInterceptor(AnnotationDelegateInterceptor.builder()
.annotation(MemberAuth.class)
.interceptor(memberAuthInterceptor())
.build());
.annotation(MemberAuth.class)
.interceptor(memberAuthInterceptor())
.build())
.addPathPatterns("/api/**");
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ class MemberAuth_어노테이션이_붙은_핸들러_메서드는_인증_기능
@Test
@WithMockAuth(role = Role.ANONYMOUS)
void 토큰이_없으면_401_응답이_반환된다() throws Exception {
mockMvc.perform(get("/annotation-member-auth"))
mockMvc.perform(get("/api/annotation-member-auth"))
.andExpect(status().isUnauthorized());
}

@Test
@WithMockAuth
void 토큰이_있으면_200_응답이_반환된다() throws Exception {
mockMvc.perform(get("/annotation-member-auth")
mockMvc.perform(get("/api/annotation-member-auth")
.header(HttpHeaders.AUTHORIZATION, "Bearer token"))
.andExpect(status().isOk());
}

@Test
@WithMockAuth(role = Role.ADMIN)
void 토큰의_권한이_어드민이면_404_응답이_반환된다() throws Exception {
mockMvc.perform(get("/annotation-member-auth")
mockMvc.perform(get("/api/annotation-member-auth")
.header(HttpHeaders.AUTHORIZATION, "Bearer token"))
.andExpect(status().isNotFound())
.andExpect(jsonPath("$.errorCode").value(ErrorCode.NOT_ENOUGH_PERMISSION.name()));
Expand All @@ -61,7 +61,7 @@ class MemberAuth_어노테이션이_붙은_핸들러_메서드는_인증_기능
class AnnotationMemberAuthController {

@MemberAuth
@GetMapping("/annotation-member-auth")
@GetMapping("/api/annotation-member-auth")
public ResponseEntity<Void> testAuthHandler() {
return ResponseEntity.ok().build();
}
Expand Down
Loading