Beispiel #1
0
        public void IsAuthorizedIpWithIPInBlockAddressReturnsTrue()
        {
            this.authorization.AllowIp.Add(IPAddressBlock.Parse("240.0.0.0/4"));

            bool result = this.authorization.IsAuthorized(IPAddress.Parse("242.1.1.15"));

            Assert.True(result);
        }
Beispiel #2
0
        public void IsAuthorizedIpWithAllZerosIPV6AddressReturnsTrue()
        {
            this.authorization.AllowIp.Add(IPAddressBlock.Parse("0:0:0:0:0:0:0:0/0"));

            bool result = this.authorization.IsAuthorized(IPAddress.Parse("1:2:3:4:5:6:7:8"));

            Assert.True(result);
        }
Beispiel #3
0
        public void IsAuthorizedIpWithAllZerosIPAddressReturnsTrue()
        {
            this.authorization.AllowIp.Add(IPAddressBlock.Parse("0.0.0.0/0"));

            bool result = this.authorization.IsAuthorized(IPAddress.Parse("127.1.1.15"));

            Assert.True(result);
        }
Beispiel #4
0
        public void IsAuthorizedIpV6WithIPNotInBlockAddressReturnsTrue()
        {
            this.authorization.AllowIp.Add(IPAddressBlock.Parse("208.0.0.0/4"));

            bool result = this.authorization.IsAuthorized(IPAddress.Parse("0:0:0:0:0:ffff:f201:010f"));

            Assert.False(result);
        }
Beispiel #5
0
        public void IsAuthorizedIpWithIPNotInV6BlockAddressReturnsTrue()
        {
            this.authorization.AllowIp.Add(IPAddressBlock.Parse("0:0:0:0:0:ffff:d000:0/100"));

            bool result = this.authorization.IsAuthorized(IPAddress.Parse("242.1.1.15"));

            Assert.False(result);
        }
Beispiel #6
0
 public void IsAuthorizedInvalidBlockThrowsError()
 {
     Assert.Throws <FormatException>(() => IPAddressBlock.Parse("240.0.0.0/33"));
 }