RawAclTest.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // RawAclTest.cs - NUnit Test Cases for RawAclTest
  3. //
  4. // Author:
  5. // Kenneth Bell
  6. //
  7. using System.Security.AccessControl;
  8. using System.Security.Principal;
  9. using NUnit.Framework;
  10. namespace MonoTests.System.Security.AccessControl {
  11. [TestFixture]
  12. public class AclTest {
  13. [Test]
  14. public void GetBinaryForm ()
  15. {
  16. RawAcl acl = new RawAcl (1, 0);
  17. byte[] buffer = new byte[acl.BinaryLength];
  18. acl.GetBinaryForm (buffer, 0);
  19. byte[] sdBinary = new byte[] { 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00 };
  20. Assert.AreEqual (sdBinary, buffer);
  21. SecurityIdentifier builtInAdmins = new SecurityIdentifier (WellKnownSidType.BuiltinAdministratorsSid, null);
  22. CommonAce ace = new CommonAce (AceFlags.None, AceQualifier.AccessAllowed, 0x7FFFFFFF, builtInAdmins, false, null);
  23. acl.InsertAce (0, ace);
  24. buffer = new byte[acl.BinaryLength];
  25. acl.GetBinaryForm (buffer, 0);
  26. sdBinary = new byte[] {
  27. 0x01, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  28. 0x18, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, 0x01, 0x02, 0x00, 0x00,
  29. 0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02,
  30. 0x00, 0x00 };
  31. Assert.AreEqual (sdBinary, buffer);
  32. }
  33. }
  34. }