Files
mono/mcs/class/corlib/Test/System.Security.AccessControl/RawAclTest.cs
T
James Bellinger 2d415e7a8f Implemented all of DiscretionaryAcl except for RemoveAccess. Unit tests are included.
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.
2012-07-03 13:56:55 -04:00

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);
}
}
}