/// <summary> /// Do not specify the file /// test for inclusion /// should be true as if the feature is turned off /// </summary> public virtual void TestFileNotSpecified() { IPList ipl = new FileBasedIPList(null); NUnit.Framework.Assert.IsFalse("110.113.221.222 is in the list", ipl.IsIn("110.113.221.222" )); }
/// <summary> /// Specify a non existent file /// test for inclusion /// should be true as if the feature is turned off /// </summary> public virtual void TestFileMissing() { IPList ipl = new FileBasedIPList("missingips.txt"); NUnit.Framework.Assert.IsFalse("110.113.221.222 is in the list", ipl.IsIn("110.113.221.222" )); }
public virtual void TestNullIP() { string[] ips = new string[] { "10.119.103.112", "10.221.102.0/23" }; CreateFileWithEntries("ips.txt", ips); IPList ipList = new FileBasedIPList("ips.txt"); NUnit.Framework.Assert.IsFalse("Null Ip is in the list", ipList.IsIn(null)); }
/// <summary> /// Specify an existing file, but empty /// test for inclusion /// should be true as if the feature is turned off /// </summary> /// <exception cref="System.IO.IOException"/> public virtual void TestWithEmptyList() { string[] ips = new string[] { }; CreateFileWithEntries("ips.txt", ips); IPList ipl = new FileBasedIPList("ips.txt"); NUnit.Framework.Assert.IsFalse("110.113.221.222 is in the list", ipl.IsIn("110.113.221.222" )); }
public CombinedIPWhiteList(string fixedWhiteListFile, string variableWhiteListFile , long cacheExpiryInSeconds) { IPList fixedNetworkList = new FileBasedIPList(fixedWhiteListFile); if (variableWhiteListFile != null) { IPList variableNetworkList = new CacheableIPList(new FileBasedIPList(variableWhiteListFile ), cacheExpiryInSeconds); networkLists = new IPList[] { fixedNetworkList, variableNetworkList }; } else { networkLists = new IPList[] { fixedNetworkList }; } }
public virtual void TestSubnetsAndIPs() { string[] ips = new string[] { "10.119.103.112", "10.221.102.0/23" }; CreateFileWithEntries("ips.txt", ips); IPList ipList = new FileBasedIPList("ips.txt"); Assert.True("10.119.103.112 is not in the list", ipList.IsIn("10.119.103.112" )); NUnit.Framework.Assert.IsFalse("10.119.103.113 is in the list", ipList.IsIn("10.119.103.113" )); Assert.True("10.221.102.0 is not in the list", ipList.IsIn("10.221.102.0" )); Assert.True("10.221.102.1 is not in the list", ipList.IsIn("10.221.102.1" )); Assert.True("10.221.103.1 is not in the list", ipList.IsIn("10.221.103.1" )); Assert.True("10.221.103.255 is not in the list", ipList.IsIn("10.221.103.255" )); NUnit.Framework.Assert.IsFalse("10.221.104.0 is in the list", ipList.IsIn("10.221.104.0" )); NUnit.Framework.Assert.IsFalse("10.221.104.1 is in the list", ipList.IsIn("10.221.104.1" )); }