[ 
https://issues.apache.org/jira/browse/SCB-728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16546114#comment-16546114
 ] 

ASF GitHub Bot commented on SCB-728:
------------------------------------

wujimin commented on a change in pull request #810: [SCB-728] Decrypt/signature 
and adjust form in edge
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/810#discussion_r202913677
 
 

 ##########
 File path: 
demo/demo-edge/consumer/src/main/java/org/apache/servicecomb/demo/edge/consumer/Consumer.java
 ##########
 @@ -111,6 +114,33 @@ public void run(String prefix) {
     checkResult("v2/dec", decV2Result, "2.0.0");
   }
 
+  public void testEncrypt() {
+    prepareEdge("encryptApi");
+    String url = edgePrefix + "/v2/encrypt";
+
+    HttpHeaders headers = new HttpHeaders();
+    headers.setContentType(MediaType.MULTIPART_FORM_DATA);
+
+    MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
+    form.add("name", "userName");
+    form.add("age", "10");
+    form.add("serviceToken", "serviceTokenTest");
+    form.add("hcrId", "hcrIdTest");
+    form.add("body", 
"bodyKey-hcrIdTest-{\"body1\":\"b1\",\"body2\":\"b2\",\"body3\":\"b3\"}");
+
+    HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(form, 
headers);
+
+    @SuppressWarnings("unchecked")
+    Map<String, Object> result = (Map<String, Object>) 
template.postForObject(url, entity, Map.class);
+    Assert.isTrue(result.containsKey("signature"), "must exist signature");
+    result.remove("signature");
+
+    String expected = "{name=userName, age=10, userId=serviceTokenTest-userId, 
body1=b1, body2=b2, body3=b3}";
+    System.out.println("encrypt result: " + result.toString());
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> add decrypt/signature/... to edge demo
> --------------------------------------
>
>                 Key: SCB-728
>                 URL: https://issues.apache.org/jira/browse/SCB-728
>             Project: Apache ServiceComb
>          Issue Type: Task
>          Components: Java-Chassis
>            Reporter: wujimin
>            Assignee: wujimin
>            Priority: Major
>
> 1.add "decrypt“ logic, decrypt field named "body" in form,  generate new 
> multiple fields to form by "body"
> 2.move "signature" to edge, and only signature for one operation
> 3.request with form-data or x-www-form-urlencoded, edge convert to json 
> automatically
> 4.query userId by serviceToken, and put userId back to form
> 5.calc signature from response buffer,  and add "signature" field to response 
> body, eg:
>   before: \{"k":"v"}
>   after:    \{"k":"v","signature":"xxxxx"}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to