Skip to content

Commit 5f52322

Browse files
committed
add test
1 parent 04a1470 commit 5f52322

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

springboot-starter-security-jwt/src/test/java/com/codingapi/springboot/security/SecurityJwtApplicationTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ void login() throws Exception {
3737
.contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
3838
}
3939

40+
@Test
41+
void loginError() throws Exception {
42+
JSONObject json = new JSONObject();
43+
json.put("username","admin");
44+
json.put("password","12345678");
45+
mockMvc.perform(post("/user/login")
46+
.content(json.toJSONString().getBytes(StandardCharsets.UTF_8))
47+
.contentType(MediaType.APPLICATION_JSON)).andExpect(result -> {
48+
String body = result.getResponse().getContentAsString();
49+
JSONObject jsonObject = JSONObject.parseObject(body);
50+
log.info("body:{}", jsonObject);
51+
assertEquals(jsonObject.getString("errCode"),"login.error","login error");
52+
});
53+
}
54+
4055
@Test
4156
void noToken() throws Exception {
4257
mockMvc.perform(get("/api/hello")

0 commit comments

Comments
 (0)