Skip to content

Commit 26c6b0c

Browse files
committed
Removed xml header from tests
1 parent 5a3a46c commit 26c6b0c

14 files changed

+21
-52
lines changed

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/workflow/WorkflowTraceSerializer.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.ArrayList;
2929
import java.util.List;
3030
import java.util.logging.Level;
31-
import javax.imageio.IIOException;
3231
import javax.xml.bind.JAXBContext;
3332
import javax.xml.bind.JAXBException;
3433
import javax.xml.bind.Marshaller;
@@ -37,6 +36,7 @@
3736
import javax.xml.stream.XMLInputFactory;
3837
import javax.xml.stream.XMLStreamException;
3938
import javax.xml.stream.XMLStreamReader;
39+
import javax.xml.transform.TransformerConfigurationException;
4040
import javax.xml.transform.TransformerException;
4141
import javax.xml.xpath.XPathExpressionException;
4242
import javax.xml.xpath.XPathFactoryConfigurationException;
@@ -115,7 +115,16 @@ public static void write(OutputStream outputStream, WorkflowTrace workflowTrace)
115115
context = getJAXBContext();
116116
Marshaller m = context.createMarshaller();
117117
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
118-
m.marshal(workflowTrace, outputStream);
118+
ByteArrayOutputStream tempStream = new ByteArrayOutputStream();
119+
120+
m.marshal(workflowTrace, tempStream);
121+
try {
122+
outputStream.write(XMLPrettyPrinter.prettyPrintXML(new String(tempStream.toByteArray())).getBytes());
123+
} catch (TransformerException | XPathExpressionException | XPathFactoryConfigurationException
124+
| ParserConfigurationException | SAXException ex) {
125+
throw new RuntimeException("Could not format XML");
126+
}
127+
tempStream.close();
119128
outputStream.close();
120129
}
121130

TLS-Core/src/test/java/de/rub/nds/tlsattacker/core/workflow/WorkflowTraceSerializerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void serializeWithSingleConnectionTest() {
121121
action = new SendAction(new ClientHelloMessage(config));
122122
trace.addTlsAction(action);
123123

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

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

217-
StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
217+
StringBuilder sb = new StringBuilder("");
218218
sb.append("<workflowTrace>\n");
219219
sb.append(" <OutboundConnection>\n");
220220
sb.append(" <alias>alias1</alias>\n");

TLS-Core/src/test/java/de/rub/nds/tlsattacker/core/workflow/action/ActionTestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static <T extends TlsAction> void marshalingEmptyActionYieldsMinimalOutpu
8383
logger.warn("The action under test does not follow naming convention. " + xmlName
8484
+ " does not end with string 'Action'");
8585
}
86-
StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
86+
StringBuilder sb = new StringBuilder("");
8787
sb.append("<workflowTrace>\n");
8888
sb.append(" <").append(xmlName).append("/>\n");
8989
sb.append("</workflowTrace>\n");

TLS-Core/src/test/java/de/rub/nds/tlsattacker/core/workflow/action/ForwardActionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void marshalingEmptyActionYieldsMinimalOutput() {
146146
try {
147147
action = new ForwardAction(ctx1Alias, ctx2Alias);
148148
trace.addTlsAction(action);
149-
StringBuilder sb = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
149+
StringBuilder sb = new StringBuilder("");
150150
sb.append("<workflowTrace>\n");
151151
sb.append(" <OutboundConnection>\n");
152152
sb.append(" <alias>ctx1</alias>\n");
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
# Given this config:
2-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
32
<config>
43
</config>
54

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

119
# We expect this normalized trace
12-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1310
<workflowTrace>
1411
<OutboundConnection>
1512
<alias>client</alias>
@@ -21,5 +18,4 @@
2118
</workflowTrace>
2219

2320
# And this after default filter application:
24-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2521
<workflowTrace/>

TLS-Core/src/test/resources/workflow_trace_serialization_tests-positive/test_workflow_trace_handling-positive-1.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Given this config:
2-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
32
<config>
43
</config>
54

65
# And this input trace
7-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
86
<workflowTrace>
97
<Send>
108
<messages>
@@ -14,7 +12,6 @@
1412
</workflowTrace>
1513

1614
# We expect this normalized trace
17-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1815
<workflowTrace>
1916
<OutboundConnection>
2017
<alias>client</alias>
@@ -33,11 +30,10 @@
3330
</workflowTrace>
3431

3532
# And this after default filter application:
36-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3733
<workflowTrace>
3834
<Send>
3935
<messages>
4036
<ClientHello/>
4137
</messages>
4238
</Send>
43-
</workflowTrace>
39+
</workflowTrace>

TLS-Core/src/test/resources/workflow_trace_serialization_tests-positive/test_workflow_trace_handling-positive-2.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Given this config:
2-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
32
<config>
43
<defaulRunningMode>CLIENT</defaulRunningMode>
54
<defaultClientConnection>
@@ -19,12 +18,10 @@
1918
</config>
2019

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

2624
# We expect this normalized trace
27-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2825
<workflowTrace>
2926
<OutboundConnection>
3027
<alias>client</alias>
@@ -36,5 +33,4 @@
3633
</workflowTrace>
3734

3835
# And this after default filter application:
39-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
4036
<workflowTrace/>

TLS-Core/src/test/resources/workflow_trace_serialization_tests-positive/test_workflow_trace_handling-positive-3.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Given this config:
2-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
32
<config>
43
<defaultRunningMode>CLIENT</defaultRunningMode>
54
<defaultClientConnection>
@@ -19,7 +18,6 @@
1918
</config>
2019

2120
# And this input trace
22-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2321
<workflowTrace>
2422
<Send>
2523
<messages>
@@ -29,7 +27,6 @@
2927
</workflowTrace>
3028

3129
# We expect this normalized trace
32-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3330
<workflowTrace>
3431
<OutboundConnection>
3532
<alias>client</alias>
@@ -48,7 +45,6 @@
4845
</workflowTrace>
4946

5047
# And this after default filter application:
51-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5248
<workflowTrace>
5349
<Send>
5450
<messages>

TLS-Core/src/test/resources/workflow_trace_serialization_tests-positive/test_workflow_trace_handling-positive-4.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ Test that user default connections that are explicitly overwritten in the
22
workflow trace are not overwritten by noramlizing and filtering.
33

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

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

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

3027
# And this after default filter application:
31-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3228
<workflowTrace>
3329
<OutboundConnection>
3430
<alias>client</alias>

TLS-Core/src/test/resources/workflow_trace_serialization_tests-positive/test_workflow_trace_handling-positive-5.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
Test custom connection in workflow trace
22

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

87
# And this input trace
9-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
108
<workflowTrace>
119
<OutboundConnection>
1210
<alias>custom</alias>
@@ -15,7 +13,6 @@ Test custom connection in workflow trace
1513
</workflowTrace>
1614

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

2926
# And this after default filter application:
30-
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
3127
<workflowTrace>
3228
<OutboundConnection>
3329
<alias>custom</alias>

0 commit comments

Comments
 (0)