Commit 167f70dd authored by wangjinjing's avatar wangjinjing

bug

parent 549330dd
......@@ -29,8 +29,6 @@ public class MainTest {
String nonce = "2";
String timestampStr = "21";
String appId = "1872576325743943682";
String appSecret = "2";
@Resource
private ObjectMapper objectMapper;
......@@ -41,47 +39,18 @@ public class MainTest {
/**
* 任务完成情况
*/
// @Test
@Test
@DisplayName("任务完成情况")
public void xxRwwcqkTest() {
timestampStr = String.valueOf(System.currentTimeMillis() / 1000);
nonce = UUID.randomUUID().toString();
// String secretKey = this.appStoreService.getAppSecretByAppKey(appId);
appSecret = DigestUtil.md5Hex(appSecret);
Assertions.assertNotNull(appId, "appId不存在");//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
XxRwwcqkDTO xxRwwcqkDTO = new XxRwwcqkDTO();
xxRwwcqkDTO.setRwid("1234");
xxRwwcqkDTO.setXxyid("12345");
xxRwwcqkDTO.setShrid("12345");
xxRwwcqkDTO.setRwid("12345678");
xxRwwcqkDTO.setXxyid("123456785");
xxRwwcqkDTO.setShrid("123456785");
xxRwwcqkDTO.setWczt("1");
xxRwwcqkDTO.setBmzt("1");
String json = null;
try {
json = objectMapper.writeValueAsString(xxRwwcqkDTO);
} catch (JsonProcessingException e) {
Assertions.fail("json序列化失败");
}
//请求体加密
json = EncryptUtil.getInstance().AESEncode(json, appSecret);
//签名appId+nonce+timestampStr+aes(body)
String data = String.format("%s%s%s%s", appId, nonce, timestampStr, json);
String generatedSignature = DigestUtil.md5Hex(data);
//请求
WebClient webClient = WebClient.builder()
.baseUrl("http://localhost:8086")
.defaultHeader("Content-Type", "application/json")
.build();
String response = webClient.post().uri("/rest/index/addXxRwwcqk")
.header(SignatureUtil.APPID, appId)
.header(SignatureUtil.NONCE, nonce)
.header(SignatureUtil.TIMESTAMP, timestampStr)
.header(SignatureUtil.SIGNATURE, generatedSignature)
.body(Mono.just(xxRwwcqkDTO), XxRwwcqkDTO.class)
.retrieve()
.bodyToMono(String.class)
.block();
System.out.println(response);
// TestHttpUtil.signatureAndRequest("/rest/index/addXxRwwcqk", xxRwwcqkDTO, XxRwwcqkDTO.class);
TestHttpUtil.signatureAndRequest("/rest/index/updateXxRwwcqk", xxRwwcqkDTO, XxRwwcqkDTO.class);
}
/**
......@@ -90,43 +59,14 @@ public class MainTest {
@Test
@DisplayName("账户信息")
public void zhxxtest() {
timestampStr = String.valueOf(System.currentTimeMillis() / 1000);
nonce = UUID.randomUUID().toString();
String secretKey = this.appStoreService.getAppSecretByAppKey(appId);
Assertions.assertNotNull(secretKey, "appId不存在");//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
XxZhxxDTO dto = new XxZhxxDTO();
dto.setZhid("1234");
dto.setZhid("12345678");
dto.setXxyid("11");
dto.setZt("2");
dto.setClbz("2");
String json = null;
try {
json = objectMapper.writeValueAsString(dto);
} catch (JsonProcessingException e) {
Assertions.fail("json序列化失败");
}
//请求体加密
json = EncryptUtil.getInstance().AESEncode(json, secretKey);
//签名appId+nonce+timestampStr+aes(body)
String data = String.format("%s%s%s%s", appId, nonce, timestampStr, json);
String generatedSignature = DigestUtil.md5Hex(data);
//请求
WebClient webClient = WebClient.builder()
.baseUrl("http://localhost:8086")
.defaultHeader("Content-Type", "application/json")
.build();
String response = webClient.post().uri("/rest/xxZhxx/add")
.header(SignatureUtil.APPID, appId)
.header(SignatureUtil.NONCE, nonce)
.header(SignatureUtil.TIMESTAMP, timestampStr)
.header(SignatureUtil.SIGNATURE, generatedSignature)
.body(Mono.just(dto), XxZhxxDTO.class)
.retrieve()
.bodyToMono(String.class)
.block();
System.out.println(response);
// TestHttpUtil.signatureAndRequest("/rest/xxZhxx/add", dto, XxZhxxDTO.class);
TestHttpUtil.signatureAndRequest("/rest/xxZhxx/update", dto, XxZhxxDTO.class);
}
/**
......@@ -135,43 +75,14 @@ public class MainTest {
@Test
@DisplayName("账户积分变更")
public void test1() {
timestampStr = String.valueOf(System.currentTimeMillis() / 1000);
nonce = UUID.randomUUID().toString();
String secretKey = this.appStoreService.getAppSecretByAppKey(appId);
Assertions.assertNotNull(secretKey, "appId不存在");//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
XxZhjfbgDTO dto = new XxZhjfbgDTO();
// dto.setZhid("1234");
dto.setDhid("1234");
// dto.setZhid("12345678");
dto.setDhid("12345678");
dto.setQbid("2");
dto.setBgsj(new Date());
String json = null;
try {
json = objectMapper.writeValueAsString(dto);
} catch (JsonProcessingException e) {
Assertions.fail("json序列化失败");
}
//请求体加密
json = EncryptUtil.getInstance().AESEncode(json, secretKey);
//签名appId+nonce+timestampStr+aes(body)
String data = String.format("%s%s%s%s", appId, nonce, timestampStr, json);
String generatedSignature = DigestUtil.md5Hex(data);
//请求
WebClient webClient = WebClient.builder()
.baseUrl("http://localhost:8086")
.defaultHeader("Content-Type", "application/json")
.build();
String response = webClient.post().uri("/rest/xxZhjfbg/add")
.header(SignatureUtil.APPID, appId)
.header(SignatureUtil.NONCE, nonce)
.header(SignatureUtil.TIMESTAMP, timestampStr)
.header(SignatureUtil.SIGNATURE, generatedSignature)
.body(Mono.just(dto), XxZhjfbgDTO.class)
.retrieve()
.bodyToMono(String.class)
.block();
System.out.println(response);
// TestHttpUtil.signatureAndRequest("/rest/xxZhjfbg/add", dto, XxZhjfbgDTO.class);
TestHttpUtil.signatureAndRequest("/rest/xxZhjfbg/update", dto, XxZhjfbgDTO.class);
}
......@@ -224,46 +135,17 @@ public class MainTest {
@Test
@DisplayName("义警任务")
public void test4() {
timestampStr = String.valueOf(System.currentTimeMillis() / 1000);
nonce = UUID.randomUUID().toString();
String secretKey = this.appStoreService.getAppSecretByAppKey(appId);
Assertions.assertNotNull(secretKey, "appId不存在");//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
XxYjrwDTO dto = new XxYjrwDTO();
// dto.setZhid("1234");
dto.setRwid("123456");
// dto.setZhid("12345678");
dto.setRwid("1234567856");
dto.setRwbt("1");
dto.setRwnr("11111");
dto.setGzrs(1L);
dto.setSfsh(1);
dto.setWcrs(1L);
String json = null;
try {
json = objectMapper.writeValueAsString(dto);
} catch (JsonProcessingException e) {
Assertions.fail("json序列化失败");
}
//请求体加密
json = EncryptUtil.getInstance().AESEncode(json, secretKey);
//签名appId+nonce+timestampStr+aes(body)
String data = String.format("%s%s%s%s", appId, nonce, timestampStr, json);
String generatedSignature = DigestUtil.md5Hex(data);
//请求
WebClient webClient = WebClient.builder()
.baseUrl("http://localhost:8086")
.defaultHeader("Content-Type", "application/json")
.build();
String response = webClient.post().uri("/rest/xxYjrw/update")
.header(SignatureUtil.APPID, appId)
.header(SignatureUtil.NONCE, nonce)
.header(SignatureUtil.TIMESTAMP, timestampStr)
.header(SignatureUtil.SIGNATURE, generatedSignature)
.body(Mono.just(dto), XxYjrwDTO.class)
.retrieve()
.bodyToMono(String.class)
.block();
System.out.println(response);
// TestHttpUtil.signatureAndRequest("/rest/xxYjrw/add", dto, XxYjrwDTO.class);
TestHttpUtil.signatureAndRequest("/rest/xxYjrw/update", dto, XxYjrwDTO.class);
}
/**
......@@ -272,179 +154,57 @@ public class MainTest {
@Test
@DisplayName("义警队伍代码")
public void test5() {
timestampStr = String.valueOf(System.currentTimeMillis() / 1000);
nonce = UUID.randomUUID().toString();
String secretKey = this.appStoreService.getAppSecretByAppKey(appId);
Assertions.assertNotNull(secretKey, "appId不存在");//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
XxYjdwdmDTO dto = new XxYjdwdmDTO();
// dto.setZhid("1234");
// dto.setZhid("12345678");
dto.setDwlx(Integer.valueOf(1));
dto.setId("1234");
dto.setId("12345678");
dto.setMchid("11111");
dto.setZt("1");
dto.setYjdwmc("test");
String json = null;
try {
json = objectMapper.writeValueAsString(dto);
} catch (JsonProcessingException e) {
Assertions.fail("json序列化失败");
}
//请求体加密
json = EncryptUtil.getInstance().AESEncode(json, secretKey);
//签名appId+nonce+timestampStr+aes(body)
String data = String.format("%s%s%s%s", appId, nonce, timestampStr, json);
String generatedSignature = DigestUtil.md5Hex(data);
//请求
WebClient webClient = WebClient.builder()
.baseUrl("http://localhost:8086")
.defaultHeader("Content-Type", "application/json")
.build();
String response = webClient.post().uri("/rest/xxYjdwdm/add")
.header(SignatureUtil.APPID, appId)
.header(SignatureUtil.NONCE, nonce)
.header(SignatureUtil.TIMESTAMP, timestampStr)
.header(SignatureUtil.SIGNATURE, generatedSignature)
.body(Mono.just(dto), XxYjdwdmDTO.class)
.retrieve()
.bodyToMono(String.class)
.block();
System.out.println(response);
// TestHttpUtil.signatureAndRequest("/rest/xxYjdwdm/add", dto, XxYjdwdmDTO.class);
TestHttpUtil.signatureAndRequest("/rest/xxYjdwdm/update", dto, XxYjdwdmDTO.class);
}
@Test
@DisplayName("社会信息员队伍")
public void test6() {
timestampStr = String.valueOf(System.currentTimeMillis() / 1000);
nonce = UUID.randomUUID().toString();
String secretKey = this.appStoreService.getAppSecretByAppKey(appId);
Assertions.assertNotNull(secretKey, "appId不存在");//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
XxShxxyDwDTO dto = new XxShxxyDwDTO();
dto.setId("1234");
dto.setDwdm("1234");
dto.setShxxyid("1234");
String json = null;
try {
json = objectMapper.writeValueAsString(dto);
} catch (JsonProcessingException e) {
Assertions.fail("json序列化失败");
}
//请求体加密
json = EncryptUtil.getInstance().AESEncode(json, secretKey);
//签名appId+nonce+timestampStr+aes(body)
String data = String.format("%s%s%s%s", appId, nonce, timestampStr, json);
String generatedSignature = DigestUtil.md5Hex(data);
//请求
WebClient webClient = WebClient.builder()
.baseUrl("http://localhost:8086")
.defaultHeader("Content-Type", "application/json")
.build();
String response = webClient.post().uri("/rest/xxShxxyDw/add")
.header(SignatureUtil.APPID, appId)
.header(SignatureUtil.NONCE, nonce)
.header(SignatureUtil.TIMESTAMP, timestampStr)
.header(SignatureUtil.SIGNATURE, generatedSignature)
.body(Mono.just(dto), XxShxxyDw.class)
.retrieve()
.bodyToMono(String.class)
.block();
System.out.println(response);
dto.setId("12345678");
dto.setDwdm("12345678");
dto.setShxxyid("12345678");
// TestHttpUtil.signatureAndRequest("/rest/xxShxxyDw/add", dto, XxShxxyDwDTO.class);
TestHttpUtil.signatureAndRequest("/rest/xxShxxyDw/update", dto, XxShxxyDwDTO.class);
}
@Test
@DisplayName("社会信息员")
public void test7() {
timestampStr = String.valueOf(System.currentTimeMillis() / 1000);
nonce = UUID.randomUUID().toString();
String secretKey = this.appStoreService.getAppSecretByAppKey(appId);
Assertions.assertNotNull(secretKey, "appId不存在");//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
XxShxxyDTO dto = new XxShxxyDTO();
dto.setXxyid("1234");
dto.setXxyid("12345678");
dto.setZt("1");
dto.setSbfszt("1");
dto.setShrid("1");
String json = null;
try {
json = objectMapper.writeValueAsString(dto);
} catch (JsonProcessingException e) {
Assertions.fail("json序列化失败");
}
//请求体加密
json = EncryptUtil.getInstance().AESEncode(json, secretKey);
//签名appId+nonce+timestampStr+aes(body)
String data = String.format("%s%s%s%s", appId, nonce, timestampStr, json);
String generatedSignature = DigestUtil.md5Hex(data);
//请求
WebClient webClient = WebClient.builder()
.baseUrl("http://localhost:8086")
.defaultHeader("Content-Type", "application/json")
.build();
String response = webClient.post().uri("/rest/xxShxxy/add")
.header(SignatureUtil.APPID, appId)
.header(SignatureUtil.NONCE, nonce)
.header(SignatureUtil.TIMESTAMP, timestampStr)
.header(SignatureUtil.SIGNATURE, generatedSignature)
.body(Mono.just(dto), XxShxxyDTO.class)
.retrieve()
.bodyToMono(String.class)
.block();
System.out.println(response);
// TestHttpUtil.signatureAndRequest("/rest/xxShxxy/add", dto, XxShxxyDTO.class);
TestHttpUtil.signatureAndRequest("/rest/xxShxxy/update", dto, XxShxxyDTO.class);
}
@Test
@DisplayName("删除服务")
public void testdelete() {
timestampStr = String.valueOf(System.currentTimeMillis() / 1000);
nonce = UUID.randomUUID().toString();
String secretKey = this.appStoreService.getAppSecretByAppKey(appId);
Assertions.assertNotNull(secretKey, "appId不存在");//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
String json = null;
List<String> ids = new ArrayList<>();
ids.add("1234");
ids.add("12345");
ids.add("12345678");
ids.add("123456785");
CommonDelParamDTO dto=new CommonDelParamDTO();
dto.setIds(ids);
try {
json = objectMapper.writeValueAsString(dto);
} catch (JsonProcessingException e) {
Assertions.fail("json序列化失败");
}
//请求体加密
String json1 = EncryptUtil.getInstance().AESEncode(json, secretKey);
//签名appId+nonce+timestampStr+aes(body)
String data = String.format("%s%s%s%s", appId, nonce, timestampStr, json1);
String generatedSignature = DigestUtil.md5Hex(data);
//请求
WebClient webClient = WebClient.builder()
.baseUrl("http://localhost:8086")
.defaultHeader("Content-Type", "application/json")
.build();
// String url="xxShxxyDw/delete";
// String url="xxShxxy/delete";
// String url="xxYjdwdm/delete";
// String url="xxYjrw/delete";
//
// String url="xxZhjfbg/delete";
//
String url = "xxZhxx/delete";
String response = webClient.post().uri("/rest/" + url)
.header(SignatureUtil.APPID, appId)
.header(SignatureUtil.NONCE, nonce)
.header(SignatureUtil.TIMESTAMP, timestampStr)
.header(SignatureUtil.SIGNATURE, generatedSignature)
.body(Mono.just(dto), CommonDelDTO.class)
.retrieve()
.bodyToMono(String.class)
.block();
System.out.println(response);
TestHttpUtil.signatureAndRequest("/rest/"+url, dto, CommonDelParamDTO.class);
}
}
......@@ -25,7 +25,7 @@ public class TestHttpUtil {
Assertions.assertNotNull(path, "path不能为空");
Assertions.assertNotNull(source, "请求参数不能为空");
timestampStr = String.valueOf(System.currentTimeMillis() / 1000);
nonce = String.valueOf(System.currentTimeMillis() / 1000);
nonce = String.valueOf(System.currentTimeMillis());
appSecret = DigestUtil.md5Hex(appSecret);
String json = null;
try {
......@@ -60,7 +60,7 @@ public class TestHttpUtil {
Assertions.assertNotNull(path, "path不能为空");
Assertions.assertNotNull(source, "请求参数不能为空");
timestampStr = String.valueOf(System.currentTimeMillis() / 1000);
nonce = String.valueOf(System.currentTimeMillis() / 1000);
nonce = String.valueOf(System.currentTimeMillis());
appSecret = DigestUtil.md5Hex(appSecret);
String json = null;
try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment