示例#1
0
        public virtual void TestRemoveSpecificPerms()
        {
            int perms    = ZooDefs.Perms.All;
            int remove   = ZooDefs.Perms.Create;
            int newPerms = ZKUtil.RemoveSpecificPerms(perms, remove);

            Assert.Equal("Removal failed", 0, newPerms & ZooDefs.Perms.Create
                         );
        }
示例#2
0
 private static void BadAcl(string acls, string expectedErr)
 {
     try
     {
         ZKUtil.ParseACLs(acls);
         NUnit.Framework.Assert.Fail("Should have failed to parse '" + acls + "'");
     }
     catch (ZKUtil.BadAclFormatException e)
     {
         Assert.Equal(expectedErr, e.Message);
     }
 }
示例#3
0
        public virtual void TestGoodAuths()
        {
            IList <ZKUtil.ZKAuthInfo> result = ZKUtil.ParseAuth("scheme:data,\n   scheme2:user:pass"
                                                                );

            Assert.Equal(2, result.Count);
            ZKUtil.ZKAuthInfo auth0 = result[0];
            Assert.Equal("scheme", auth0.GetScheme());
            Assert.Equal("data", Runtime.GetStringForBytes(auth0.GetAuth
                                                               ()));
            ZKUtil.ZKAuthInfo auth1 = result[1];
            Assert.Equal("scheme2", auth1.GetScheme());
            Assert.Equal("user:pass", Runtime.GetStringForBytes(auth1
                                                                .GetAuth()));
        }
示例#4
0
        public virtual void TestGoodACLs()
        {
            IList <ACL> result = ZKUtil.ParseACLs("sasl:hdfs/[email protected]:cdrwa, sasl:hdfs/[email protected]:ca"
                                                  );
            ACL acl0 = result[0];

            Assert.Equal(ZooDefs.Perms.Create | ZooDefs.Perms.Delete | ZooDefs.Perms
                         .Read | ZooDefs.Perms.Write | ZooDefs.Perms.Admin, acl0.GetPerms());
            Assert.Equal("sasl", acl0.GetId().GetScheme());
            Assert.Equal("hdfs/[email protected]", acl0.GetId().GetId());
            ACL acl1 = result[1];

            Assert.Equal(ZooDefs.Perms.Create | ZooDefs.Perms.Admin, acl1.
                         GetPerms());
            Assert.Equal("sasl", acl1.GetId().GetScheme());
            Assert.Equal("hdfs/[email protected]", acl1.GetId().GetId());
        }
示例#5
0
 public virtual void TestConfIndirection()
 {
     NUnit.Framework.Assert.IsNull(ZKUtil.ResolveConfIndirection(null));
     Assert.Equal("x", ZKUtil.ResolveConfIndirection("x"));
     TestFile.GetParentFile().Mkdirs();
     Files.Write("hello world", TestFile, Charsets.Utf8);
     Assert.Equal("hello world", ZKUtil.ResolveConfIndirection("@"
                                                               + TestFile.GetAbsolutePath()));
     try
     {
         ZKUtil.ResolveConfIndirection("@" + BogusFile);
         NUnit.Framework.Assert.Fail("Did not throw for non-existent file reference");
     }
     catch (FileNotFoundException fnfe)
     {
         Assert.True(fnfe.Message.StartsWith(BogusFile));
     }
 }
示例#6
0
        public virtual void TestEmptyAuth()
        {
            IList <ZKUtil.ZKAuthInfo> result = ZKUtil.ParseAuth(string.Empty);

            Assert.True(result.IsEmpty());
        }
示例#7
0
        public virtual void TestNullACL()
        {
            IList <ACL> result = ZKUtil.ParseACLs(null);

            Assert.True(result.IsEmpty());
        }
示例#8
0
        public virtual void TestEmptyACL()
        {
            IList <ACL> result = ZKUtil.ParseACLs(string.Empty);

            Assert.True(result.IsEmpty());
        }
示例#9
0
        public virtual void TestNullAuth()
        {
            IList <ZKUtil.ZKAuthInfo> result = ZKUtil.ParseAuth(null);

            Assert.True(result.IsEmpty());
        }