|
|
|
@@ -18,7 +18,6 @@ import org.springframework.test.context.ActiveProfiles; |
|
|
|
import org.springframework.test.context.junit4.SpringRunner; |
|
|
|
import org.springframework.test.web.servlet.MockMvc; |
|
|
|
import org.springframework.test.web.servlet.MvcResult; |
|
|
|
import org.springframework.test.web.servlet.RequestBuilder; |
|
|
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; |
|
|
|
import org.springframework.test.web.servlet.result.MockMvcResultHandlers; |
|
|
|
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; |
|
|
|
@@ -41,9 +40,9 @@ public class PosAppTest { |
|
|
|
@Autowired |
|
|
|
private MockMvc mockMvc; |
|
|
|
|
|
|
|
private static final String devId = "fmpos"; |
|
|
|
private static final String devReqKey = "ZiGFLC4@3c5sTLZT"; |
|
|
|
private static final String devResKey = "ugPAM7wd&%p6I0W8"; |
|
|
|
private static final String devId = "neupos"; |
|
|
|
private static final String devReqKey = "qVH2YDmXJ$ok4a95"; |
|
|
|
private static final String devResKey = "VE#1fB2PhUe@&3Of"; |
|
|
|
|
|
|
|
private static final String tenantId = "456"; |
|
|
|
|
|
|
|
@@ -69,7 +68,8 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, ""); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
this.mockMvc.perform(MockMvcRequestBuilders.post("/checkCouponOrderForVerify") |
|
|
|
this.mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/checkCouponOrderForVerify") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr) |
|
|
|
) |
|
|
|
@@ -86,18 +86,19 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/getPosMemConfigStatus") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/getPosMemConfigStatus") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@@ -107,17 +108,17 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.TENANT_ID, tenantId); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/getQrCode") |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/getQrCode") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -133,17 +134,17 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, "100"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/checkMem") |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/checkMem") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -161,17 +162,17 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, "100"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/checkCouponOrderForVerify") |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/checkCouponOrderForVerify") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -189,17 +190,17 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, "100"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/checkCouponOrderForVerify") |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/checkCouponOrderForVerify") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -215,17 +216,18 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, "1"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/couponOrderIndependentVerify") |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/couponOrderIndependentVerify") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -241,17 +243,17 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, "1"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/couponOrderVerifyCancel") |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/couponOrderVerifyCancel") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -265,20 +267,20 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.COUPON_ORDER_ID, "318978990426783744"); |
|
|
|
reqObj.put(WxPayConstant.NONCE_STR, "1"); |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, "1"); |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, "100"); |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, "200"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/couponOrderPreVerify") |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/couponOrderPreVerify") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -294,17 +296,17 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.POS_ORDER_ID, "1"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/couponOrderPreVerifyCancel") |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/couponOrderPreVerifyCancel") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -321,17 +323,17 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, "200"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/couponOrderPayVerifyOne") |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/couponOrderPayVerifyOne") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -348,17 +350,17 @@ public class PosAppTest { |
|
|
|
reqObj.put(WxPayConstant.POS_AMOUNT, "200"); |
|
|
|
reqObj.put(WxPayConstant.SIGN, WxPayment.createSignHMAC(reqObj, devReqKey)); |
|
|
|
String reqJsonStr = JSONObject.toJSONString(reqObj); |
|
|
|
RequestBuilder request = MockMvcRequestBuilders.post("/couponOrderPayVerifyList") |
|
|
|
MvcResult result = mockMvc.perform( |
|
|
|
MockMvcRequestBuilders.post("/couponOrderPayVerifyList") |
|
|
|
.contentType(MediaType.APPLICATION_JSON) |
|
|
|
.content(reqJsonStr); |
|
|
|
MvcResult result = mockMvc.perform(request).andReturn(); |
|
|
|
.content(reqJsonStr)) |
|
|
|
.andExpect(MockMvcResultMatchers.status().isOk()) |
|
|
|
.andDo(MockMvcResultHandlers.print()) |
|
|
|
.andReturn(); |
|
|
|
String responseStr = result.getResponse().getContentAsString(); |
|
|
|
System.out.println(responseStr); |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
Map<String,String> respMap = mapper.readValue(responseStr, Map.class); |
|
|
|
boolean resSigned = WxPayment.verifyNotifyHMAC(respMap, devResKey); |
|
|
|
System.out.println("response sign: " + resSigned); |
|
|
|
Assert.assertEquals(resSigned, true); |
|
|
|
} |
|
|
|
} |