Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }