Skip to content

Commit

Permalink
test: implement allow and deny expiration notifications api test
Browse files Browse the repository at this point in the history
  • Loading branch information
inh2613 committed Oct 25, 2023
1 parent 2412d42 commit 0a65525
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,41 @@ void deleteDeviceToken() throws Exception {
.content(objectMapper.writeValueAsString(deviceTokenRequestDto)))
.andExpect(status().isOk());
}

/**
* 만료 알림 수신 허용 테스트
*/
@Test
@WithMockUser(username = "이진우", roles = "USER")
void allowNotifications() throws Exception {
String accessToken = "my.access.token";
String username = "이진우";
User user = User.builder().username(username).build();

when(jwtProvider.resolveToken(any())).thenReturn(accessToken);
when(jwtProvider.getUsername(anyString())).thenReturn(username);
when(userService.read(username)).thenReturn(user);

mockMvc.perform(post("/notifications/expiration/allow").header("Authorization", "Bearer " + accessToken))
.andExpect(status().isOk());
}

/**
* 만료 알림 수신 거부 테스트
*/
@Test
@WithMockUser(username = "이진우", roles = "USER")
void denyNotifications() throws Exception {
String accessToken = "my.access.token";
String username = "이진우";
User user = User.builder().username(username).build();

when(jwtProvider.resolveToken(any())).thenReturn(accessToken);
when(jwtProvider.getUsername(anyString())).thenReturn(username);
when(userService.read(username)).thenReturn(user);

mockMvc.perform(post("/notifications/expiration/deny").header("Authorization", "Bearer " + accessToken))
.andExpect(status().isOk());
}

}

0 comments on commit 0a65525

Please sign in to comment.