|
@@ -0,0 +1,111 @@
|
|
|
+package com.dragoninfo.dcuc.duceap;
|
|
|
+
|
|
|
+import com.dragonsoft.smtools.enums.SM2SignStrategy;
|
|
|
+import org.junit.Before;
|
|
|
+import org.junit.Test;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+import org.springframework.test.context.web.WebAppConfiguration;
|
|
|
+import org.springframework.test.web.servlet.MockMvc;
|
|
|
+import org.springframework.test.web.servlet.ResultActions;
|
|
|
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
|
|
+import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
|
|
|
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
|
+import org.springframework.web.context.WebApplicationContext;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author mazq
|
|
|
+ * @date 2021/5/11
|
|
|
+ */
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
+@SpringBootTest(classes = DcucDceapApplication.class)
|
|
|
+@WebAppConfiguration
|
|
|
+public class GMSignTest {
|
|
|
+
|
|
|
+ private String baseUrl = "/duceapsvr/v2/gmSignFacade";
|
|
|
+ private String codeId = "DM_ROLE_LEVEL";
|
|
|
+ private String origin = "部级0";
|
|
|
+ private String digest = "56F1BC32905E350680226324BC27DE7F1F0C49A4A303F7810344165D58712598";
|
|
|
+ private String sign = "3044022058BE9306F6442C8003AABD0FA59F1B5414346384ACEFAFCE9161BB4E580BC99102202681B7E3230016793B6BB257958E398E413455070F59EC1EAD0F657420C367E9";
|
|
|
+ private String encode = "teeR/VVEAq4f35mnSa8pzw==";
|
|
|
+
|
|
|
+ public MockMvc mockMvc;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WebApplicationContext webApplicationContext;
|
|
|
+
|
|
|
+ @Before
|
|
|
+ public void setup() {
|
|
|
+ mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void gmSm2Sign() throws Exception {
|
|
|
+ ResultActions perform = mockMvc.perform(MockMvcRequestBuilders.get(baseUrl + "/gmSm2Sign").param("origin", this.origin));
|
|
|
+ perform.andReturn().getResponse().setCharacterEncoding("UTF-8");
|
|
|
+ perform.andDo(MockMvcResultHandlers.print());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void gmSm3Digest() throws Exception {
|
|
|
+ ResultActions perform = mockMvc.perform(MockMvcRequestBuilders.get(baseUrl + "/gmSm3Digest").param("origin", this.origin));
|
|
|
+ perform.andReturn().getResponse().setCharacterEncoding("UTF-8");
|
|
|
+ perform.andDo(MockMvcResultHandlers.print());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void codeGmCheck() throws Exception{
|
|
|
+ ResultActions perform = mockMvc.perform(MockMvcRequestBuilders.get(baseUrl + "/codeGmCheck").param("codeId", this.codeId));
|
|
|
+ perform.andReturn().getResponse().setCharacterEncoding("UTF-8");
|
|
|
+ perform.andDo(MockMvcResultHandlers.print());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void codeGmCheckCodes() throws Exception {
|
|
|
+ ResultActions perform = mockMvc.perform(MockMvcRequestBuilders.get(baseUrl + "/codeGmCheckCodes").param("codeIds", codeId));
|
|
|
+ perform.andReturn().getResponse().setCharacterEncoding("UTF-8");
|
|
|
+ perform.andDo(MockMvcResultHandlers.print());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void codeGmSign() throws Exception {
|
|
|
+ ResultActions perform = mockMvc.perform(MockMvcRequestBuilders.get(baseUrl + "/codeGmSign").param("codeId", this.codeId));
|
|
|
+ perform.andReturn().getResponse().setCharacterEncoding("UTF-8");
|
|
|
+ perform.andDo(MockMvcResultHandlers.print());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void gmSm2Verify() throws Exception {
|
|
|
+ ResultActions perform = mockMvc.perform(MockMvcRequestBuilders.get(baseUrl + "/sm2Verify").param("origin", origin).param("sign", sign));
|
|
|
+ perform.andReturn().getResponse().setCharacterEncoding("UTF-8");
|
|
|
+ perform.andDo(MockMvcResultHandlers.print());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void gmSm3Verify() throws Exception {
|
|
|
+ ResultActions perform = mockMvc.perform(MockMvcRequestBuilders.get(baseUrl + "/gmSm3Verify"));
|
|
|
+ perform.andReturn().getResponse().setCharacterEncoding("UTF-8");
|
|
|
+ perform.andDo(MockMvcResultHandlers.print());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void gmSm4Encode() throws Exception {
|
|
|
+ ResultActions perform = mockMvc.perform(MockMvcRequestBuilders.get(baseUrl + "/gmSm4Encode").param("origin", this.origin));
|
|
|
+ perform.andReturn().getResponse().setCharacterEncoding("UTF-8");
|
|
|
+ perform.andDo(MockMvcResultHandlers.print());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void gmSm4Decode() throws Exception {
|
|
|
+ ResultActions perform = mockMvc.perform(MockMvcRequestBuilders.get(baseUrl + "/gmSm4Decode").param("encode", this.encode));
|
|
|
+ perform.andReturn().getResponse().setCharacterEncoding("UTF-8");
|
|
|
+ perform.andDo(MockMvcResultHandlers.print());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|