Skip to content

Commit

Permalink
Removed xml header from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ic0ns committed Jun 1, 2018
1 parent 5a3a46c commit 26c6b0c
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 52 deletions.
Expand Up @@ -28,7 +28,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import javax.imageio.IIOException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
Expand All @@ -37,6 +36,7 @@
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactoryConfigurationException;
Expand Down Expand Up @@ -115,7 +115,16 @@ public static void write(OutputStream outputStream, WorkflowTrace workflowTrace)
context = getJAXBContext();
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.marshal(workflowTrace, outputStream);
ByteArrayOutputStream tempStream = new ByteArrayOutputStream();

m.marshal(workflowTrace, tempStream);
try {
outputStream.write(XMLPrettyPrinter.prettyPrintXML(new String(tempStream.toByteArray())).getBytes());
} catch (TransformerException | XPathExpressionException | XPathFactoryConfigurationException
| ParserConfigurationException | SAXException ex) {
throw new RuntimeException("Could not format XML");
}
tempStream.close();
outputStream.close();
}

Expand Down
Expand Up @@ -121,7 +121,7 @@ public void serializeWithSingleConnectionTest() {
action = new SendAction(new ClientHelloMessage(config));
trace.addTlsAction(action);

StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
StringBuilder sb = new StringBuilder();
sb.append("<workflowTrace>\n");
sb.append(" <Send>\n");
sb.append(" <messages>\n");
Expand Down Expand Up @@ -164,7 +164,7 @@ public void serializeWithSingleCustomConnectionTest() {
action.setConnectionAlias(con.getAlias());
trace.addTlsAction(action);

StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
StringBuilder sb = new StringBuilder("");
sb.append("<workflowTrace>\n");
sb.append(" <OutboundConnection>\n");
sb.append(" <alias>theAlias</alias>\n");
Expand Down Expand Up @@ -214,7 +214,7 @@ public void serializeWithMultipleCustomConnectionTest() {
action = new SendAction(con3.getAlias(), new ClientHelloMessage(config));
trace.addTlsAction(action);

StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
StringBuilder sb = new StringBuilder("");
sb.append("<workflowTrace>\n");
sb.append(" <OutboundConnection>\n");
sb.append(" <alias>alias1</alias>\n");
Expand Down
Expand Up @@ -83,7 +83,7 @@ public static <T extends TlsAction> void marshalingEmptyActionYieldsMinimalOutpu
logger.warn("The action under test does not follow naming convention. " + xmlName
+ " does not end with string 'Action'");
}
StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
StringBuilder sb = new StringBuilder("");
sb.append("<workflowTrace>\n");
sb.append(" <").append(xmlName).append("/>\n");
sb.append("</workflowTrace>\n");
Expand Down
Expand Up @@ -146,7 +146,7 @@ public void marshalingEmptyActionYieldsMinimalOutput() {
try {
action = new ForwardAction(ctx1Alias, ctx2Alias);
trace.addTlsAction(action);
StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
StringBuilder sb = new StringBuilder("");
sb.append("<workflowTrace>\n");
sb.append(" <OutboundConnection>\n");
sb.append(" <alias>ctx1</alias>\n");
Expand Down
@@ -1,15 +1,12 @@
# Given this config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
</config>

# And this input trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
</workflowTrace>

# We expect this normalized trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand All @@ -21,5 +18,4 @@
</workflowTrace>

# And this after default filter application:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace/>
@@ -1,10 +1,8 @@
# Given this config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
</config>

# And this input trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<Send>
<messages>
Expand All @@ -14,7 +12,6 @@
</workflowTrace>

# We expect this normalized trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand All @@ -33,11 +30,10 @@
</workflowTrace>

# And this after default filter application:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<Send>
<messages>
<ClientHello/>
</messages>
</Send>
</workflowTrace>
</workflowTrace>
@@ -1,5 +1,4 @@
# Given this config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
<defaulRunningMode>CLIENT</defaulRunningMode>
<defaultClientConnection>
Expand All @@ -19,12 +18,10 @@
</config>

# And this input trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
</workflowTrace>

# We expect this normalized trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand All @@ -36,5 +33,4 @@
</workflowTrace>

# And this after default filter application:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace/>
@@ -1,5 +1,4 @@
# Given this config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
<defaultRunningMode>CLIENT</defaultRunningMode>
<defaultClientConnection>
Expand All @@ -19,7 +18,6 @@
</config>

# And this input trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<Send>
<messages>
Expand All @@ -29,7 +27,6 @@
</workflowTrace>

# We expect this normalized trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand All @@ -48,7 +45,6 @@
</workflowTrace>

# And this after default filter application:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<Send>
<messages>
Expand Down
Expand Up @@ -2,12 +2,10 @@ Test that user default connections that are explicitly overwritten in the
workflow trace are not overwritten by noramlizing and filtering.

# Given this config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
</config>

# And this input trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand All @@ -16,7 +14,6 @@ workflow trace are not overwritten by noramlizing and filtering.
</workflowTrace>

# We expect this normalized trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand All @@ -28,7 +25,6 @@ workflow trace are not overwritten by noramlizing and filtering.
</workflowTrace>

# And this after default filter application:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand Down
@@ -1,12 +1,10 @@
Test custom connection in workflow trace

# Given this config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
</config>

# And this input trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>custom</alias>
Expand All @@ -15,7 +13,6 @@ Test custom connection in workflow trace
</workflowTrace>

# We expect this normalized trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>custom</alias>
Expand All @@ -27,7 +24,6 @@ Test custom connection in workflow trace
</workflowTrace>

# And this after default filter application:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>custom</alias>
Expand Down
@@ -1,10 +1,8 @@
# Given this config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
</config>

# And this input trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<timeout>44</timeout>
Expand All @@ -17,7 +15,6 @@
</workflowTrace>

# We expect this normalized trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand All @@ -36,7 +33,6 @@
</workflowTrace>

# And this after default filter application:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<timeout>44</timeout>
Expand All @@ -46,4 +42,4 @@
<ClientHello/>
</messages>
</Send>
</workflowTrace>
</workflowTrace>
Expand Up @@ -3,12 +3,10 @@ if there is only one connection defined in the workflow trace. This is
true for default and custom connections.

# Given this config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
</config>

# And this input trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>custom</alias>
Expand All @@ -22,7 +20,6 @@ true for default and custom connections.
</workflowTrace>

# We expect this normalized trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>custom</alias>
Expand All @@ -41,7 +38,6 @@ true for default and custom connections.
</workflowTrace>

# And this after default filter application:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>custom</alias>
Expand All @@ -52,4 +48,4 @@ true for default and custom connections.
<ClientHello/>
</messages>
</Send>
</workflowTrace>
</workflowTrace>
Expand Up @@ -2,12 +2,10 @@ This test illustrates that connection aliases are removed from actions
if there is only one connection defined in the workflow trace.

# Given this config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
</config>

# And this input trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand All @@ -20,7 +18,6 @@ if there is only one connection defined in the workflow trace.
</workflowTrace>

# We expect this normalized trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand All @@ -39,7 +36,6 @@ if there is only one connection defined in the workflow trace.
</workflowTrace>

# And this after default filter application:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<OutboundConnection>
<alias>client</alias>
Expand All @@ -49,4 +45,4 @@ if there is only one connection defined in the workflow trace.
<ClientHello/>
</messages>
</Send>
</workflowTrace>
</workflowTrace>
@@ -1,13 +1,11 @@
Test a MITM workflow trace

# Given this config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
<runningMode>MITM</runningMode>
</config>

# And this input trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<InboundConnection>
<alias>server</alias>
Expand Down Expand Up @@ -84,7 +82,6 @@ Test a MITM workflow trace


# We expect this normalized trace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<InboundConnection>
<alias>server</alias>
Expand Down Expand Up @@ -178,7 +175,6 @@ Test a MITM workflow trace


# And this after default filter application:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workflowTrace>
<InboundConnection>
<alias>server</alias>
Expand Down Expand Up @@ -251,4 +247,4 @@ Test a MITM workflow trace
<connectionAlias>server</connectionAlias>
<stringEncoding>US_ASCII</stringEncoding>
</PrintLastHandledApplicationData>
</workflowTrace>
</workflowTrace>

0 comments on commit 26c6b0c

Please sign in to comment.