parent
4a93d0c813
commit
5564475f24
|
@ -0,0 +1,16 @@
|
|||
package com.dispose.TestSuit;
|
||||
|
||||
import com.dispose.controller.AuthControllerQATest;
|
||||
import com.dispose.controller.AuthControllerSmokeTest;
|
||||
import com.dispose.controller.TaskControllerExceptionSmokeTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
AuthControllerQATest.class,
|
||||
AuthControllerSmokeTest.class,
|
||||
TaskControllerExceptionSmokeTest.class
|
||||
})
|
||||
public class QATest {
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.dispose.TestSuit;
|
||||
|
||||
import com.dispose.controller.AuthControllerExceptionSmokeTest;
|
||||
import com.dispose.controller.AuthControllerQATest;
|
||||
import com.dispose.controller.TaskControllerExceptionSmokeTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
@ -10,7 +10,7 @@ import org.junit.runners.Suite;
|
|||
*/
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
AuthControllerExceptionSmokeTest.class,
|
||||
AuthControllerQATest.class,
|
||||
TaskControllerExceptionSmokeTest.class
|
||||
})
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@Slf4j
|
||||
public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
|
||||
public class AuthControllerQATest extends InitTestEnvironment {
|
||||
/**
|
||||
* The Mock mvc.
|
||||
*/
|
||||
|
@ -47,48 +47,13 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
|
|||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* A 1 normal auth test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a1_loginNormalLoginTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
"\"msgContent\":\"{\\\"password\\\"" +
|
||||
":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/login")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
LoginRsp rspInfo = objectMapper.readValue(verifyResp(ret), LoginRsp.class) ;
|
||||
|
||||
Assert.assertNotNull(rspInfo);
|
||||
Assert.assertNotNull(rspInfo.getUserName());
|
||||
Assert.assertNotNull(rspInfo.getLogTime());
|
||||
Assert.assertNotNull(rspInfo.getToken());
|
||||
Assert.assertNotNull(rspInfo.getExpireTime());
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* A 2 ver json exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a2_loginVerJsonExceptionTest() throws Exception {
|
||||
public void a1_loginVerJsonExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":" +
|
||||
"\"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
@ -117,7 +82,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a3_loginVerNullExceptionTest() throws Exception {
|
||||
public void a2_loginVerNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":null,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"" +
|
||||
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
@ -146,7 +111,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a4_loginCryptoJsonExceptionTest() throws Exception {
|
||||
public void a3_loginCryptoJsonExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":\"timeStamp\":1587604296988,\"msgContent\":\"" +
|
||||
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
@ -175,7 +140,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a5_loginCryptoNullExceptionTest() throws Exception {
|
||||
public void a4_loginCryptoNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":null,\"timeStamp\":1587604296988,\"msgContent\":\"" +
|
||||
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
@ -198,42 +163,13 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_PARAMEXCEPTION.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* A 6 username not exist exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a6_loginUsernameNotExistExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"" +
|
||||
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":\\\"123456\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/login")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.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()));
|
||||
}
|
||||
|
||||
/**
|
||||
* A 7 username empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a7_loginUsernameEmptyExceptionTest() throws Exception {
|
||||
public void a5_loginUsernameEmptyExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"" +
|
||||
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":\\\"\\\"}\"}";
|
||||
|
@ -262,7 +198,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a8_loginUsernameNullExceptionTest() throws Exception {
|
||||
public void a6_loginUsernameNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"" +
|
||||
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":null}\"}";
|
||||
|
@ -285,33 +221,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
|
|||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_USERNOTFOUND.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* A 9 password empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a9_loginPasswordEmptyExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
"\"msgContent\":\"{\\\"password\\\":\\\"\\\",\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/login")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PASSWORD.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_PASSWORD.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* B 1 password null exception test.
|
||||
|
@ -435,7 +345,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void c2_logoutUsernameEmptyExceptionTest() throws Exception {
|
||||
public void c3_logoutUsernameEmptyExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604300195," +
|
||||
"\"msgContent\":\"{\\\"userName\\\":\\\"\\\"}\"}";
|
||||
|
||||
|
@ -464,7 +374,7 @@ public class AuthControllerExceptionSmokeTest extends InitTestEnvironment {
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void c3_logoutUsernameNullExceptionTest() throws Exception {
|
||||
public void c4_logoutUsernameNullExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604300195," +
|
||||
"\"msgContent\":\"{\\\"userName\\\":null}\"}";
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
package com.dispose.controller;
|
||||
|
||||
import com.dispose.Global.InitTestEnvironment;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.po.ReturnStatus;
|
||||
import com.dispose.pojo.vo.auth.LoginRsp;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Assert;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* The type Auth controller smoke test.
|
||||
*/
|
||||
@AutoConfigureMockMvc
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
@Slf4j
|
||||
public class AuthControllerSmokeTest extends InitTestEnvironment {
|
||||
/**
|
||||
* The Mock mvc.
|
||||
*/
|
||||
@Resource
|
||||
private MockMvc mockMvc;
|
||||
/**
|
||||
* The Object mapper.
|
||||
*/
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* A 1 login normal login test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a1_loginNormalLoginTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
"\"msgContent\":\"{\\\"password\\\"" +
|
||||
":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/login")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_OK.getHttpCode()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
LoginRsp rspInfo = objectMapper.readValue(verifyResp(ret), LoginRsp.class) ;
|
||||
|
||||
Assert.assertNotNull(rspInfo);
|
||||
Assert.assertNotNull(rspInfo.getUserName());
|
||||
Assert.assertNotNull(rspInfo.getLogTime());
|
||||
Assert.assertNotNull(rspInfo.getToken());
|
||||
Assert.assertNotNull(rspInfo.getExpireTime());
|
||||
Assert.assertNotNull(rspInfo.getMessage());
|
||||
Assert.assertNotNull(rspInfo.getStatus());
|
||||
|
||||
Assert.assertEquals(Long.valueOf(rspInfo.getStatus()), Long.valueOf(ErrorCode.ERR_OK.getCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* A 2 login username as integer exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a2_loginUsernameAsIntegerExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988,\"msgContent\":\"" +
|
||||
"{\\\"password\\\":\\\"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58\\\"," +
|
||||
"\\\"userName\\\":\\\"123456\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/login")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.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()));
|
||||
}
|
||||
|
||||
/**
|
||||
* A 3 login password empty exception test.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a3_loginPasswordEmptyExceptionTest() throws Exception {
|
||||
String reqData = "{\"ver\":2,\"cryptoType\":0,\"timeStamp\":1587604296988," +
|
||||
"\"msgContent\":\"{\\\"password\\\":\\\"\\\",\\\"userName\\\":\\\"admin\\\"}\"}";
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/auth/login")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(reqData))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(ErrorCode.ERR_PASSWORD.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_PASSWORD.getCode()));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue