Permissions tests: added test with 2 direct transfers with permission changes in between (in inventory)
parent
8e88a9d702
commit
1ca2a7937e
|
@ -93,11 +93,16 @@ namespace OpenSim.Tests.Permissions
|
|||
AddA1Object("Box MT", 14, PermissionMask.Modify | PermissionMask.Transfer);
|
||||
AddA1Object("Box T", 15, PermissionMask.Transfer);
|
||||
|
||||
// MCT-C
|
||||
AddA1Object("Box MCT-C", 16, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer);
|
||||
|
||||
Thread.Sleep(5000);
|
||||
|
||||
InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[0].UUID, "Objects");
|
||||
List<InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(m_Avatars[0].UUID, objsFolder.ID);
|
||||
Assert.That(items.Count, Is.EqualTo(6));
|
||||
Assert.That(items.Count, Is.EqualTo(7));
|
||||
|
||||
RevokePermission(0, "Box MCT-C", PermissionMask.Copy);
|
||||
}
|
||||
|
||||
private ScenePresence AddScenePresence(string first, string last, UUID id)
|
||||
|
@ -139,6 +144,30 @@ namespace OpenSim.Tests.Permissions
|
|||
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
public void PrintPerms(SceneObjectGroup sog)
|
||||
{
|
||||
Console.WriteLine("SOG " + sog.Name + " (" + sog.OwnerID.ToString().Substring(34) + "): " +
|
||||
|
@ -210,6 +239,39 @@ namespace OpenSim.Tests.Permissions
|
|||
return item;
|
||||
}
|
||||
|
||||
public InventoryItemBase CloneInventoryItem(InventoryItemBase item)
|
||||
{
|
||||
InventoryItemBase clone = new InventoryItemBase(item.ID);
|
||||
clone.Name = item.Name;
|
||||
clone.Description = item.Description;
|
||||
clone.AssetID = item.AssetID;
|
||||
clone.AssetType = item.AssetType;
|
||||
clone.BasePermissions = item.BasePermissions;
|
||||
clone.CreatorId = item.CreatorId;
|
||||
clone.CurrentPermissions = item.CurrentPermissions;
|
||||
clone.EveryOnePermissions = item.EveryOnePermissions;
|
||||
clone.Flags = item.Flags;
|
||||
clone.Folder = item.Folder;
|
||||
clone.GroupID = item.GroupID;
|
||||
clone.GroupOwned = item.GroupOwned;
|
||||
clone.GroupPermissions = item.GroupPermissions;
|
||||
clone.InvType = item.InvType;
|
||||
clone.NextPermissions = item.NextPermissions;
|
||||
clone.Owner = item.Owner;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
public string IdStr(InventoryItemBase item)
|
||||
{
|
||||
return item.Owner.ToString().Substring(34) + " : " + item.Name;
|
||||
}
|
||||
|
||||
public string IdStr(SceneObjectGroup sog)
|
||||
{
|
||||
return sog.OwnerID.ToString().Substring(34) + " : " + sog.Name;
|
||||
}
|
||||
|
||||
public void GiveInventoryItem(UUID itemId, ScenePresence giverSp, ScenePresence receiverSp)
|
||||
{
|
||||
TestClient giverClient = (TestClient)giverSp.ControllingClient;
|
||||
|
|
|
@ -57,10 +57,10 @@ namespace OpenSim.Tests.Permissions
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test giving a C object.
|
||||
/// Test giving simple objecta with various combinations of next owner perms.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestGiveCBox()
|
||||
public void TestGiveBox()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
|
@ -108,5 +108,48 @@ namespace OpenSim.Tests.Permissions
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test giving simple objecta with variour combinations of next owner perms.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestDoubleGiveWithChange()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
|
||||
string name = "Box MCT-C";
|
||||
InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[0].UUID, "Objects", name);
|
||||
|
||||
// Now give the item to A2. We give the original item, not a clone.
|
||||
// The giving methods are supposed to duplicate it.
|
||||
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(PermissionMask.Modify | PermissionMask.Transfer,
|
||||
(PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item));
|
||||
|
||||
// ---------------------------
|
||||
// Second transfer
|
||||
//----------------------------
|
||||
|
||||
// A2 revokes M
|
||||
Common.TheInstance.RevokePermission(1, name, PermissionMask.Modify);
|
||||
|
||||
item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name);
|
||||
|
||||
// Now give the item to A3. We give the original item, not a clone.
|
||||
// The giving methods are supposed to duplicate it.
|
||||
Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[1], Common.TheAvatars[2]);
|
||||
|
||||
item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[2].UUID, "Objects", name);
|
||||
|
||||
// Check the receiver
|
||||
Common.TheInstance.PrintPerms(item);
|
||||
Common.TheInstance.AssertPermissions(PermissionMask.Transfer,
|
||||
(PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue