示例#1
0
        public void TestModifyAndRemoveAclRecursively()
        {
            var acls  = FilePropertiesUnitTest.GetAclEntryForModifyAndRemove();
            var stats = _adlsClient.ChangeAcl(rootPath, acls, RequestedAclType.ModifyAcl, 1, null, default(CancellationToken));

            Assert.IsTrue(stats.DirectoryProcessed == 3);
            Assert.IsTrue(stats.FilesProcessed == 1);
            Assert.IsTrue(VerifyChangeAclJob.CheckAclListContains(_adlsClient.GetAclStatus(rootPath).Entries, acls));
            Assert.IsTrue(VerifyChangeAclJob.CheckAclListContains(_adlsClient.GetAclStatus(rootPath + "/b0/c0").Entries, acls));
            Assert.IsTrue(VerifyChangeAclJob.CheckAclListContains(_adlsClient.GetAclStatus(rootPath + "/bFile01").Entries, acls));
            stats = _adlsClient.ChangeAcl(rootPath, acls, RequestedAclType.RemoveAcl, 1, null, default(CancellationToken));
            Assert.IsTrue(stats.DirectoryProcessed == 3);
            Assert.IsTrue(stats.FilesProcessed == 1);
            Assert.IsTrue(VerifyChangeAclJob.CheckAclListContains(_adlsClient.GetAclStatus(rootPath).Entries, acls, true));
            Assert.IsTrue(VerifyChangeAclJob.CheckAclListContains(_adlsClient.GetAclStatus(rootPath + "/b0/c0").Entries, acls, true));
            Assert.IsTrue(VerifyChangeAclJob.CheckAclListContains(_adlsClient.GetAclStatus(rootPath + "/bFile01").Entries, acls, true));
        }
        private static void SetAclAndGetFileProperties(AdlsClient client)
        {
            var aclEntry = new List <AclEntry>()
            {
                new AclEntry(AclType.user, aclUserId, AclScope.Access, AclAction.ReadExecute)
            };

            Console.WriteLine("Adding Acl recursively to /");
            client.ChangeAcl("/", aclEntry, RequestedAclType.ModifyAcl);
            Console.WriteLine($"Dumping Acl and disk usage information recursively to {localFilePropertyDumpPath}\\dump1.txt");
            // Dump the Acl and disk usage to a local file. If you want to dump it to ADL then pass false for 5th parameter and pass a adl path in 2nd parameter.
            // Verify the Acl properties are set contain the AclUserId
            client.GetFileProperties("/", true, $"{localFilePropertyDumpPath}\\dump1.txt", true, true);
            Console.WriteLine("Removing Acl recursively from /");
            client.ChangeAcl("/", aclEntry, RequestedAclType.RemoveAcl);
            Console.WriteLine($"Dumping Acl and disk usage information recursively to {localFilePropertyDumpPath}\\dump2.txt");
            // Now the Acl will not contain the AclUserId
            client.GetFileProperties("/", true, $"{localFilePropertyDumpPath}\\dump2.txt", true, true);
            Directory.Delete(localFilePropertyDumpPath, true);
        }