CommonAceTest.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // CommonAceTest.cs - NUnit Test Cases for CommonAce
  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 CommonAceTest {
  13. [Test]
  14. public void GetBinaryForm ()
  15. {
  16. SecurityIdentifier builtInAdmins = new SecurityIdentifier (WellKnownSidType.BuiltinAdministratorsSid, null);
  17. CommonAce ace = new CommonAce (AceFlags.None, AceQualifier.AccessAllowed, 0x7FFFFFFF, builtInAdmins, false, null);
  18. byte[] buffer = new byte[ace.BinaryLength];
  19. ace.GetBinaryForm (buffer, 0);
  20. byte[] aceBinary = new byte[] {
  21. 0x00, 0x00, 0x18, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, 0x01, 0x02,
  22. 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00,
  23. 0x20, 0x02, 0x00, 0x00 };
  24. Assert.AreEqual (aceBinary, buffer);
  25. }
  26. [Test]
  27. public void MaxOpaqueLength ()
  28. {
  29. Assert.AreEqual (65459, CommonAce.MaxOpaqueLength (true));
  30. Assert.AreEqual (65459, CommonAce.MaxOpaqueLength (false));
  31. Assert.AreEqual (65423, ObjectAce.MaxOpaqueLength (true));
  32. Assert.AreEqual (65423, ObjectAce.MaxOpaqueLength (false));
  33. }
  34. }
  35. }