Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
serega6531 committed May 10, 2020
1 parent e20bc3a commit 1b6c01f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.pcap4j.packet.tls.extensions.UnimplementedTlsExtension;
import org.pcap4j.packet.tls.extensions.keyshare.KeyShareEntry;
import org.pcap4j.packet.tls.extensions.keyshare.ServerKeyShareExtension;
import org.pcap4j.packet.tls.records.AlertRecord;
import org.pcap4j.packet.tls.records.ApplicationDataRecord;
import org.pcap4j.packet.tls.records.HandshakeRecord;
import org.pcap4j.packet.tls.records.TlsRecord;
Expand Down Expand Up @@ -76,6 +77,8 @@ public TlsPacketTest() {

TlsRecord dataRecord = new ApplicationDataRecord(new byte[]{1, 2, 3, 4, 5});

TlsRecord alertRecord = new AlertRecord(AlertLevel.WARNING, AlertDescription.unknown_ca);

b.contentType(ContentType.HANDSHAKE)
.version(TlsVersion.TLS_1_2)
.recordLength((short) 95)
Expand All @@ -84,7 +87,12 @@ public TlsPacketTest() {
.version(TlsVersion.TLS_1_2)
.contentType(ContentType.APPLICATION_DATA)
.recordLength((short) 5)
.record(dataRecord));
.record(dataRecord)
.payloadBuilder(new TlsPacket.Builder()
.version(TlsVersion.TLS_1_2)
.contentType(ContentType.ALERT)
.recordLength((short) 2)
.record(alertRecord)));

this.packet = b.build();
}
Expand Down
6 changes: 5 additions & 1 deletion pcap4j-packettest/src/test/resources/TlsPacketTest.log
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
[TLS Header (10 bytes)]
Version: 771 (TLS 1.2)
Type: 23 (Application Data)
Encrypted data: [5 bytes]
Encrypted data: [5 bytes]
[TLS Header (7 bytes)]
Version: 771 (TLS 1.2)
Type: 21 (Alert)
Alert [level: warning, description: unknown_ca]
Binary file modified pcap4j-packettest/src/test/resources/TlsPacketTest.obj
Binary file not shown.
Binary file modified pcap4j-packettest/src/test/resources/TlsPacketTest.pcap
Binary file not shown.

0 comments on commit 1b6c01f

Please sign in to comment.