Skip to content

Commit f07503b

Browse files
author
Noah Potash
committed
Added factory default tests. Fixed factory default bugs in IEEE802_1x and TCP. Fixed minimum parseable size for IEEE802_1x. Bumped version number.
1 parent 29bd2d8 commit f07503b

17 files changed

+281
-4
lines changed

Diff for: src/LibPacketGremlin/PacketFactories/IEEE802_1xFactory.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ public override bool TryParse(byte[] buffer, int index, int count, out IEEE802_1
3838
/// <returns>A Packet with default values</returns>
3939
public IEEE802_1x<T> Default<T>(T payload) where T : class, IPacket
4040
{
41-
return new IEEE802_1x<T> { Payload = payload };
41+
var packet = new IEEE802_1x<T> { Payload = payload };
42+
packet.CorrectFields();
43+
return packet;
4244
}
4345
}
4446
}

Diff for: src/LibPacketGremlin/PacketFactories/TCPFactory.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ public override bool TryParse(byte[] buffer, int index, int count, out TCP packe
4040
/// <returns>A Packet with default values</returns>
4141
public TCP<T> Default<T>(T payload) where T : class, IPacket
4242
{
43-
return new TCP<T>
43+
var packet = new TCP<T>
4444
{
4545
OptionsAndPadding = Array.Empty<byte>(),
4646
Payload = payload
4747
};
48+
49+
packet.CorrectFields();
50+
return packet;
4851
}
4952
}
5053
}

Diff for: src/LibPacketGremlin/Packets/IEEE802_1x.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace OutbreakLabs.LibPacketGremlin.Packets
1919
/// </summary>
2020
public abstract class IEEE802_1x : IPacket
2121
{
22-
private const int MinimumParseableBytes = 8;
22+
private const int MinimumParseableBytes = 4;
2323

2424
protected UInt16 _BodyLength;
2525

Diff for: src/LibPacketGremlin/project.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.0-beta-3",
2+
"version": "1.0.0-beta-4",
33
"description": "Library for manipulating packets",
44
"authors": [ "Noah Potash" ],
55
"tags": [ "packet", "packets" ],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class ARPFactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = ARPFactory.Instance.Default();
18+
ARPFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class EthernetIIFactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = EthernetIIFactory.Instance.Default(GenericFactory.Instance.Default());
18+
EthernetIIFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class GenericFactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = GenericFactory.Instance.Default();
18+
GenericFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using Xunit;
8+
9+
namespace LibPacketGremlinTests.PacketFactories
10+
{
11+
public class ICMPFactoryTests
12+
{
13+
[Fact]
14+
public void GeneratesParseableDefault()
15+
{
16+
var defaultPacket = ICMPFactory.Instance.Default();
17+
ICMPFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
18+
}
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class IEEE802_1xFactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = IEEE802_1xFactory.Instance.Default(GenericFactory.Instance.Default());
18+
IEEE802_1xFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class IPv4FactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = IPv4Factory.Instance.Default(GenericFactory.Instance.Default());
18+
IPv4Factory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class LLCFactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = LLCFactory.Instance.Default(GenericFactory.Instance.Default());
18+
LLCFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class MSMon802_11FactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = MSMon802_11Factory.Instance.Default(GenericFactory.Instance.Default());
18+
MSMon802_11Factory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class RadiotapFactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = RadiotapFactory.Instance.Default(GenericFactory.Instance.Default());
18+
RadiotapFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class SNAPFactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = SNAPFactory.Instance.Default(GenericFactory.Instance.Default());
18+
SNAPFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class TCPFactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = TCPFactory.Instance.Default(GenericFactory.Instance.Default());
18+
TCPFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class UDPFactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = UDPFactory.Instance.Default(GenericFactory.Instance.Default());
18+
UDPFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FluentAssertions;
2+
using OutbreakLabs.LibPacketGremlin.Extensions;
3+
using OutbreakLabs.LibPacketGremlin.PacketFactories;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Xunit;
9+
10+
namespace LibPacketGremlinTests.PacketFactories
11+
{
12+
public class WakeOnLanFactoryTests
13+
{
14+
[Fact]
15+
public void GeneratesParseableDefault()
16+
{
17+
var defaultPacket = WakeOnLanFactory.Instance.Default();
18+
WakeOnLanFactory.Instance.ParseAs(defaultPacket.ToArray()).Should().NotBeNull();
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)