public void TestModifyAclMask()

in AdlsDotNetSDKUnitTest/SdkUnitTest.cs [2184:2227]


        public void TestModifyAclMask()
        {
            string path = $"{UnitTestDir}/ModifyAclEntryMask.txt";
            using (var ostream = _adlsClient.CreateFile(path, IfExists.Overwrite, "700"))
            {
                byte[] buff = Encoding.UTF8.GetBytes("Hello");
                ostream.Write(buff, 0, buff.Length);
            }
            AdlsClient nonOwner1 = SetupNonOwnerClient1();
            try
            {
                using (nonOwner1.GetAppendStream(path))
                { }
                Assert.Fail("Nonowner1 should not have write permission so AppendStream should raise an exception");
            }
            catch (IOException)
            {
            }
            List<AclEntry> aclList = new List<AclEntry>() {
            new AclEntry(AclType.mask, "", AclScope.Access, AclAction.ReadOnly),
            new AclEntry(AclType.user, NonOwner1ObjectId, AclScope.Access, AclAction.ReadWrite)};//Non owner client 1
            _adlsClient.ModifyAclEntries(path, aclList);
            try
            {
                using (nonOwner1.GetAppendStream(path))
                { }
                Assert.Fail("Nonowner1 still should not have effective write permission so AppendStream should raise an exception");
            }
            catch (IOException)
            { }
            try
            {
                using (var istream = nonOwner1.GetReadStream(path))
                {
                    byte[] buffer = new byte[25];
                    istream.Read(buffer, 0, buffer.Length);
                }

            }
            catch (IOException)
            {
                Assert.Fail("Nonowner1 should have read permission so ReadStream should not raise an exception");
            }
        }