示例#1
0
        public void Test()
        {
            TAAuthorizer     a1 = new ConstantAuthorizer(TAAuthorizer.Decision.Allow);
            TransportAddress ta = TransportAddressFactory.CreateInstance("brunet.udp://127.0.0.1:45");

            Assert.IsTrue(a1.IsNotDenied(ta), "constant allow");
            TAAuthorizer a2 = new ConstantAuthorizer(TAAuthorizer.Decision.Deny);

            Assert.IsFalse(a2.IsNotDenied(ta), "constant deny");

            IPAddress    network = IPAddress.Parse("10.128.0.0");
            TAAuthorizer a3      = new NetmaskTAAuthorizer(network, 9,
                                                           TAAuthorizer.Decision.Deny,
                                                           TAAuthorizer.Decision.None);
            TransportAddress ta2 = TransportAddressFactory.CreateInstance("brunet.udp://10.255.255.255:80");

            Assert.AreEqual(a3.Authorize(ta2), TAAuthorizer.Decision.Deny, "Netmask Deny");
            TransportAddress ta3 = TransportAddressFactory.CreateInstance("brunet.udp://10.1.255.255:80");

            Assert.AreEqual(a3.Authorize(ta3), TAAuthorizer.Decision.None, "Netmask None");
            //Here is the series:
            //If Netmask doesn't say no, constant says yes:
            TAAuthorizer[] my_auths = new TAAuthorizer[] { a3, a1 };
            TAAuthorizer   a4       = new SeriesTAAuthorizer(my_auths);

            Assert.AreEqual(a4.Authorize(ta2), TAAuthorizer.Decision.Deny, "Series Deny");
            Assert.AreEqual(a4.Authorize(ta3), TAAuthorizer.Decision.Allow, "Series Allow");
        }
示例#2
0
 public void Test() {
   TAAuthorizer a1 = new ConstantAuthorizer(TAAuthorizer.Decision.Allow);
   TransportAddress ta = TransportAddressFactory.CreateInstance("brunet.udp://127.0.0.1:45");
   Assert.IsTrue( a1.IsNotDenied( ta ), "constant allow");
   TAAuthorizer a2 = new ConstantAuthorizer(TAAuthorizer.Decision.Deny);
   Assert.IsFalse( a2.IsNotDenied( ta ), "constant deny");
   
   IPAddress network = IPAddress.Parse("10.128.0.0");
   TAAuthorizer a3 = new NetmaskTAAuthorizer(network, 9,
                                             TAAuthorizer.Decision.Deny,
                                             TAAuthorizer.Decision.None);
   TransportAddress ta2 = TransportAddressFactory.CreateInstance("brunet.udp://10.255.255.255:80");
   Assert.AreEqual(a3.Authorize(ta2), TAAuthorizer.Decision.Deny, "Netmask Deny");
   TransportAddress ta3 = TransportAddressFactory.CreateInstance("brunet.udp://10.1.255.255:80");
   Assert.AreEqual(a3.Authorize(ta3), TAAuthorizer.Decision.None, "Netmask None");
   //Here is the series:
   //If Netmask doesn't say no, constant says yes:
   TAAuthorizer[] my_auths = new TAAuthorizer[]{ a3, a1 };
   TAAuthorizer a4 = new SeriesTAAuthorizer(my_auths);
   Assert.AreEqual(a4.Authorize(ta2), TAAuthorizer.Decision.Deny, "Series Deny");
   Assert.AreEqual(a4.Authorize(ta3), TAAuthorizer.Decision.Allow, "Series Allow");
 }