Exemplo n.º 1
0
        public virtual void TestWildcardRW()
        {
            NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "* rw");

            Assert.Equal(AccessPrivilege.ReadWrite, matcher.GetAccessPrivilege
                             (address1, hostname1));
        }
Exemplo n.º 2
0
        public virtual void TestMultiMatchers()
        {
            long shortExpirationPeriod = 1 * 1000 * 1000 * 1000;
            // 1s
            NfsExports matcher = new NfsExports(CacheSize, shortExpirationPeriod, "192.168.0.[0-9]+;[a-z]+.b.com rw"
                                                );

            Assert.Equal(AccessPrivilege.ReadOnly, matcher.GetAccessPrivilege
                             (address1, hostname2));
            Assert.Equal(AccessPrivilege.ReadOnly, matcher.GetAccessPrivilege
                             (address1, address1));
            Assert.Equal(AccessPrivilege.ReadOnly, matcher.GetAccessPrivilege
                             (address1, hostname1));
            Assert.Equal(AccessPrivilege.ReadWrite, matcher.GetAccessPrivilege
                             (address2, hostname1));
            // address2 will hit the cache
            Assert.Equal(AccessPrivilege.ReadWrite, matcher.GetAccessPrivilege
                             (address2, hostname2));
            Thread.Sleep(1000);
            // no cache for address2 now
            AccessPrivilege ap;
            long            startNanos = Runtime.NanoTime();

            do
            {
                ap = matcher.GetAccessPrivilege(address2, address2);
                if (ap == AccessPrivilege.None)
                {
                    break;
                }
                Thread.Sleep(500);
            }while ((Runtime.NanoTime() - startNanos) / NanosPerMillis < 5000);
            Assert.Equal(AccessPrivilege.None, ap);
        }
Exemplo n.º 3
0
        public virtual void TestRegexHostRO()
        {
            NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "[a-z]+.b.com");

            Assert.Equal(AccessPrivilege.ReadOnly, matcher.GetAccessPrivilege
                             (address1, hostname1));
            // address1 will hit the cache
            Assert.Equal(AccessPrivilege.ReadOnly, matcher.GetAccessPrivilege
                             (address1, hostname2));
        }
Exemplo n.º 4
0
        public virtual void TestRegexIPRW()
        {
            NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "192.168.0.[0-9]+ rw"
                                                );

            Assert.Equal(AccessPrivilege.ReadWrite, matcher.GetAccessPrivilege
                             (address1, hostname1));
            Assert.Equal(AccessPrivilege.None, matcher.GetAccessPrivilege(
                             address2, hostname1));
        }
Exemplo n.º 5
0
        public virtual void TestRegexGrouping()
        {
            NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "192.168.0.(12|34)"
                                                );

            Assert.Equal(AccessPrivilege.ReadOnly, matcher.GetAccessPrivilege
                             (address1, hostname1));
            // address1 will hit the cache
            Assert.Equal(AccessPrivilege.ReadOnly, matcher.GetAccessPrivilege
                             (address1, hostname2));
            matcher = new NfsExports(CacheSize, ExpirationPeriod, "\\w*.a.b.com");
            Assert.Equal(AccessPrivilege.ReadOnly, matcher.GetAccessPrivilege
                             ("1.2.3.4", "web.a.b.com"));
            // address "1.2.3.4" will hit the cache
            Assert.Equal(AccessPrivilege.ReadOnly, matcher.GetAccessPrivilege
                             ("1.2.3.4", "email.a.b.org"));
        }
Exemplo n.º 6
0
 public virtual void TestInvalidHost()
 {
     NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "foo#bar");
 }