-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* turning up version number * added integration tests for firewall api and updated gitignire * added ipV6 support * added ipv6_task (thank you ozaroth) * released binary
- Loading branch information
Showing
14 changed files
with
442 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
Source/EvlWatcher/EvlWatcher.Tests.Integration/EvlWatcher.Tests.Integration.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
|
||
<PlatformTarget>x86</PlatformTarget> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" /> | ||
<PackageReference Include="coverlet.collector" Version="3.1.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EvlWatcher\EvlWatcher.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
107 changes: 107 additions & 0 deletions
107
Source/EvlWatcher/EvlWatcher.Tests.Integration/FirewallApiTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using EvlWatcher.SystemAPI; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace EvlWatcher.Tests.Integration | ||
{ | ||
[TestClass] | ||
public class FirewallApiTests | ||
{ | ||
[TestMethod] | ||
public void GetBannedIPs() | ||
{ | ||
//given we have a firewall API | ||
var api = new FirewallAPI(); | ||
|
||
//when we get the bannes IPs, we want a result | ||
var ips = api.GetBannedIPs(); | ||
|
||
Assert.IsNotNull(ips); | ||
} | ||
|
||
[TestMethod] | ||
public void AddV4IP() | ||
{ | ||
//given we have a firewall API, and an empty rule | ||
var api = new FirewallAPI(); | ||
var list = new System.Collections.Generic.List<System.Net.IPAddress>(); | ||
api.AdjustIPBanList(list); | ||
var ips = api.GetBannedIPs(); | ||
Assert.IsNotNull(ips); | ||
Assert.IsTrue(ips.Count == 0); | ||
|
||
//when we add a some ipv4 addresses | ||
list.Add(System.Net.IPAddress.Parse("192.192.182.15")); | ||
list.Add(System.Net.IPAddress.Parse("192.192.182.16")); | ||
list.Add(System.Net.IPAddress.Parse("192.192.182.21")); | ||
api.AdjustIPBanList(list); | ||
|
||
//then we want that address to be in there | ||
ips = api.GetBannedIPs(); | ||
Assert.IsTrue(ips.Contains("192.192.182.15/255.255.255.255")); | ||
Assert.IsTrue(ips.Contains("192.192.182.16/255.255.255.255")); | ||
Assert.IsTrue(ips.Contains("192.192.182.21/255.255.255.255")); | ||
|
||
|
||
} | ||
|
||
[TestMethod] | ||
public void AddV6IP() | ||
{ | ||
//given we have a firewall API, and an empty rule | ||
var api = new FirewallAPI(); | ||
var list = new System.Collections.Generic.List<System.Net.IPAddress>(); | ||
api.AdjustIPBanList(list); | ||
var ips = api.GetBannedIPs(); | ||
Assert.IsNotNull(ips); | ||
Assert.IsTrue(ips.Count == 0); | ||
|
||
//when we add a some ipv6 addresses | ||
list.Add(System.Net.IPAddress.Parse("48a2:ca86:e35:977c:d2dc:1276:1754:f5e6")); | ||
list.Add(System.Net.IPAddress.Parse("2b9c:5213:2df6:9866:5073:45c4:291:d82f")); | ||
list.Add(System.Net.IPAddress.Parse("692d:22df:cd31:d65b:ba37:ba83:fc5b:3d40")); | ||
api.AdjustIPBanList(list); | ||
|
||
//then we want that address to be in there | ||
ips = api.GetBannedIPs(); | ||
Assert.IsTrue(ips.Contains("48a2:ca86:e35:977c:d2dc:1276:1754:f5e6")); | ||
Assert.IsTrue(ips.Contains("2b9c:5213:2df6:9866:5073:45c4:291:d82f")); | ||
Assert.IsTrue(ips.Contains("692d:22df:cd31:d65b:ba37:ba83:fc5b:3d40")); | ||
|
||
|
||
} | ||
|
||
[TestMethod] | ||
public void AddCombinedV4V6() | ||
{ | ||
//given we have a firewall API, and an empty rule | ||
var api = new FirewallAPI(); | ||
var list = new System.Collections.Generic.List<System.Net.IPAddress>(); | ||
api.AdjustIPBanList(list); | ||
var ips = api.GetBannedIPs(); | ||
Assert.IsNotNull(ips); | ||
Assert.IsTrue(ips.Count == 0); | ||
|
||
//when we add a some ipv6 addresses | ||
list.Add(System.Net.IPAddress.Parse("48a2:ca86:e35:977c:d2dc:1276:1754:f5e6")); | ||
list.Add(System.Net.IPAddress.Parse("192.192.182.15")); | ||
list.Add(System.Net.IPAddress.Parse("192.192.182.16")); | ||
list.Add(System.Net.IPAddress.Parse("2b9c:5213:2df6:9866:5073:45c4:291:d82f")); | ||
list.Add(System.Net.IPAddress.Parse("192.192.182.21")); | ||
list.Add(System.Net.IPAddress.Parse("692d:22df:cd31:d65b:ba37:ba83:fc5b:3d40")); | ||
|
||
api.AdjustIPBanList(list); | ||
|
||
//then we want that address to be in there | ||
ips = api.GetBannedIPs(); | ||
Assert.IsTrue(ips.Contains("48a2:ca86:e35:977c:d2dc:1276:1754:f5e6")); | ||
Assert.IsTrue(ips.Contains("2b9c:5213:2df6:9866:5073:45c4:291:d82f")); | ||
Assert.IsTrue(ips.Contains("692d:22df:cd31:d65b:ba37:ba83:fc5b:3d40")); | ||
Assert.IsTrue(ips.Contains("192.192.182.15/255.255.255.255")); | ||
Assert.IsTrue(ips.Contains("192.192.182.16/255.255.255.255")); | ||
Assert.IsTrue(ips.Contains("192.192.182.21/255.255.255.255")); | ||
|
||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.