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