diff options
Diffstat (limited to 'OpenSim/Tests/Permissions/Common.cs')
-rw-r--r-- | OpenSim/Tests/Permissions/Common.cs | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/OpenSim/Tests/Permissions/Common.cs b/OpenSim/Tests/Permissions/Common.cs index 63b91b6..84dadf2 100644 --- a/OpenSim/Tests/Permissions/Common.cs +++ b/OpenSim/Tests/Permissions/Common.cs | |||
@@ -93,11 +93,16 @@ namespace OpenSim.Tests.Permissions | |||
93 | AddA1Object("Box MT", 14, PermissionMask.Modify | PermissionMask.Transfer); | 93 | AddA1Object("Box MT", 14, PermissionMask.Modify | PermissionMask.Transfer); |
94 | AddA1Object("Box T", 15, PermissionMask.Transfer); | 94 | AddA1Object("Box T", 15, PermissionMask.Transfer); |
95 | 95 | ||
96 | // MCT-C | ||
97 | AddA1Object("Box MCT-C", 16, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer); | ||
98 | |||
96 | Thread.Sleep(5000); | 99 | Thread.Sleep(5000); |
97 | 100 | ||
98 | InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[0].UUID, "Objects"); | 101 | InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[0].UUID, "Objects"); |
99 | List<InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(m_Avatars[0].UUID, objsFolder.ID); | 102 | List<InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(m_Avatars[0].UUID, objsFolder.ID); |
100 | Assert.That(items.Count, Is.EqualTo(6)); | 103 | Assert.That(items.Count, Is.EqualTo(7)); |
104 | |||
105 | RevokePermission(0, "Box MCT-C", PermissionMask.Copy); | ||
101 | } | 106 | } |
102 | 107 | ||
103 | private ScenePresence AddScenePresence(string first, string last, UUID id) | 108 | private ScenePresence AddScenePresence(string first, string last, UUID id) |
@@ -139,6 +144,30 @@ namespace OpenSim.Tests.Permissions | |||
139 | 144 | ||
140 | } | 145 | } |
141 | 146 | ||
147 | public void RevokePermission(int ownerIndex, string name, PermissionMask perm) | ||
148 | { | ||
149 | InventoryItemBase item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name); | ||
150 | Assert.That(item, Is.Not.Null); | ||
151 | |||
152 | // Clone it, so to avoid aliasing -- just like the viewer does. | ||
153 | InventoryItemBase clone = Common.TheInstance.CloneInventoryItem(item); | ||
154 | // Revoke the permission in this copy | ||
155 | clone.NextPermissions &= ~(uint)perm; | ||
156 | Common.TheInstance.AssertPermissions((PermissionMask)clone.NextPermissions & ~perm, | ||
157 | (PermissionMask)clone.NextPermissions, Common.TheInstance.IdStr(clone)); | ||
158 | Assert.That(clone.ID == item.ID); | ||
159 | |||
160 | // Update properties of the item in inventory. This should affect the original item above. | ||
161 | Common.TheScene.UpdateInventoryItemAsset(m_Avatars[ownerIndex].ControllingClient, UUID.Zero, clone.ID, clone); | ||
162 | |||
163 | item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name); | ||
164 | Assert.That(item, Is.Not.Null); | ||
165 | Common.TheInstance.PrintPerms(item); | ||
166 | Common.TheInstance.AssertPermissions((PermissionMask)item.NextPermissions & ~perm, | ||
167 | (PermissionMask)item.NextPermissions, Common.TheInstance.IdStr(item)); | ||
168 | |||
169 | } | ||
170 | |||
142 | public void PrintPerms(SceneObjectGroup sog) | 171 | public void PrintPerms(SceneObjectGroup sog) |
143 | { | 172 | { |
144 | Console.WriteLine("SOG " + sog.Name + " (" + sog.OwnerID.ToString().Substring(34) + "): " + | 173 | Console.WriteLine("SOG " + sog.Name + " (" + sog.OwnerID.ToString().Substring(34) + "): " + |
@@ -210,6 +239,39 @@ namespace OpenSim.Tests.Permissions | |||
210 | return item; | 239 | return item; |
211 | } | 240 | } |
212 | 241 | ||
242 | public InventoryItemBase CloneInventoryItem(InventoryItemBase item) | ||
243 | { | ||
244 | InventoryItemBase clone = new InventoryItemBase(item.ID); | ||
245 | clone.Name = item.Name; | ||
246 | clone.Description = item.Description; | ||
247 | clone.AssetID = item.AssetID; | ||
248 | clone.AssetType = item.AssetType; | ||
249 | clone.BasePermissions = item.BasePermissions; | ||
250 | clone.CreatorId = item.CreatorId; | ||
251 | clone.CurrentPermissions = item.CurrentPermissions; | ||
252 | clone.EveryOnePermissions = item.EveryOnePermissions; | ||
253 | clone.Flags = item.Flags; | ||
254 | clone.Folder = item.Folder; | ||
255 | clone.GroupID = item.GroupID; | ||
256 | clone.GroupOwned = item.GroupOwned; | ||
257 | clone.GroupPermissions = item.GroupPermissions; | ||
258 | clone.InvType = item.InvType; | ||
259 | clone.NextPermissions = item.NextPermissions; | ||
260 | clone.Owner = item.Owner; | ||
261 | |||
262 | return clone; | ||
263 | } | ||
264 | |||
265 | public string IdStr(InventoryItemBase item) | ||
266 | { | ||
267 | return item.Owner.ToString().Substring(34) + " : " + item.Name; | ||
268 | } | ||
269 | |||
270 | public string IdStr(SceneObjectGroup sog) | ||
271 | { | ||
272 | return sog.OwnerID.ToString().Substring(34) + " : " + sog.Name; | ||
273 | } | ||
274 | |||
213 | public void GiveInventoryItem(UUID itemId, ScenePresence giverSp, ScenePresence receiverSp) | 275 | public void GiveInventoryItem(UUID itemId, ScenePresence giverSp, ScenePresence receiverSp) |
214 | { | 276 | { |
215 | TestClient giverClient = (TestClient)giverSp.ControllingClient; | 277 | TestClient giverClient = (TestClient)giverSp.ControllingClient; |