REM:
1. 增加冒烟测试集入口
2. 增加注销冒烟测试
This commit is contained in:
HuangXin 2020-05-08 16:26:27 +08:00
parent 964c63d360
commit b68d6d0598
3 changed files with 148 additions and 13 deletions

View File

@ -138,7 +138,6 @@ public class UserAccountServiceImpl implements UserAccountService {
*/
@Override
public UserAccount getUserByToken(String token) {
String username = userAccountCacheManager.getUsernameByToken(token);
if (username != null && username.length() > 0) {

View File

@ -0,0 +1,16 @@
package com.dispose.TestSuit;
import com.dispose.controller.AuthControllerExceptionSmokeTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
/**
* The type Smoke test.
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
AuthControllerExceptionSmokeTest.class
})
public class SmokeTest {
}

View File

@ -8,6 +8,7 @@ import com.dispose.pojo.dto.ProtocolRespDTO;
import com.dispose.pojo.po.ReturnStatus;
import com.dispose.pojo.vo.auth.LoginReq;
import com.dispose.pojo.vo.auth.LoginRsp;
import com.dispose.pojo.vo.auth.LogoutRsp;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
@ -57,7 +58,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void a1_normalAuthTest() throws Exception {
public void a1_loginNormalLoginTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
"\"msgContent\":\"{\\\"password\\\"" +
":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
@ -92,7 +93,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void a2_verJsonExceptionTest() throws Exception {
public void a2_loginVerJsonExceptionTest() throws Exception {
String reqData = "{\"ver\":\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":" +
"\"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
"\\\"userName\\\":\\\"admin\\\"}\"}";
@ -121,7 +122,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void a3_verNullExceptionTest() throws Exception {
public void a3_loginVerNullExceptionTest() throws Exception {
String reqData = "{\"ver\":null,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"" +
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
"\\\"userName\\\":\\\"admin\\\"}\"}";
@ -150,7 +151,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void a4_cryptoJsonExceptionTest() throws Exception {
public void a4_loginCryptoJsonExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":\"timeStamp\":1587604296988,\"msgContent\":\"" +
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
"\\\"userName\\\":\\\"admin\\\"}\"}";
@ -179,7 +180,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void a5_cryptoNullExceptionTest() throws Exception {
public void a5_loginCryptoNullExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":null,\"timeStamp\":1587604296988,\"msgContent\":\"" +
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
"\\\"userName\\\":\\\"admin\\\"}\"}";
@ -208,7 +209,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void a6_usernameNotExistExceptionTest() throws Exception {
public void a6_loginUsernameNotExistExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"" +
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
"\\\"userName\\\":\\\"123456\\\"}\"}";
@ -237,7 +238,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void a7_usernameEmptyExceptionTest() throws Exception {
public void a7_loginUsernameEmptyExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"" +
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
"\\\"userName\\\":\\\"\\\"}\"}";
@ -266,7 +267,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void a8_usernameNullExceptionTest() throws Exception {
public void a8_loginUsernameNullExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"" +
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
"\\\"userName\\\":null}\"}";
@ -295,7 +296,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void a9_passwordEmptyExceptionTest() throws Exception {
public void a9_loginPasswordEmptyExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
"\"msgContent\":\"{\\\"password\\\":\\\"\\\",\\\"userName\\\":\\\"admin\\\"}\"}";
@ -323,7 +324,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void b1_passwordNullExceptionTest() throws Exception {
public void b1_loginPasswordNullExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
"\"msgContent\":\"{\\\"password\\\":null,\\\"userName\\\":\\\"admin\\\"}\"}";
@ -351,8 +352,9 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
* @throws Exception the exception
*/
@Test
public void b2_passwordErrorExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"{\\\"password\\\":\\\"123456\\\",\\\"userName\\\":\\\"admin\\\"}\"}";
public void b2_loginPasswordErrorExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
"\"msgContent\":\"{\\\"password\\\":\\\"123456\\\",\\\"userName\\\":\\\"admin\\\"}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/auth/login")
@ -371,4 +373,122 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PASSWORD.getCode()));
}
/**
* C 1 normal logout test.
*
* @throws Exception the exception
*/
@Test
public void c1_logoutNormalLogoutTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604300195," +
"\"msgContent\":\"{\\\"userName\\\":\\\"admin\\\"}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/auth/logout")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", "Bearer " + getLogToken())
.content(reqData))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
.andReturn()
.getResponse()
.getContentAsString();
LogoutRsp rspInfo = objectMapper.readValue(verifyResp(ret), LogoutRsp.class) ;
Assert.assertNotNull(rspInfo);
Assert.assertNotNull(rspInfo.getUserName());
Assert.assertNotNull(rspInfo.getMessage());
Assert.assertNotNull(rspInfo.getStatus());
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
}
/**
* C 2 username type exception test.
*
* @throws Exception the exception
*/
@Test
public void c2_logoutUsernameTypeExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604300195," +
"\"msgContent\":\"{\\\"userName\\\":1,\\\"admin\\\"}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/auth/logout")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", "Bearer " + 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()));
}
/**
* C 2 username empty exception test.
*
* @throws Exception the exception
*/
@Test
public void c2_logoutUsernameEmptyExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604300195," +
"\"msgContent\":\"{\\\"userName\\\":\\\"\\\"}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/auth/logout")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", "Bearer " + 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()));
}
/**
* C 3 username null exception test.
*
* @throws Exception the exception
*/
@Test
public void c3_logoutUsernameNullExceptionTest() throws Exception {
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604300195," +
"\"msgContent\":\"{\\\"userName\\\":null}\"}";
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/auth/logout")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", "Bearer " + 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()));
}
}