public void AssertPermissions(PermissionMask desired, PermissionMask actual, string message) { if ((desired & PermissionMask.Copy) != 0) { Assert.True((actual & PermissionMask.Copy) != 0, message); } else { Assert.True((actual & PermissionMask.Copy) == 0, message); } if ((desired & PermissionMask.Modify) != 0) { Assert.True((actual & PermissionMask.Modify) != 0, message); } else { Assert.True((actual & PermissionMask.Modify) == 0, message); } if ((desired & PermissionMask.Transfer) != 0) { Assert.True((actual & PermissionMask.Transfer) != 0, message); } else { Assert.True((actual & PermissionMask.Transfer) == 0, message); } }
private void AddA1Object(string name, int suffix, PermissionMask nextOwnerPerms) { // Create a Box. Default permissions are just T SceneObjectGroup box = AddSceneObject(name, suffix, 1, m_Avatars[0].UUID); Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Copy) == 0); Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Modify) == 0); Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Transfer) != 0); // field = 16 is NextOwner // set = 1 means add the permission; set = 0 means remove permission if ((nextOwnerPerms & PermissionMask.Copy) != 0) { m_Scene.HandleObjectPermissionsUpdate(m_Avatars[0].ControllingClient, m_Avatars[0].UUID, m_Avatars[0].ControllingClient.SessionId, 16, box.LocalId, (uint)PermissionMask.Copy, 1); } if ((nextOwnerPerms & PermissionMask.Modify) != 0) { m_Scene.HandleObjectPermissionsUpdate(m_Avatars[0].ControllingClient, m_Avatars[0].UUID, m_Avatars[0].ControllingClient.SessionId, 16, box.LocalId, (uint)PermissionMask.Modify, 1); } if ((nextOwnerPerms & PermissionMask.Transfer) == 0) { m_Scene.HandleObjectPermissionsUpdate(m_Avatars[0].ControllingClient, m_Avatars[0].UUID, m_Avatars[0].ControllingClient.SessionId, 16, box.LocalId, (uint)PermissionMask.Transfer, 0); } PrintPerms(box); AssertPermissions(nextOwnerPerms, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name); TakeCopyToInventory(0, box); }
private void TestOneBox(string name, PermissionMask mask) { InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[0].UUID, "Objects", name); Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[0], Common.TheAvatars[1]); item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name); // Check the receiver Common.TheInstance.PrintPerms(item); Common.TheInstance.AssertPermissions(mask, (PermissionMask)item.BasePermissions, item.Owner.ToString().Substring(34) + " : " + item.Name); int nObjects = Common.TheScene.GetSceneObjectGroups().Count; // Rez it and check perms in scene too Common.TheScene.RezObject(Common.TheAvatars[1].ControllingClient, item.ID, UUID.Zero, Vector3.One, Vector3.Zero, UUID.Zero, 0, false, false, false, UUID.Zero); Assert.That(Common.TheScene.GetSceneObjectGroups().Count, Is.EqualTo(nObjects + 1)); SceneObjectGroup box = Common.TheScene.GetSceneObjectGroups().Find(sog => sog.OwnerID == Common.TheAvatars[1].UUID && sog.Name == name); Common.TheInstance.PrintPerms(box); Assert.That(box, Is.Not.Null); // Check Owner permissions Common.TheInstance.AssertPermissions(mask, (PermissionMask)box.EffectiveOwnerPerms, box.OwnerID.ToString().Substring(34) + " : " + box.Name); // Check Next Owner permissions Common.TheInstance.AssertPermissions(mask, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name); }
private void TakeOneBox(List <SceneObjectGroup> objs, string name, PermissionMask mask) { SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID); Assert.That(box, Is.Not.Null, name); // A2's inventory (index 1) Common.TheInstance.TakeCopyToInventory(1, box); }
public void SimpleTakeCopy() { TestHelpers.InMethod(); // The Objects folder of A2 InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[1].UUID, "Objects"); // C, CT, MC, MCT, MT, T string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T" }; PermissionMask[] perms = new PermissionMask[6] { PermissionMask.Copy, PermissionMask.Copy | PermissionMask.Transfer, PermissionMask.Modify | PermissionMask.Copy, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer, PermissionMask.Modify | PermissionMask.Transfer, PermissionMask.Transfer }; // Try A2 takes copies of objects that cannot be copied. for (int i = 0; i < 6; i++) { TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]); } // Ad-hoc. Enough time to let the take work. Thread.Sleep(5000); List <InventoryItemBase> items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID); Assert.That(items.Count, Is.EqualTo(0)); // A1 makes the objects copyable for (int i = 0; i < 6; i++) { MakeCopyable(Common.TheScene.GetSceneObjectGroups(), names[i]); } // Try A2 takes copies of objects that can be copied. for (int i = 0; i < 6; i++) { TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]); } // Ad-hoc. Enough time to let the take work. Thread.Sleep(5000); items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID); Assert.That(items.Count, Is.EqualTo(6)); for (int i = 0; i < 6; i++) { InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", names[i]); Assert.That(item, Is.Not.Null); Common.TheInstance.AssertPermissions(perms[i], (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item)); } }
public void TestGiveBox() { TestHelpers.InMethod(); // C, CT, MC, MCT, MT, T string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T" }; PermissionMask[] perms = new PermissionMask[6] { PermissionMask.Copy, PermissionMask.Copy | PermissionMask.Transfer, PermissionMask.Modify | PermissionMask.Copy, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer, PermissionMask.Modify | PermissionMask.Transfer, PermissionMask.Transfer }; for (int i = 0; i < 6; i++) { TestOneBox(names[i], perms[i]); } }
public void RevokePermission(int ownerIndex, string name, PermissionMask perm) { InventoryItemBase item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name); Assert.That(item, Is.Not.Null); // Clone it, so to avoid aliasing -- just like the viewer does. InventoryItemBase clone = Common.TheInstance.CloneInventoryItem(item); // Revoke the permission in this copy clone.NextPermissions &= ~(uint)perm; Common.TheInstance.AssertPermissions((PermissionMask)clone.NextPermissions & ~perm, (PermissionMask)clone.NextPermissions, Common.TheInstance.IdStr(clone)); Assert.That(clone.ID == item.ID); // Update properties of the item in inventory. This should affect the original item above. Common.TheScene.UpdateInventoryItemAsset(m_Avatars[ownerIndex].ControllingClient, UUID.Zero, clone.ID, clone); item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name); Assert.That(item, Is.Not.Null); Common.TheInstance.PrintPerms(item); Common.TheInstance.AssertPermissions((PermissionMask)item.NextPermissions & ~perm, (PermissionMask)item.NextPermissions, Common.TheInstance.IdStr(item)); }