Skip to content

Commit

Permalink
#34 - Test: 로그인 요청시 username/password 입력데이터 유효성 검증 실패하면 400(BadReques…
Browse files Browse the repository at this point in the history
…t) 응답 테스트
  • Loading branch information
ahah525 committed Nov 8, 2022
1 parent a06a89d commit fc972c3
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,43 @@ void t2() throws Exception {

assertThat(authentication).isNotEmpty();
}

@Test
@DisplayName("POST /api/v1/member/login 호출할 때 username 이나 password 를 누락하면 400")
void t3() throws Exception {
// When
ResultActions resultActions = mvc
.perform(
post("/api/v1/member/login")
.content("""
{
"username": "",
"password": "1234"
}
""".stripIndent())
.contentType(new MediaType(MediaType.APPLICATION_JSON, StandardCharsets.UTF_8))
)
.andDo(print());

// Then
resultActions
.andExpect(status().is4xxClientError());

resultActions = mvc
.perform(
post("/api/v1/member/login")
.content("""
{
"username": "user1",
"password": " "
}
""".stripIndent())
.contentType(new MediaType(MediaType.APPLICATION_JSON, StandardCharsets.UTF_8))
)
.andDo(print());

// Then
resultActions
.andExpect(status().is4xxClientError());
}
}

0 comments on commit fc972c3

Please sign in to comment.