public void AnIpIsContainedInItsNetwork_Subnet23() { var checker = new IpNetworkChecker(); var ip = "10.0.1.222"; var container = "10.0.0.0/23"; Assert.That(checker.Check(ip, container), Is.True); }
public void AnIpIsNotContainedInAnotherNetwork() { var checker = new IpNetworkChecker(); var ip = "10.0.1.222"; var container = "10.0.0.0/24"; Assert.That(checker.Check(ip, container), Is.False); }
public void TwoEqualIpAddressesAreContainedOneInTheOther() { var checker = new IpNetworkChecker(); var ip = "10.0.0.222"; var container = "10.0.0.222"; Assert.That(checker.Check(ip, container), Is.True); }
public void TwoDifferentIpAddressesAreContainedOneInTheOther() { var checker = new IpNetworkChecker(); var ip = "10.0.0.222"; var container = "10.0.0.223"; Assert.That(checker.Check(ip, container), Is.False); }
public void Store(MessaggioPosizione messaggio) { var sourceIp = HttpContext.Current.Request.UserHostAddress; if (this.AllowedSources.All(allowed => !checker.Check(sourceIp, allowed))) { throw new UnauthorizedAccessException("Client not authorized by the current configuration policies."); } this.decorated.Store(messaggio); }