You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2019/01/03 11:48:58 UTC
svn commit: r1850227 [7/11] - in /webservices/wss4j/trunk: build-tools/
integration/src/test/java/org/apache/wss4j/integration/test/kerberos/
performance/src/test/java/org/apache/wss4j/performance/
policy/src/test/java/org/apache/wss4j/policy/tests/ ws...
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncryptionCRLTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncryptionCRLTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncryptionCRLTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncryptionCRLTest.java Thu Jan 3 11:48:56 2019
@@ -31,12 +31,16 @@ import org.apache.wss4j.common.ext.WSSec
import org.apache.wss4j.stax.ext.WSSConstants;
import org.apache.wss4j.stax.ext.WSSSecurityProperties;
import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
* This is a test for Certificate Revocation List checking before encryption.
*
@@ -62,32 +66,32 @@ public class EncryptionCRLTest extends A
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedKey.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedKey.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
XPathExpression xPathExpression = getXPath("/soap:Envelope/soap:Header/wsse:Security/xenc:EncryptedKey/xenc:EncryptionMethod[@Algorithm='http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p']");
Node node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
- Assert.assertNotNull(node);
+ assertNotNull(node);
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_DataReference.getNamespaceURI(), WSSConstants.TAG_xenc_DataReference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedData.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedData.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
xPathExpression = getXPath("/soap:Envelope/soap:Body/xenc:EncryptedData/xenc:EncryptionMethod[@Algorithm='http://www.w3.org/2001/04/xmlenc#aes256-cbc']");
node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
- Assert.assertNotNull(node);
+ assertNotNull(node);
- Assert.assertEquals(node.getParentNode().getParentNode().getLocalName(), "Body");
+ assertEquals(node.getParentNode().getParentNode().getLocalName(), "Body");
NodeList childNodes = node.getParentNode().getParentNode().getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.TEXT_NODE) {
- Assert.assertEquals(child.getTextContent().trim(), "");
+ assertEquals(child.getTextContent().trim(), "");
} else if (child.getNodeType() == Node.ELEMENT_NODE) {
- Assert.assertEquals(child, nodeList.item(0));
+ assertEquals(child, nodeList.item(0));
} else {
- Assert.fail("Unexpected Node encountered");
+ fail("Unexpected Node encountered");
}
}
}
@@ -114,12 +118,12 @@ public class EncryptionCRLTest extends A
try {
doOutboundSecurity(securityProperties, sourceDocument);
- Assert.fail("Expected failure on a revocation check");
+ fail("Expected failure on a revocation check");
} catch (Exception ex) {
- Assert.assertNotNull(ex.getCause());
- Assert.assertTrue(ex.getCause() instanceof WSSecurityException);
+ assertNotNull(ex.getCause());
+ assertTrue(ex.getCause() instanceof WSSecurityException);
}
}
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/FaultTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/FaultTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/FaultTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/FaultTest.java Thu Jan 3 11:48:56 2019
@@ -35,11 +35,12 @@ import org.apache.wss4j.stax.ext.WSSSecu
import org.apache.wss4j.stax.setup.InboundWSSec;
import org.apache.wss4j.stax.setup.WSSec;
import org.apache.wss4j.stax.test.utils.StAX2DOM;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+
public class FaultTest extends AbstractTestBase {
@Test
@@ -53,7 +54,7 @@ public class FaultTest extends AbstractT
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/HeaderOrderingTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/HeaderOrderingTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/HeaderOrderingTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/HeaderOrderingTest.java Thu Jan 3 11:48:56 2019
@@ -48,11 +48,12 @@ import org.apache.wss4j.stax.test.utils.
import org.apache.xml.security.stax.ext.SecurePart;
import org.apache.xml.security.stax.securityEvent.SecurityEvent;
import org.apache.xml.security.stax.securityEvent.SecurityEventListener;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+
public class HeaderOrderingTest extends AbstractTestBase {
@Test
@@ -85,15 +86,15 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 2);
- Assert.assertEquals(childs.item(0).getLocalName(), "UsernameToken");
- Assert.assertEquals(childs.item(1).getLocalName(), "Signature");
+ assertEquals(childs.getLength(), 2);
+ assertEquals(childs.item(0).getLocalName(), "UsernameToken");
+ assertEquals(childs.item(1).getLocalName(), "Signature");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(2, sigReferences.getLength());
+ assertEquals(2, sigReferences.getLength());
}
//done UsernameToken; now verification:
@@ -133,15 +134,15 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 2);
- Assert.assertEquals(childs.item(0).getLocalName(), "Signature");
- Assert.assertEquals(childs.item(1).getLocalName(), "UsernameToken");
+ assertEquals(childs.getLength(), 2);
+ assertEquals(childs.item(0).getLocalName(), "Signature");
+ assertEquals(childs.item(1).getLocalName(), "UsernameToken");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(2, sigReferences.getLength());
+ assertEquals(2, sigReferences.getLength());
}
//done UsernameToken; now verification:
@@ -182,16 +183,16 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 3);
- Assert.assertEquals(childs.item(0).getLocalName(), "UsernameToken");
- Assert.assertEquals(childs.item(1).getLocalName(), "BinarySecurityToken");
- Assert.assertEquals(childs.item(2).getLocalName(), "Signature");
+ assertEquals(childs.getLength(), 3);
+ assertEquals(childs.item(0).getLocalName(), "UsernameToken");
+ assertEquals(childs.item(1).getLocalName(), "BinarySecurityToken");
+ assertEquals(childs.item(2).getLocalName(), "Signature");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(2, sigReferences.getLength());
+ assertEquals(2, sigReferences.getLength());
}
//done UsernameToken; now verification:
@@ -231,15 +232,15 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 2);
- Assert.assertEquals(childs.item(0).getLocalName(), "Timestamp");
- Assert.assertEquals(childs.item(1).getLocalName(), "Signature");
+ assertEquals(childs.getLength(), 2);
+ assertEquals(childs.item(0).getLocalName(), "Timestamp");
+ assertEquals(childs.item(1).getLocalName(), "Signature");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(2, sigReferences.getLength());
+ assertEquals(2, sigReferences.getLength());
}
//done UsernameToken; now verification:
@@ -279,15 +280,15 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 2);
- Assert.assertEquals(childs.item(0).getLocalName(), "Signature");
- Assert.assertEquals(childs.item(1).getLocalName(), "Timestamp");
+ assertEquals(childs.getLength(), 2);
+ assertEquals(childs.item(0).getLocalName(), "Signature");
+ assertEquals(childs.item(1).getLocalName(), "Timestamp");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(2, sigReferences.getLength());
+ assertEquals(2, sigReferences.getLength());
}
//done UsernameToken; now verification:
@@ -331,16 +332,16 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 3);
- Assert.assertEquals(childs.item(0).getLocalName(), "Timestamp");
- Assert.assertEquals(childs.item(1).getLocalName(), "UsernameToken");
- Assert.assertEquals(childs.item(2).getLocalName(), "Signature");
+ assertEquals(childs.getLength(), 3);
+ assertEquals(childs.item(0).getLocalName(), "Timestamp");
+ assertEquals(childs.item(1).getLocalName(), "UsernameToken");
+ assertEquals(childs.item(2).getLocalName(), "Signature");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(3, sigReferences.getLength());
+ assertEquals(3, sigReferences.getLength());
}
//done UsernameToken; now verification:
@@ -384,16 +385,16 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 3);
- Assert.assertEquals(childs.item(0).getLocalName(), "UsernameToken");
- Assert.assertEquals(childs.item(1).getLocalName(), "Timestamp");
- Assert.assertEquals(childs.item(2).getLocalName(), "Signature");
+ assertEquals(childs.getLength(), 3);
+ assertEquals(childs.item(0).getLocalName(), "UsernameToken");
+ assertEquals(childs.item(1).getLocalName(), "Timestamp");
+ assertEquals(childs.item(2).getLocalName(), "Signature");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(3, sigReferences.getLength());
+ assertEquals(3, sigReferences.getLength());
}
//done UsernameToken; now verification:
@@ -438,17 +439,17 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 4);
- Assert.assertEquals(childs.item(0).getLocalName(), "Timestamp");
- Assert.assertEquals(childs.item(1).getLocalName(), "UsernameToken");
- Assert.assertEquals(childs.item(2).getLocalName(), "BinarySecurityToken");
- Assert.assertEquals(childs.item(3).getLocalName(), "Signature");
+ assertEquals(childs.getLength(), 4);
+ assertEquals(childs.item(0).getLocalName(), "Timestamp");
+ assertEquals(childs.item(1).getLocalName(), "UsernameToken");
+ assertEquals(childs.item(2).getLocalName(), "BinarySecurityToken");
+ assertEquals(childs.item(3).getLocalName(), "Signature");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(3, sigReferences.getLength());
+ assertEquals(3, sigReferences.getLength());
}
//done UsernameToken; now verification:
@@ -505,17 +506,17 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 4);
- Assert.assertEquals(childs.item(0).getLocalName(), "EncryptedKey");
- Assert.assertEquals(childs.item(1).getLocalName(), "EncryptedData");
- Assert.assertEquals(childs.item(2).getLocalName(), "EncryptedData");
- Assert.assertEquals(childs.item(3).getLocalName(), "Signature");
+ assertEquals(childs.getLength(), 4);
+ assertEquals(childs.item(0).getLocalName(), "EncryptedKey");
+ assertEquals(childs.item(1).getLocalName(), "EncryptedData");
+ assertEquals(childs.item(2).getLocalName(), "EncryptedData");
+ assertEquals(childs.item(3).getLocalName(), "Signature");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(3, sigReferences.getLength());
+ assertEquals(3, sigReferences.getLength());
}
//done UsernameToken; now verification:
@@ -574,19 +575,19 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 6);
- Assert.assertEquals(childs.item(0).getLocalName(), "BinarySecurityToken");
- Assert.assertEquals(childs.item(1).getLocalName(), "EncryptedKey");
- Assert.assertEquals(childs.item(2).getLocalName(), "EncryptedData");
- Assert.assertEquals(childs.item(3).getLocalName(), "EncryptedData");
- Assert.assertEquals(childs.item(4).getLocalName(), "BinarySecurityToken");
- Assert.assertEquals(childs.item(5).getLocalName(), "Signature");
+ assertEquals(childs.getLength(), 6);
+ assertEquals(childs.item(0).getLocalName(), "BinarySecurityToken");
+ assertEquals(childs.item(1).getLocalName(), "EncryptedKey");
+ assertEquals(childs.item(2).getLocalName(), "EncryptedData");
+ assertEquals(childs.item(3).getLocalName(), "EncryptedData");
+ assertEquals(childs.item(4).getLocalName(), "BinarySecurityToken");
+ assertEquals(childs.item(5).getLocalName(), "Signature");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(3, sigReferences.getLength());
+ assertEquals(3, sigReferences.getLength());
}
//done UsernameToken; now verification:
@@ -613,7 +614,7 @@ public class HeaderOrderingTest extends
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -639,8 +640,8 @@ public class HeaderOrderingTest extends
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
}
//so we have a request generated, now do the response:
@@ -679,18 +680,18 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 5);
- Assert.assertEquals(childs.item(0).getLocalName(), "Timestamp");
- Assert.assertEquals(childs.item(1).getLocalName(), "UsernameToken");
- Assert.assertEquals(childs.item(2).getLocalName(), "SignatureConfirmation");
- Assert.assertEquals(childs.item(3).getLocalName(), "BinarySecurityToken");
- Assert.assertEquals(childs.item(4).getLocalName(), "Signature");
+ assertEquals(childs.getLength(), 5);
+ assertEquals(childs.item(0).getLocalName(), "Timestamp");
+ assertEquals(childs.item(1).getLocalName(), "UsernameToken");
+ assertEquals(childs.item(2).getLocalName(), "SignatureConfirmation");
+ assertEquals(childs.item(3).getLocalName(), "BinarySecurityToken");
+ assertEquals(childs.item(4).getLocalName(), "Signature");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(4, sigReferences.getLength());
+ assertEquals(4, sigReferences.getLength());
}
//verify SigConf response:
@@ -754,19 +755,19 @@ public class HeaderOrderingTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList securityHeaderElement = document.getElementsByTagNameNS(WSConstants.WSSE_NS, "Security");
- Assert.assertEquals(1, securityHeaderElement.getLength());
+ assertEquals(1, securityHeaderElement.getLength());
NodeList childs = securityHeaderElement.item(0).getChildNodes();
- Assert.assertEquals(childs.getLength(), 6);
- Assert.assertEquals(childs.item(0).getLocalName(), "BinarySecurityToken");
- Assert.assertEquals(childs.item(1).getLocalName(), "EncryptedKey");
- Assert.assertEquals(childs.item(2).getLocalName(), "EncryptedData");
- Assert.assertEquals(childs.item(3).getLocalName(), "EncryptedData");
- Assert.assertEquals(childs.item(4).getLocalName(), "BinarySecurityToken");
- Assert.assertEquals(childs.item(5).getLocalName(), "EncryptedData");
+ assertEquals(childs.getLength(), 6);
+ assertEquals(childs.item(0).getLocalName(), "BinarySecurityToken");
+ assertEquals(childs.item(1).getLocalName(), "EncryptedKey");
+ assertEquals(childs.item(2).getLocalName(), "EncryptedData");
+ assertEquals(childs.item(3).getLocalName(), "EncryptedData");
+ assertEquals(childs.item(4).getLocalName(), "BinarySecurityToken");
+ assertEquals(childs.item(5).getLocalName(), "EncryptedData");
NodeList sigReferences = document.getElementsByTagNameNS(WSConstants.SIG_NS, "Reference");
- Assert.assertEquals(0, sigReferences.getLength()); //0 because the signature is encrypted
+ assertEquals(0, sigReferences.getLength()); //0 because the signature is encrypted
}
//done UsernameToken; now verification:
@@ -775,4 +776,4 @@ public class HeaderOrderingTest extends
doInboundSecurityWithWSS4J(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
}
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InboundWSSecurityContextImplTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InboundWSSecurityContextImplTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InboundWSSecurityContextImplTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InboundWSSecurityContextImplTest.java Thu Jan 3 11:48:56 2019
@@ -65,10 +65,12 @@ import org.apache.xml.security.stax.secu
import org.apache.xml.security.stax.securityEvent.SecurityEventListener;
import org.apache.xml.security.stax.securityEvent.SignatureValueSecurityEvent;
import org.apache.xml.security.stax.securityEvent.SignedElementSecurityEvent;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class InboundWSSecurityContextImplTest {
@BeforeClass
@@ -82,23 +84,23 @@ public class InboundWSSecurityContextImp
final List<SecurityEvent> securityEventList = generateTransportBindingSecurityEvents();
- Assert.assertEquals(securityEventList.size(), 11);
+ assertEquals(securityEventList.size(), 11);
for (int i = 0; i < securityEventList.size(); i++) {
SecurityEvent securityEvent = securityEventList.get(i);
if (securityEvent instanceof HttpsTokenSecurityEvent) {
HttpsTokenSecurityEvent tokenSecurityEvent = (HttpsTokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 2);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_SIGNATURE));
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_ENCRYPTION));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 2);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_SIGNATURE));
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_ENCRYPTION));
} else if (securityEvent instanceof X509TokenSecurityEvent) {
X509TokenSecurityEvent tokenSecurityEvent = (X509TokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS));
} else if (securityEvent instanceof UsernameTokenSecurityEvent) {
UsernameTokenSecurityEvent tokenSecurityEvent = (UsernameTokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENCRYPTED_SUPPORTING_TOKENS));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENCRYPTED_SUPPORTING_TOKENS));
}
}
}
@@ -212,61 +214,61 @@ public class InboundWSSecurityContextImp
boolean encryptedSupportingTokensOccured = false;
boolean mainEncryptionTokenOccured = false;
boolean usernameTokenOccured = false;
- Assert.assertEquals(securityEventList.size(), 34);
+ assertEquals(securityEventList.size(), 34);
int x509TokenIndex = 0;
for (int i = 0; i < securityEventList.size(); i++) {
SecurityEvent securityEvent = securityEventList.get(i);
if (securityEvent instanceof X509TokenSecurityEvent && x509TokenIndex == 0) {
x509TokenIndex++;
X509TokenSecurityEvent tokenSecurityEvent = (X509TokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_ENCRYPTION));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_ENCRYPTION));
mainEncryptionTokenOccured = true;
} else if (securityEvent instanceof X509TokenSecurityEvent && x509TokenIndex == 1) {
x509TokenIndex++;
X509TokenSecurityEvent tokenSecurityEvent = (X509TokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_ENCRYPTED_SUPPORTING_TOKENS));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_ENCRYPTED_SUPPORTING_TOKENS));
signedEndorsingSupportingTokenOccured = true;
} else if (securityEvent instanceof X509TokenSecurityEvent && x509TokenIndex == 2) {
x509TokenIndex++;
X509TokenSecurityEvent tokenSecurityEvent = (X509TokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SUPPORTING_TOKENS));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SUPPORTING_TOKENS));
encryptedSupportingTokensOccured = true;
} else if (securityEvent instanceof X509TokenSecurityEvent && x509TokenIndex == 3) {
x509TokenIndex++;
X509TokenSecurityEvent tokenSecurityEvent = (X509TokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_SIGNATURE));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_SIGNATURE));
supportingTokensOccured = true;
} else if (securityEvent instanceof X509TokenSecurityEvent && x509TokenIndex == 4) {
x509TokenIndex++;
X509TokenSecurityEvent tokenSecurityEvent = (X509TokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENDORSING_SUPPORTING_TOKENS));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENDORSING_SUPPORTING_TOKENS));
signedEndorsingEncryptedSupportingTokenOccured = true;
} else if (securityEvent instanceof X509TokenSecurityEvent && x509TokenIndex == 5) {
x509TokenIndex++;
X509TokenSecurityEvent tokenSecurityEvent = (X509TokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENDORSING_ENCRYPTED_SUPPORTING_TOKENS));
mainSignatureTokenOccured = true;
} else if (securityEvent instanceof UsernameTokenSecurityEvent) {
UsernameTokenSecurityEvent tokenSecurityEvent = (UsernameTokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENCRYPTED_SUPPORTING_TOKENS));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENCRYPTED_SUPPORTING_TOKENS));
usernameTokenOccured = true;
}
}
- Assert.assertTrue(mainSignatureTokenOccured);
- Assert.assertTrue(mainEncryptionTokenOccured);
- Assert.assertTrue(signedEndorsingSupportingTokenOccured);
- Assert.assertTrue(signedEndorsingEncryptedSupportingTokenOccured);
- Assert.assertTrue(supportingTokensOccured);
- Assert.assertTrue(encryptedSupportingTokensOccured);
- Assert.assertTrue(usernameTokenOccured);
+ assertTrue(mainSignatureTokenOccured);
+ assertTrue(mainEncryptionTokenOccured);
+ assertTrue(signedEndorsingSupportingTokenOccured);
+ assertTrue(signedEndorsingEncryptedSupportingTokenOccured);
+ assertTrue(supportingTokensOccured);
+ assertTrue(encryptedSupportingTokensOccured);
+ assertTrue(usernameTokenOccured);
}
public List<SecurityEvent> generateAsymmetricBindingSecurityEvents() throws Exception {
@@ -517,23 +519,23 @@ public class InboundWSSecurityContextImp
final List<SecurityEvent> securityEventList = generateSymmetricBindingSecurityEvents();
- Assert.assertEquals(securityEventList.size(), 24);
+ assertEquals(securityEventList.size(), 24);
for (int i = 0; i < securityEventList.size(); i++) {
SecurityEvent securityEvent = securityEventList.get(i);
if (securityEvent instanceof X509TokenSecurityEvent) {
X509TokenSecurityEvent tokenSecurityEvent = (X509TokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENDORSING_SUPPORTING_TOKENS));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENDORSING_SUPPORTING_TOKENS));
} else if (securityEvent instanceof UsernameTokenSecurityEvent) {
UsernameTokenSecurityEvent tokenSecurityEvent = (UsernameTokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENCRYPTED_SUPPORTING_TOKENS));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 1);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_SIGNED_ENCRYPTED_SUPPORTING_TOKENS));
} else if (securityEvent instanceof SamlTokenSecurityEvent) {
SamlTokenSecurityEvent tokenSecurityEvent = (SamlTokenSecurityEvent) securityEvent;
- Assert.assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 2);
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_SIGNATURE));
- Assert.assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_ENCRYPTION));
+ assertEquals(tokenSecurityEvent.getSecurityToken().getTokenUsages().size(), 2);
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_SIGNATURE));
+ assertTrue(tokenSecurityEvent.getSecurityToken().getTokenUsages().contains(WSSecurityTokenConstants.TOKENUSAGE_MAIN_ENCRYPTION));
}
}
}
@@ -763,4 +765,4 @@ public class InboundWSSecurityContextImp
x509SecurityToken.setX509Certificates(x509Certificates);
return x509SecurityToken;
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InteroperabilityTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InteroperabilityTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InteroperabilityTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InteroperabilityTest.java Thu Jan 3 11:48:56 2019
@@ -62,7 +62,6 @@ import org.apache.xml.security.stax.secu
import org.apache.xml.security.stax.securityEvent.SecurityEventListener;
import org.apache.xml.security.stax.securityEvent.SignatureValueSecurityEvent;
import org.apache.xml.security.stax.securityEvent.SignedElementSecurityEvent;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -71,6 +70,12 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
public class InteroperabilityTest extends AbstractTestBase {
@Test
@@ -160,11 +165,11 @@ public class InteroperabilityTest extend
}
}
- Assert.assertEquals(4, encryptedPartSecurityEvents.size());
- Assert.assertEquals(3, signedElementSecurityEvents1.size());
- Assert.assertEquals(3, signedElementSecurityEvents2.size());
- Assert.assertEquals(4, signatureValueSecurityEvents.size());
- Assert.assertEquals(securityEventListener.getReceivedSecurityEvents().size(),
+ assertEquals(4, encryptedPartSecurityEvents.size());
+ assertEquals(3, signedElementSecurityEvents1.size());
+ assertEquals(3, signedElementSecurityEvents2.size());
+ assertEquals(4, signatureValueSecurityEvents.size());
+ assertEquals(securityEventListener.getReceivedSecurityEvents().size(),
operationSecurityEvents.size() +
encryptedPartSecurityEvents.size() +
signedElementSecurityEvents1.size() +
@@ -325,12 +330,12 @@ public class InteroperabilityTest extend
}
}
- Assert.assertEquals(3, encryptedPartSecurityEvents.size());
- Assert.assertEquals(3, encryptedElementSecurityEvents.size());
- Assert.assertEquals(3, signedElementSecurityEvents1.size());
- Assert.assertEquals(3, signedElementSecurityEvents2.size());
- Assert.assertEquals(4, signatureValueSecurityEvents.size());
- Assert.assertEquals(securityEventListener.getReceivedSecurityEvents().size(),
+ assertEquals(3, encryptedPartSecurityEvents.size());
+ assertEquals(3, encryptedElementSecurityEvents.size());
+ assertEquals(3, signedElementSecurityEvents1.size());
+ assertEquals(3, signedElementSecurityEvents2.size());
+ assertEquals(4, signatureValueSecurityEvents.size());
+ assertEquals(securityEventListener.getReceivedSecurityEvents().size(),
operationSecurityEvents.size() +
encryptedPartSecurityEvents.size() +
encryptedElementSecurityEvents.size() +
@@ -456,10 +461,10 @@ public class InteroperabilityTest extend
}
}
- Assert.assertEquals(4, encryptedPartSecurityEvents.size());
- Assert.assertEquals(3, signedElementSecurityEvents1.size());
- Assert.assertEquals(4, signatureValueSecurityEvents.size());
- Assert.assertEquals(securityEventListener.getReceivedSecurityEvents().size(),
+ assertEquals(4, encryptedPartSecurityEvents.size());
+ assertEquals(3, signedElementSecurityEvents1.size());
+ assertEquals(4, signatureValueSecurityEvents.size());
+ assertEquals(securityEventListener.getReceivedSecurityEvents().size(),
operationSecurityEvents.size() +
encryptedPartSecurityEvents.size() +
signedElementSecurityEvents1.size() +
@@ -636,12 +641,12 @@ public class InteroperabilityTest extend
}
}
- Assert.assertEquals(3, encryptedPartSecurityEvents.size());
- Assert.assertEquals(3, encryptedElementSecurityEvents.size());
- Assert.assertEquals(3, signedElementSecurityEvents1.size());
- Assert.assertEquals(3, signedElementSecurityEvents2.size());
- Assert.assertEquals(4, signatureValueSecurityEvents.size());
- Assert.assertEquals(securityEventListener.getReceivedSecurityEvents().size(),
+ assertEquals(3, encryptedPartSecurityEvents.size());
+ assertEquals(3, encryptedElementSecurityEvents.size());
+ assertEquals(3, signedElementSecurityEvents1.size());
+ assertEquals(3, signedElementSecurityEvents2.size());
+ assertEquals(4, signatureValueSecurityEvents.size());
+ assertEquals(securityEventListener.getReceivedSecurityEvents().size(),
operationSecurityEvents.size() +
encryptedPartSecurityEvents.size() +
encryptedElementSecurityEvents.size() +
@@ -666,7 +671,7 @@ public class InteroperabilityTest extend
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -694,8 +699,8 @@ public class InteroperabilityTest extend
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
}
//so we have a request generated, now do the response:
@@ -720,16 +725,16 @@ public class InteroperabilityTest extend
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Reference.getNamespaceURI(), WSSConstants.TAG_dsig_Reference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
nodeList = document.getElementsByTagNameNS(WSSConstants.NS_SOAP11, WSSConstants.TAG_SOAP_BODY_LN);
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
String idAttrValue = ((Element) nodeList.item(0)).getAttributeNS(WSSConstants.ATT_WSU_ID.getNamespaceURI(), WSSConstants.ATT_WSU_ID.getLocalPart());
- Assert.assertNotNull(idAttrValue);
- Assert.assertTrue(idAttrValue.length() > 0);
+ assertNotNull(idAttrValue);
+ assertTrue(idAttrValue.length() > 0);
}
//verify SigConf response:
@@ -766,13 +771,13 @@ public class InteroperabilityTest extend
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Reference.getNamespaceURI(), WSSConstants.TAG_dsig_Reference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 25);
+ assertEquals(nodeList.getLength(), 25);
nodeList = document.getElementsByTagNameNS("http://www.w3.org/1999/XMLSchema", "complexType");
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -820,7 +825,7 @@ public class InteroperabilityTest extend
securedDocument = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
}
{
@@ -934,8 +939,8 @@ public class InteroperabilityTest extend
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
securityEventListener.compare();
}
@@ -1186,9 +1191,9 @@ public class InteroperabilityTest extend
properties.setProperty(WSHandlerConstants.ACTOR, "anotherTest");
try {
doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
- Assert.fail("Expected WSSecurityException");
+ fail("Expected WSSecurityException");
} catch (WSSecurityException e) {
- Assert.assertEquals(e.getMessage(), "WSS4JHandler: Request does not contain required Security header");
+ assertEquals(e.getMessage(), "WSS4JHandler: Request does not contain required Security header");
}
}
@@ -1307,7 +1312,7 @@ public class InteroperabilityTest extend
StringWriter stringWriter = new StringWriter();
PrintWriter pw = new PrintWriter(stringWriter);
ex.printStackTrace(pw);
- Assert.assertFalse(stringWriter.toString(), t instanceof NullPointerException);
+ assertFalse(stringWriter.toString(), t instanceof NullPointerException);
t = t.getCause();
}
}
@@ -1367,4 +1372,4 @@ public class InteroperabilityTest extend
Node node;
int index;
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/MultipleActionTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/MultipleActionTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/MultipleActionTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/MultipleActionTest.java Thu Jan 3 11:48:56 2019
@@ -35,12 +35,16 @@ import org.apache.wss4j.stax.setup.WSSec
import org.apache.wss4j.stax.test.utils.XmlReaderToWriter;
import org.apache.xml.security.stax.ext.XMLSecurityConstants;
import org.apache.xml.security.stax.securityEvent.SecurityEvent;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
* A test for 2x Signatures + 2x Encryption. This is not supported for now, but these tests are mainly to
* demonstrate an issue with WSS4J/Santuario hanging on the outbound side in certain scenarios.
@@ -70,21 +74,21 @@ public class MultipleActionTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Reference.getNamespaceURI(), WSSConstants.TAG_dsig_Reference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
nodeList = document.getElementsByTagNameNS(WSSConstants.NS_SOAP11, WSSConstants.TAG_SOAP_BODY_LN);
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
String idAttrValue = ((Element) nodeList.item(0)).getAttributeNS(WSSConstants.ATT_WSU_ID.getNamespaceURI(), WSSConstants.ATT_WSU_ID.getLocalPart());
- Assert.assertNotNull(idAttrValue);
- Assert.assertTrue(idAttrValue.length() > 0);
+ assertNotNull(idAttrValue);
+ assertTrue(idAttrValue.length() > 0);
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_c14nExcl_InclusiveNamespaces.getNamespaceURI(), WSSConstants.TAG_c14nExcl_InclusiveNamespaces.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, WSSConstants.ATT_NULL_PrefixList.getLocalPart()), "env");
- Assert.assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, WSSConstants.ATT_NULL_PrefixList.getLocalPart()), "");
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, WSSConstants.ATT_NULL_PrefixList.getLocalPart()), "env");
+ assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, WSSConstants.ATT_NULL_PrefixList.getLocalPart()), "");
}
}
@@ -130,9 +134,9 @@ public class MultipleActionTest extends
try {
WSSec.getOutboundWSSec(properties);
- Assert.fail();
+ fail();
} catch (WSSecurityException ex) {
- Assert.assertTrue(ex.getMessage().contains("Duplicate Actions are not allowed"));
+ assertTrue(ex.getMessage().contains("Duplicate Actions are not allowed"));
}
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/OutputChainTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/OutputChainTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/OutputChainTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/OutputChainTest.java Thu Jan 3 11:48:56 2019
@@ -34,12 +34,15 @@ import org.apache.wss4j.stax.setup.Outbo
import org.apache.wss4j.stax.setup.WSSec;
import org.apache.wss4j.stax.test.utils.XmlReaderToWriter;
import org.apache.xml.security.stax.securityEvent.SecurityEvent;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
public class OutputChainTest extends AbstractTestBase {
@Test
@@ -60,29 +63,29 @@ public class OutputChainTest extends Abs
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedKey.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedKey.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedData.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedData.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), "Body");
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), "Body");
NodeList childNodes = nodeList.item(0).getParentNode().getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.TEXT_NODE) {
- Assert.assertEquals(child.getTextContent().trim(), "");
+ assertEquals(child.getTextContent().trim(), "");
} else if (child.getNodeType() == Node.ELEMENT_NODE) {
- Assert.assertEquals(child, nodeList.item(0));
+ assertEquals(child, nodeList.item(0));
} else {
- Assert.fail("Unexpected Node encountered");
+ fail("Unexpected Node encountered");
}
}
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_WSU_TIMESTAMP.getNamespaceURI(), WSSConstants.TAG_WSU_TIMESTAMP.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
@Test
@@ -104,21 +107,21 @@ public class OutputChainTest extends Abs
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.NS_SOAP11, WSSConstants.TAG_SOAP_BODY_LN);
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
Node attr = nodeList.item(0).getAttributes().getNamedItemNS(WSSConstants.ATT_WSU_ID.getNamespaceURI(), WSSConstants.ATT_WSU_ID.getLocalPart());
- Assert.assertNotNull(attr);
+ assertNotNull(attr);
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedData.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedData.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_WSU_TIMESTAMP.getNamespaceURI(), WSSConstants.TAG_WSU_TIMESTAMP.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
@Test
@@ -138,14 +141,14 @@ public class OutputChainTest extends Abs
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_WSU_TIMESTAMP.getNamespaceURI(), WSSConstants.TAG_WSU_TIMESTAMP.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedData.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedData.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordEncryptorTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordEncryptorTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordEncryptorTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordEncryptorTest.java Thu Jan 3 11:48:56 2019
@@ -41,13 +41,17 @@ import org.apache.wss4j.stax.setup.Outbo
import org.apache.wss4j.stax.setup.WSSec;
import org.apache.wss4j.stax.test.utils.XmlReaderToWriter;
import org.apache.xml.security.stax.securityEvent.SecurityEvent;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
* This is a test for signing and encrypting using a Crypto properties file with an encrypted
* password
@@ -79,21 +83,21 @@ public class PasswordEncryptorTest exten
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Reference.getNamespaceURI(), WSSConstants.TAG_dsig_Reference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
nodeList = document.getElementsByTagNameNS(WSSConstants.NS_SOAP11, WSSConstants.TAG_SOAP_BODY_LN);
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
String idAttrValue = ((Element) nodeList.item(0)).getAttributeNS(WSSConstants.ATT_WSU_ID.getNamespaceURI(), WSSConstants.ATT_WSU_ID.getLocalPart());
- Assert.assertNotNull(idAttrValue);
- Assert.assertTrue(idAttrValue.length() > 0);
+ assertNotNull(idAttrValue);
+ assertTrue(idAttrValue.length() > 0);
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_c14nExcl_InclusiveNamespaces.getNamespaceURI(), WSSConstants.TAG_c14nExcl_InclusiveNamespaces.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, WSSConstants.ATT_NULL_PrefixList.getLocalPart()), "env");
- Assert.assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, WSSConstants.ATT_NULL_PrefixList.getLocalPart()), "");
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, WSSConstants.ATT_NULL_PrefixList.getLocalPart()), "env");
+ assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, WSSConstants.ATT_NULL_PrefixList.getLocalPart()), "");
}
//done signature; now test sig-verification:
{
@@ -123,32 +127,32 @@ public class PasswordEncryptorTest exten
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedKey.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedKey.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
XPathExpression xPathExpression = getXPath("/soap:Envelope/soap:Header/wsse:Security/xenc:EncryptedKey/xenc:EncryptionMethod[@Algorithm='http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p']");
Node node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
- Assert.assertNotNull(node);
+ assertNotNull(node);
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_DataReference.getNamespaceURI(), WSSConstants.TAG_xenc_DataReference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedData.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedData.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
xPathExpression = getXPath("/soap:Envelope/soap:Body/xenc:EncryptedData/xenc:EncryptionMethod[@Algorithm='http://www.w3.org/2001/04/xmlenc#aes256-cbc']");
node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
- Assert.assertNotNull(node);
+ assertNotNull(node);
- Assert.assertEquals(node.getParentNode().getParentNode().getLocalName(), "Body");
+ assertEquals(node.getParentNode().getParentNode().getLocalName(), "Body");
NodeList childNodes = node.getParentNode().getParentNode().getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.TEXT_NODE) {
- Assert.assertEquals(child.getTextContent().trim(), "");
+ assertEquals(child.getTextContent().trim(), "");
} else if (child.getNodeType() == Node.ELEMENT_NODE) {
- Assert.assertEquals(child, nodeList.item(0));
+ assertEquals(child, nodeList.item(0));
} else {
- Assert.fail("Unexpected Node encountered");
+ fail("Unexpected Node encountered");
}
}
}
@@ -160,4 +164,4 @@ public class PasswordEncryptorTest exten
}
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordTypeTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordTypeTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordTypeTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordTypeTest.java Thu Jan 3 11:48:56 2019
@@ -36,12 +36,16 @@ import org.apache.wss4j.stax.ext.WSSSecu
import org.apache.wss4j.stax.setup.InboundWSSec;
import org.apache.wss4j.stax.setup.WSSec;
import org.apache.wss4j.stax.test.utils.StAX2DOM;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
* This is a test for processing a Username Token to enforce either a plaintext or digest
* password type.
@@ -59,11 +63,11 @@ public class PasswordTypeTest extends Ab
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_WSSE_USERNAME_TOKEN.getNamespaceURI(), WSSConstants.TAG_WSSE_USERNAME_TOKEN.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_WSSE_PASSWORD.getNamespaceURI(), WSSConstants.TAG_WSSE_PASSWORD.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, WSSConstants.ATT_NULL_Type.getLocalPart()), WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST.getNamespace());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, WSSConstants.ATT_NULL_Type.getLocalPart()), WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST.getNamespace());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -104,12 +108,12 @@ public class PasswordTypeTest extends Ab
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("Expected XMLStreamException");
+ fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
- Assert.assertTrue(e.getCause() instanceof WSSecurityException);
- Assert.assertEquals(e.getCause().getMessage(), "The security token could not be authenticated or authorized");
- Assert.assertEquals(((WSSecurityException) e.getCause()).getFaultCode(), WSSecurityException.FAILED_AUTHENTICATION);
+ assertNotNull(e.getCause());
+ assertTrue(e.getCause() instanceof WSSecurityException);
+ assertEquals(e.getCause().getMessage(), "The security token could not be authenticated or authorized");
+ assertEquals(((WSSecurityException) e.getCause()).getFaultCode(), WSSecurityException.FAILED_AUTHENTICATION);
}
}
}
@@ -126,11 +130,11 @@ public class PasswordTypeTest extends Ab
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_WSSE_USERNAME_TOKEN.getNamespaceURI(), WSSConstants.TAG_WSSE_USERNAME_TOKEN.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_WSSE_PASSWORD.getNamespaceURI(), WSSConstants.TAG_WSSE_PASSWORD.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, WSSConstants.ATT_NULL_Type.getLocalPart()), WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT.getNamespace());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, WSSConstants.ATT_NULL_Type.getLocalPart()), WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT.getNamespace());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -171,15 +175,15 @@ public class PasswordTypeTest extends Ab
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("Expected XMLStreamException");
+ fail("Expected XMLStreamException");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
- Assert.assertTrue(e.getCause() instanceof WSSecurityException);
- Assert.assertEquals(e.getCause().getMessage(), "The security token could not be authenticated or authorized");
- Assert.assertEquals(((WSSecurityException) e.getCause()).getFaultCode(), WSSecurityException.FAILED_AUTHENTICATION);
+ assertNotNull(e.getCause());
+ assertTrue(e.getCause() instanceof WSSecurityException);
+ assertEquals(e.getCause().getMessage(), "The security token could not be authenticated or authorized");
+ assertEquals(((WSSecurityException) e.getCause()).getFaultCode(), WSSecurityException.FAILED_AUTHENTICATION);
}
}
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PrincipalTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PrincipalTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PrincipalTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PrincipalTest.java Thu Jan 3 11:48:56 2019
@@ -46,9 +46,12 @@ import org.apache.wss4j.stax.ext.WSSCons
import org.apache.wss4j.stax.ext.WSSSecurityProperties;
import org.apache.wss4j.stax.test.saml.SAML1CallbackHandler;
import org.apache.wss4j.stax.test.utils.StAX2DOM;
-import org.junit.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* A test for various Principals...
*/
@@ -65,11 +68,11 @@ public class PrincipalTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_WSSE_USERNAME_TOKEN.getNamespaceURI(), WSSConstants.TAG_WSSE_USERNAME_TOKEN.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_WSSE_PASSWORD.getNamespaceURI(), WSSConstants.TAG_WSSE_PASSWORD.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, WSSConstants.ATT_NULL_Type.getLocalPart()), WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST.getNamespace());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, WSSConstants.ATT_NULL_Type.getLocalPart()), WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST.getNamespace());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -94,17 +97,17 @@ public class PrincipalTest extends Abstr
// Check principal
UsernameTokenSecurityEvent event =
(UsernameTokenSecurityEvent)securityEventListener.getSecurityEvent(WSSecurityEventConstants.USERNAME_TOKEN);
- Assert.assertNotNull(event);
+ assertNotNull(event);
UsernameSecurityToken usernameSecurityToken = event.getSecurityToken();
Principal principal = usernameSecurityToken.getPrincipal();
- Assert.assertTrue(principal instanceof UsernameTokenPrincipal);
+ assertTrue(principal instanceof UsernameTokenPrincipal);
UsernameTokenPrincipal usernameTokenPrincipal = (UsernameTokenPrincipal)principal;
- Assert.assertTrue("transmitter".equals(usernameTokenPrincipal.getName()));
- Assert.assertNotNull(usernameTokenPrincipal.getCreatedTime());
- Assert.assertNotNull(usernameTokenPrincipal.getNonce());
- Assert.assertNotNull(usernameTokenPrincipal.getPassword());
- Assert.assertTrue(usernameTokenPrincipal.isPasswordDigest());
- Assert.assertTrue(WSSConstants.NS_PASSWORD_DIGEST.equals(usernameTokenPrincipal.getPasswordType()));
+ assertTrue("transmitter".equals(usernameTokenPrincipal.getName()));
+ assertNotNull(usernameTokenPrincipal.getCreatedTime());
+ assertNotNull(usernameTokenPrincipal.getNonce());
+ assertNotNull(usernameTokenPrincipal.getPassword());
+ assertTrue(usernameTokenPrincipal.isPasswordDigest());
+ assertTrue(WSSConstants.NS_PASSWORD_DIGEST.equals(usernameTokenPrincipal.getPasswordType()));
}
}
@@ -127,7 +130,7 @@ public class PrincipalTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -152,13 +155,13 @@ public class PrincipalTest extends Abstr
// Check principal
SamlTokenSecurityEvent event =
(SamlTokenSecurityEvent)securityEventListener.getSecurityEvent(WSSecurityEventConstants.SAML_TOKEN);
- Assert.assertNotNull(event);
+ assertNotNull(event);
SamlSecurityToken token = event.getSecurityToken();
Principal principal = token.getPrincipal();
- Assert.assertTrue(principal instanceof SAMLTokenPrincipal);
- Assert.assertTrue(principal.getName().contains("uid=joe"));
- Assert.assertNotNull(((SAMLTokenPrincipal)principal).getToken());
+ assertTrue(principal instanceof SAMLTokenPrincipal);
+ assertTrue(principal.getName().contains("uid=joe"));
+ assertNotNull(((SAMLTokenPrincipal)principal).getToken());
}
}
@@ -173,7 +176,7 @@ public class PrincipalTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -197,11 +200,11 @@ public class PrincipalTest extends Abstr
// Check principal
X509TokenSecurityEvent event =
(X509TokenSecurityEvent)securityEventListener.getSecurityEvent(WSSecurityEventConstants.X509Token);
- Assert.assertNotNull(event);
+ assertNotNull(event);
X509SecurityToken token = event.getSecurityToken();
Principal principal = token.getPrincipal();
- Assert.assertTrue(principal instanceof X500Principal);
+ assertTrue(principal instanceof X500Principal);
}
}
@@ -218,7 +221,7 @@ public class PrincipalTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -243,11 +246,11 @@ public class PrincipalTest extends Abstr
// Check principal
KeyValueTokenSecurityEvent event =
(KeyValueTokenSecurityEvent)securityEventListener.getSecurityEvent(WSSecurityEventConstants.KeyValueToken);
- Assert.assertNotNull(event);
+ assertNotNull(event);
KeyValueSecurityToken token = event.getSecurityToken();
Principal principal = token.getPrincipal();
- Assert.assertTrue(principal instanceof PublicKeyPrincipal);
+ assertTrue(principal instanceof PublicKeyPrincipal);
}
}
@@ -265,7 +268,7 @@ public class PrincipalTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -291,11 +294,11 @@ public class PrincipalTest extends Abstr
// Check principal
KeyValueTokenSecurityEvent event =
(KeyValueTokenSecurityEvent)securityEventListener.getSecurityEvent(WSSecurityEventConstants.KeyValueToken);
- Assert.assertNotNull(event);
+ assertNotNull(event);
KeyValueSecurityToken token = event.getSecurityToken();
Principal principal = token.getPrincipal();
- Assert.assertTrue(principal instanceof PublicKeyPrincipal);
+ assertTrue(principal instanceof PublicKeyPrincipal);
}
}
@@ -324,7 +327,7 @@ public class PrincipalTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -350,11 +353,11 @@ public class PrincipalTest extends Abstr
// Check principal
KeyValueTokenSecurityEvent event =
(KeyValueTokenSecurityEvent)securityEventListener.getSecurityEvent(WSSecurityEventConstants.KeyValueToken);
- Assert.assertNotNull(event);
+ assertNotNull(event);
KeyValueSecurityToken token = event.getSecurityToken();
Principal principal = token.getPrincipal();
- Assert.assertTrue(principal instanceof PublicKeyPrincipal);
+ assertTrue(principal instanceof PublicKeyPrincipal);
}
}
-}
+}
\ No newline at end of file