diff options
Diffstat (limited to 'OpenSim/Framework/Tests')
-rw-r--r-- | OpenSim/Framework/Tests/ACLTest.cs | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/OpenSim/Framework/Tests/ACLTest.cs b/OpenSim/Framework/Tests/ACLTest.cs index 2428b64..d11f307 100644 --- a/OpenSim/Framework/Tests/ACLTest.cs +++ b/OpenSim/Framework/Tests/ACLTest.cs | |||
@@ -1,5 +1,6 @@ | |||
1 | using System; | 1 | using System; |
2 | using NUnit.Framework; | 2 | using NUnit.Framework; |
3 | using System.Collections.Generic; | ||
3 | 4 | ||
4 | 5 | ||
5 | namespace OpenSim.Framework.Tests | 6 | namespace OpenSim.Framework.Tests |
@@ -32,8 +33,64 @@ namespace OpenSim.Framework.Tests | |||
32 | 33 | ||
33 | acl.GrantPermission("Guests", "CanBuild"); | 34 | acl.GrantPermission("Guests", "CanBuild"); |
34 | 35 | ||
35 | acl.HasPermission("JoeGuest", "CanBuild"); | 36 | Permission perm = acl.HasPermission("JoeGuest", "CanBuild"); |
37 | Assert.That(perm == Permission.Allow, "JoeGuest should have permission to build"); | ||
38 | perm = Permission.None; | ||
39 | try | ||
40 | { | ||
41 | perm = acl.HasPermission("unknownGuest", "CanBuild"); | ||
42 | |||
43 | } | ||
44 | catch (KeyNotFoundException) | ||
45 | { | ||
46 | |||
47 | |||
48 | } | ||
49 | catch (Exception) | ||
50 | { | ||
51 | Assert.That(false,"Exception thrown should have been KeyNotFoundException"); | ||
52 | } | ||
53 | Assert.That(perm == Permission.None,"Permission None should be set because exception should have been thrown"); | ||
54 | |||
55 | } | ||
56 | |||
57 | [Test] | ||
58 | public void KnownButPermissionDenyAndPermissionNoneUserTest() | ||
59 | { | ||
60 | ACL acl = new ACL(); | ||
61 | |||
62 | Role Guests = new Role("Guests"); | ||
63 | acl.AddRole(Guests); | ||
64 | Role Administrators = new Role("Administrators"); | ||
65 | acl.AddRole(Administrators); | ||
66 | Role[] Guestparents = new Role[1]; | ||
67 | Role[] Adminparents = new Role[1]; | ||
68 | |||
69 | Guestparents[0] = Guests; | ||
70 | Adminparents[0] = Administrators; | ||
71 | |||
72 | Role JoeGuest = new Role("JoeGuest", Guestparents); | ||
73 | acl.AddRole(JoeGuest); | ||
74 | |||
75 | Resource CanBuild = new Resource("CanBuild"); | ||
76 | acl.AddResource(CanBuild); | ||
77 | |||
78 | Resource CanScript = new Resource("CanScript"); | ||
79 | acl.AddResource(CanScript); | ||
80 | |||
81 | Resource CanRestart = new Resource("CanRestart"); | ||
82 | acl.AddResource(CanRestart); | ||
83 | |||
84 | acl.GrantPermission("Guests", "CanBuild"); | ||
85 | acl.DenyPermission("Guests", "CanRestart"); | ||
86 | |||
87 | acl.GrantPermission("Administrators", "CanScript"); | ||
36 | 88 | ||
89 | acl.GrantPermission("Administrators", "CanRestart"); | ||
90 | Permission setPermission = acl.HasPermission("JoeGuest", "CanRestart"); | ||
91 | Assert.That(setPermission == Permission.Deny, "Guests Should not be able to restart"); | ||
92 | Assert.That(acl.HasPermission("JoeGuest", "CanScript") == Permission.None, | ||
93 | "No Explicit Permissions set so should be Permission.None"); | ||
37 | } | 94 | } |
38 | 95 | ||
39 | #endregion | 96 | #endregion |