ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1867003 - /webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java
Date Mon, 16 Sep 2019 13:58:54 GMT
Author: coheigea
Date: Mon Sep 16 13:58:54 2019
New Revision: 1867003

URL: http://svn.apache.org/viewvc?rev=1867003&view=rev
Log:
Adding a SignatureConfirmation unit test

Modified:
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java?rev=1867003&r1=1867002&r2=1867003&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/handler/SignatureConfirmationTest.java
Mon Sep 16 13:58:54 2019
@@ -46,6 +46,7 @@ import org.junit.jupiter.api.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -211,6 +212,7 @@ public class SignatureConfirmationTest {
             LOG.debug(outputString);
         }
         assertTrue(outputString.contains("SignatureConfirmation"));
+        assertTrue(outputString.contains("Value"));
     }
 
 
@@ -316,6 +318,59 @@ public class SignatureConfirmationTest {
         newEngine.processSecurityHeader(doc, data);
     }
 
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testSignatureResponseForUnsignedRequest() throws Exception {
+        final RequestData reqData = new RequestData();
+        java.util.Map<String, Object> msgContext = new java.util.TreeMap<>();
+        msgContext.put(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, "true");
+        msgContext.put(WSHandlerConstants.SIG_PROP_FILE, "crypto.properties");
+        msgContext.put("password", "security");
+        reqData.setMsgContext(msgContext);
+        reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
+
+        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        CustomHandler handler = new CustomHandler();
+        HandlerAction action = new HandlerAction(WSConstants.NO_SECURITY);
+        handler.send(
+            doc,
+            reqData,
+            Collections.singletonList(action),
+            true
+        );
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("After Signing....");
+            String outputString =
+                XMLUtils.prettyDocumentToString(doc);
+            LOG.debug(outputString);
+        }
+
+        //
+        // Verify the inbound request, and create a response with a Signature Confirmation
+        //
+        WSHandlerResult results = verify(doc);
+        doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+        msgContext = (java.util.Map<String, Object>)reqData.getMsgContext();
+        List<WSHandlerResult> receivedResults = new ArrayList<>();
+        receivedResults.add(results);
+        msgContext.put(WSHandlerConstants.RECV_RESULTS, receivedResults);
+        action = new HandlerAction(WSConstants.NO_SECURITY);
+        handler.send(
+            doc,
+            reqData,
+            Collections.singletonList(action),
+            false
+        );
+        String outputString =
+            XMLUtils.prettyDocumentToString(doc);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Signature Confirmation response....");
+            LOG.debug(outputString);
+        }
+        assertTrue(outputString.contains("SignatureConfirmation"));
+        // We should have no Value attribute
+        assertFalse(outputString.contains("Value"));
+    }
 
     /**
      * Verifies the soap envelope



Mime
View raw message