From fc972c358eb68855aebc12ad0e2fa53b3e0b8fc9 Mon Sep 17 00:00:00 2001 From: ahah525 Date: Tue, 8 Nov 2022 10:20:48 +0900 Subject: [PATCH] =?UTF-8?q?#34=20-=20Test:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=20=EC=9A=94=EC=B2=AD=EC=8B=9C=20username/password=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=EC=84=B1=20=EA=B2=80=EC=A6=9D=20=EC=8B=A4=ED=8C=A8=ED=95=98?= =?UTF-8?q?=EB=A9=B4=20400(BadRequest)=20=EC=9D=91=EB=8B=B5=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MemberApiControllerTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/4Week_Mission/mutbooks/src/test/java/com/example/mutbooks/app/api/controller/MemberApiControllerTest.java b/4Week_Mission/mutbooks/src/test/java/com/example/mutbooks/app/api/controller/MemberApiControllerTest.java index be26429..65011ad 100644 --- a/4Week_Mission/mutbooks/src/test/java/com/example/mutbooks/app/api/controller/MemberApiControllerTest.java +++ b/4Week_Mission/mutbooks/src/test/java/com/example/mutbooks/app/api/controller/MemberApiControllerTest.java @@ -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()); + } } \ No newline at end of file