parent
aaccebede2
commit
a70241687e
|
@ -566,5 +566,151 @@ public class AuthControllerQATest extends InitTestEnvironment {
|
|||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
/**
|
||||
* C 7 ver json exception test .
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void c7_logoutVerJsonExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":\"cryptoType\":0,\"timeStamp\":1587604300195," +
|
||||
"\"msgContent\":\"{\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), ReturnStatus.class) ;
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* C 8 ver null exception test .
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void c8_logoutVerNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":null,\"cryptoType\":0,\"timeStamp\":1587604300195," +
|
||||
"\"msgContent\":\"{\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), ReturnStatus.class) ;
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
}
|
||||
/**
|
||||
* C 9 crypto json exception test .
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void c9_logoutCryptoJsonExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":\"timeStamp\":1587604300195," +
|
||||
"\"msgContent\":\"{\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), ReturnStatus.class) ;
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* C 10 crypto null exception test .
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void c10_logoutCryptoNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":null,\"timeStamp\":1587604300195," +
|
||||
"\"msgContent\":\"{\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PARAMEXCEPTION.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), ReturnStatus.class) ;
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_PARAMEXCEPTION.getMsg());
|
||||
}
|
||||
/**
|
||||
* C 11 username not exit exception test .
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void c11_logoutUsernameNotExitExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604300195," +
|
||||
"\"msgContent\":\"{\\\"userName\\\":\\\"a\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/logout")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", GlobalVar.STRING_HTTP_AUTH_HEAD + getLogToken())
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_USERNOTFOUND.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ReturnStatus rspInfo = objectMapper.readValue(verifyResp(ret), ReturnStatus.class) ;
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_USERNOTFOUND.getCode()));
|
||||
Assert.assertEquals(rspInfo.getMessage(), ErrorCode.ERR_USERNOTFOUND.getMsg());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue