mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 17:02:10 -10:00
Also fixed: CommonAcl's merging now filters out AceFlags.InheritedFlags when !IsContainer. For matching AccessMask, CommonAcl will now correctly merge ContainerInherit and ObjectInherit. GenericAcl's SyncRoot is now virtual as per spec. SecurityIdentifier.CompareTo throws ArgumentNullException, not NullReferenceException, on null parameter. Miscellaneous unit tests: Verify that RawAcl throws for negative capacity.
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
//
|
|
// RawAclTest.cs - NUnit Test Cases for RawAclTest
|
|
//
|
|
// Author:
|
|
// Kenneth Bell
|
|
//
|
|
|
|
using System;
|
|
using System.Security.AccessControl;
|
|
using System.Security.Principal;
|
|
using NUnit.Framework;
|
|
|
|
namespace MonoTests.System.Security.AccessControl {
|
|
|
|
[TestFixture]
|
|
public class AclTest {
|
|
|
|
[Test]
|
|
public void GetBinaryForm ()
|
|
{
|
|
RawAcl acl = new RawAcl (1, 0);
|
|
|
|
byte[] buffer = new byte[acl.BinaryLength];
|
|
acl.GetBinaryForm (buffer, 0);
|
|
byte[] sdBinary = new byte[] { 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
Assert.AreEqual (sdBinary, buffer);
|
|
|
|
|
|
SecurityIdentifier builtInAdmins = new SecurityIdentifier (WellKnownSidType.BuiltinAdministratorsSid, null);
|
|
CommonAce ace = new CommonAce (AceFlags.None, AceQualifier.AccessAllowed, 0x7FFFFFFF, builtInAdmins, false, null);
|
|
acl.InsertAce (0, ace);
|
|
buffer = new byte[acl.BinaryLength];
|
|
acl.GetBinaryForm (buffer, 0);
|
|
sdBinary = new byte[] {
|
|
0x01, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x18, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, 0x01, 0x02, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02,
|
|
0x00, 0x00 };
|
|
Assert.AreEqual (sdBinary, buffer);
|
|
}
|
|
|
|
[Test, ExpectedException (typeof (ArgumentOutOfRangeException))]
|
|
public void NonNegativeCapacity ()
|
|
{
|
|
new RawAcl (GenericAcl.AclRevision, -1);
|
|
}
|
|
}
|
|
}
|