示例#1
0
        public virtual void TestAccess()
        {
            fs.SetPermission(target, new FsPermission((short)0x2));
            fs.SetAcl(target, Arrays.AsList(AclTestHelpers.AclEntry(AclEntryScope.Access, AclEntryType
                                                                    .User, FsAction.All), AclTestHelpers.AclEntry(AclEntryScope.Access, AclEntryType
                                                                                                                  .Group, FsAction.None), AclTestHelpers.AclEntry(AclEntryScope.Access, AclEntryType
                                                                                                                                                                  .User, user.GetShortUserName(), FsAction.Write), AclTestHelpers.AclEntry(AclEntryScope
                                                                                                                                                                                                                                           .Access, AclEntryType.Other, FsAction.Write)));
            FileContext myfc = user.DoAs(new _PrivilegedExceptionAction_407());

            // Path to targetChild via symlink
            myfc.Access(link, FsAction.Write);
            try
            {
                myfc.Access(link, FsAction.All);
                NUnit.Framework.Assert.Fail("The access call should have failed.");
            }
            catch (AccessControlException)
            {
            }
            // expected
            Path badPath = new Path(link, "bad");

            try
            {
                myfc.Access(badPath, FsAction.Read);
                NUnit.Framework.Assert.Fail("The access call should have failed");
            }
            catch (FileNotFoundException)
            {
            }
        }