From 3ff7391495271fed152aadc7a588ae976e09bafc Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 29 Apr 2013 00:55:34 +0100
Subject: Some more pieces of Avination's ban system - if an avatar isn't
allowed on any parcel in the sim, keep them out entirely.
---
OpenSim/Region/Framework/Scenes/Scene.cs | 95 +++++++++++++++++++++++++++++---
1 file changed, 88 insertions(+), 7 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 69fe137..829a7e9 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3693,7 +3693,7 @@ namespace OpenSim.Region.Framework.Scenes
//On login test land permisions
if (vialogin)
{
- if (land != null && !TestLandRestrictions(agent, land, out reason))
+ if (land != null && !TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
{
return false;
}
@@ -3868,20 +3868,37 @@ namespace OpenSim.Region.Framework.Scenes
return true;
}
- private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason)
+ public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
{
- bool banned = land.IsBannedFromLand(agent.AgentID);
- bool restricted = land.IsRestrictedFromLand(agent.AgentID);
+ if (posX < 0)
+ posX = 0;
+ else if (posX >= 256)
+ posX = 255.999f;
+ if (posY < 0)
+ posY = 0;
+ else if (posY >= 256)
+ posY = 255.999f;
+
+ reason = String.Empty;
+ if (Permissions.IsGod(agentID))
+ return true;
+
+ ILandObject land = LandChannel.GetLandObject(posX, posY);
+ if (land == null)
+ return false;
+
+ bool banned = land.IsBannedFromLand(agentID);
+ bool restricted = land.IsRestrictedFromLand(agentID);
if (banned || restricted)
{
- ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y);
+ ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
if (nearestParcel != null)
{
//Move agent to nearest allowed
Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
- agent.startpos.X = newPosition.X;
- agent.startpos.Y = newPosition.Y;
+ posX = newPosition.X;
+ posY = newPosition.Y;
}
else
{
@@ -5466,6 +5483,8 @@ namespace OpenSim.Region.Framework.Scenes
///
public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
{
+ reason = "You are banned from the region";
+
if (EntityTransferModule.IsInTransit(agentID))
{
reason = "Agent is still in transit from this region";
@@ -5477,6 +5496,12 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
+ if (Permissions.IsGod(agentID))
+ {
+ reason = String.Empty;
+ return true;
+ }
+
// FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
// However, the long term fix is to make sure root agent count is always accurate.
m_sceneGraph.RecalculateStats();
@@ -5497,6 +5522,41 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ ScenePresence presence = GetScenePresence(agentID);
+ IClientAPI client = null;
+ AgentCircuitData aCircuit = null;
+
+ if (presence != null)
+ {
+ client = presence.ControllingClient;
+ if (client != null)
+ aCircuit = client.RequestClientInfo();
+ }
+
+ // We may be called before there is a presence or a client.
+ // Fake AgentCircuitData to keep IAuthorizationModule smiling
+ if (client == null)
+ {
+ aCircuit = new AgentCircuitData();
+ aCircuit.AgentID = agentID;
+ aCircuit.firstname = String.Empty;
+ aCircuit.lastname = String.Empty;
+ }
+
+ try
+ {
+ if (!AuthorizeUser(aCircuit, out reason))
+ {
+ // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
+ return false;
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
+ return false;
+ }
+
if (position == Vector3.Zero) // Teleport
{
if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@@ -5530,6 +5590,27 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
+
+ float posX = 128.0f;
+ float posY = 128.0f;
+
+ if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
+ {
+ // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
+ return false;
+ }
+ }
+ else // Walking
+ {
+ ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
+ if (land == null)
+ return false;
+
+ bool banned = land.IsBannedFromLand(agentID);
+ bool restricted = land.IsRestrictedFromLand(agentID);
+
+ if (banned || restricted)
+ return false;
}
reason = String.Empty;
--
cgit v1.1
From 12054aaa9ff66cc785d2018526ff6f3e94f86915 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 29 Apr 2013 17:14:44 +0100
Subject: Fix bug where an agent that declined an inventory offer and
subsequently emptied their trash would make the item invalid in the giver's
inventory
This was because the original item/folder ID was sent in the session slot of the offer IM rather than the copy.
---
.../Avatar/Inventory/Transfer/InventoryTransferModule.cs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index bcb7f42..e1ada97 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -213,7 +213,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
user.ControllingClient.SendBulkUpdateInventory(folderCopy);
// HACK!!
- im.imSessionID = folderID.Guid;
+ // Insert the ID of the copied item into the IM so that we know which item to move to trash if it
+ // is rejected.
+ // XXX: This is probably a misuse of the session ID slot.
+ im.imSessionID = copyID.Guid;
}
else
{
@@ -243,7 +246,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
user.ControllingClient.SendBulkUpdateInventory(itemCopy);
// HACK!!
- im.imSessionID = itemID.Guid;
+ // Insert the ID of the copied item into the IM so that we know which item to move to trash if it
+ // is rejected.
+ // XXX: This is probably a misuse of the session ID slot.
+ im.imSessionID = copyID.Guid;
}
// Send the IM to the recipient. The item is already
--
cgit v1.1
From a7cbb9edc98fabc6d2705d69310f4356e84c7596 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 29 Apr 2013 20:50:49 +0100
Subject: Add regression test for offer, accept and subsequent receiver delete
of an item offered via instant message.
---
.../Inventory/Transfer/InventoryTransferModule.cs | 83 +---------------------
OpenSim/Tests/Common/Mock/TestClient.cs | 12 ++++
2 files changed, 15 insertions(+), 80 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index e1ada97..c292700 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -47,10 +47,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
///
private List m_Scenelist = new List();
-// private Dictionary m_AgentRegions =
-// new Dictionary();
- private IMessageTransferModule m_TransferModule = null;
+ private IMessageTransferModule m_TransferModule;
private bool m_Enabled = true;
#region Region Module interface
@@ -81,9 +79,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
// scene.RegisterModuleInterface(this);
scene.EventManager.OnNewClient += OnNewClient;
-// scene.EventManager.OnClientClosed += ClientLoggedOut;
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
-// scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene;
}
public void RegionLoaded(Scene scene)
@@ -96,11 +92,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
m_log.Error("[INVENTORY TRANSFER]: No Message transfer module found, transfers will be local only");
m_Enabled = false;
- m_Scenelist.Clear();
- scene.EventManager.OnNewClient -= OnNewClient;
-// scene.EventManager.OnClientClosed -= ClientLoggedOut;
+// m_Scenelist.Clear();
+// scene.EventManager.OnNewClient -= OnNewClient;
scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
-// scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene;
}
}
}
@@ -108,9 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
public void RemoveRegion(Scene scene)
{
scene.EventManager.OnNewClient -= OnNewClient;
-// scene.EventManager.OnClientClosed -= ClientLoggedOut;
scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
-// scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene;
m_Scenelist.Remove(scene);
}
@@ -139,11 +131,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
// Inventory giving is conducted via instant message
client.OnInstantMessage += OnInstantMessage;
}
-
-// protected void OnSetRootAgentScene(UUID id, Scene scene)
-// {
-// m_AgentRegions[id] = scene;
-// }
private Scene FindClientScene(UUID agentId)
{
@@ -460,70 +447,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
}
}
-// public bool NeedSceneCacheClear(UUID agentID, Scene scene)
-// {
-// if (!m_AgentRegions.ContainsKey(agentID))
-// {
-// // Since we can get here two ways, we need to scan
-// // the scenes here. This is somewhat more expensive
-// // but helps avoid a nasty bug
-// //
-//
-// foreach (Scene s in m_Scenelist)
-// {
-// ScenePresence presence;
-//
-// if (s.TryGetScenePresence(agentID, out presence))
-// {
-// // If the agent is in this scene, then we
-// // are being called twice in a single
-// // teleport. This is wasteful of cycles
-// // but harmless due to this 2nd level check
-// //
-// // If the agent is found in another scene
-// // then the list wasn't current
-// //
-// // If the agent is totally unknown, then what
-// // are we even doing here??
-// //
-// if (s == scene)
-// {
-// //m_log.Debug("[INVTRANSFERMOD]: s == scene. Returning true in " + scene.RegionInfo.RegionName);
-// return true;
-// }
-// else
-// {
-// //m_log.Debug("[INVTRANSFERMOD]: s != scene. Returning false in " + scene.RegionInfo.RegionName);
-// return false;
-// }
-// }
-// }
-// //m_log.Debug("[INVTRANSFERMOD]: agent not in scene. Returning true in " + scene.RegionInfo.RegionName);
-// return true;
-// }
-//
-// // The agent is left in current Scene, so we must be
-// // going to another instance
-// //
-// if (m_AgentRegions[agentID] == scene)
-// {
-// //m_log.Debug("[INVTRANSFERMOD]: m_AgentRegions[agentID] == scene. Returning true in " + scene.RegionInfo.RegionName);
-// m_AgentRegions.Remove(agentID);
-// return true;
-// }
-//
-// // Another region has claimed the agent
-// //
-// //m_log.Debug("[INVTRANSFERMOD]: last resort. Returning false in " + scene.RegionInfo.RegionName);
-// return false;
-// }
-//
-// public void ClientLoggedOut(UUID agentID, Scene scene)
-// {
-// if (m_AgentRegions.ContainsKey(agentID))
-// m_AgentRegions.Remove(agentID);
-// }
-
///
///
///
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index d26e3f7..b7a7463 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -484,6 +484,18 @@ namespace OpenSim.Tests.Common.Mock
OnCompleteMovementToRegion(this, true);
}
+ ///
+ /// Emulate sending an IM from the viewer to the simulator.
+ ///
+ ///
+ public void HandleImprovedInstantMessage(GridInstantMessage im)
+ {
+ ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
+
+ if (handlerInstantMessage != null)
+ handlerInstantMessage(this, im);
+ }
+
public virtual void ActivateGesture(UUID assetId, UUID gestureId)
{
}
--
cgit v1.1
From 0beccf23c0c2e7b2420f4f150d5f2566f0d63370 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 29 Apr 2013 21:11:44 +0100
Subject: Add regression test for inventory item give, reject and subsequent
trash folder purge by receiver.
This commit also actually adds the InventoryTransferModuleTests file which I previously forgot
---
.../Transfer/Tests/InventoryTransferModuleTests.cs | 256 +++++++++++++++++++++
OpenSim/Tests/Common/Mock/TestClient.cs | 4 +-
2 files changed, 259 insertions(+), 1 deletion(-)
create mode 100644 OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/Tests/InventoryTransferModuleTests.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/Tests/InventoryTransferModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/Tests/InventoryTransferModuleTests.cs
new file mode 100644
index 0000000..b07d38c
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/Tests/InventoryTransferModuleTests.cs
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using log4net.Config;
+using Nini.Config;
+using NUnit.Framework;
+using OpenMetaverse;
+using OpenMetaverse.Assets;
+using OpenSim.Framework;
+using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Services.Interfaces;
+using OpenSim.Tests.Common;
+using OpenSim.Tests.Common.Mock;
+
+namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.Tests
+{
+ [TestFixture]
+ public class InventoryTransferModuleTests : OpenSimTestCase
+ {
+ protected TestScene m_scene;
+
+ [SetUp]
+ public override void SetUp()
+ {
+ base.SetUp();
+
+ IConfigSource config = new IniConfigSource();
+ config.AddConfig("Messaging");
+ config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule");
+
+ m_scene = new SceneHelpers().SetupScene();
+ SceneHelpers.SetupSceneModules(m_scene, config, new InventoryTransferModule());
+ }
+
+ [Test]
+ public void TestAcceptGivenItem()
+ {
+// TestHelpers.EnableLogging();
+
+ UUID initialSessionId = TestHelpers.ParseTail(0x10);
+ UUID itemId = TestHelpers.ParseTail(0x100);
+ UUID assetId = TestHelpers.ParseTail(0x200);
+
+ UserAccount ua1
+ = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
+ UserAccount ua2
+ = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");
+
+ ScenePresence giverSp = SceneHelpers.AddScenePresence(m_scene, ua1);
+ TestClient giverClient = (TestClient)giverSp.ControllingClient;
+
+ ScenePresence receiverSp = SceneHelpers.AddScenePresence(m_scene, ua2);
+ TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
+
+ // Create the object to test give
+ InventoryItemBase originalItem
+ = UserInventoryHelpers.CreateInventoryItem(
+ m_scene, "givenObj", itemId, assetId, giverSp.UUID, InventoryType.Object);
+
+ byte[] giveImBinaryBucket = new byte[17];
+ byte[] itemIdBytes = itemId.GetBytes();
+ Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
+
+ GridInstantMessage giveIm
+ = new GridInstantMessage(
+ m_scene,
+ giverSp.UUID,
+ giverSp.Name,
+ receiverSp.UUID,
+ (byte)InstantMessageDialog.InventoryOffered,
+ false,
+ "inventory offered msg",
+ initialSessionId,
+ false,
+ Vector3.Zero,
+ giveImBinaryBucket,
+ true);
+
+ giverClient.HandleImprovedInstantMessage(giveIm);
+
+ // These details might not all be correct.
+ GridInstantMessage acceptIm
+ = new GridInstantMessage(
+ m_scene,
+ receiverSp.UUID,
+ receiverSp.Name,
+ giverSp.UUID,
+ (byte)InstantMessageDialog.InventoryAccepted,
+ false,
+ "inventory accepted msg",
+ initialSessionId,
+ false,
+ Vector3.Zero,
+ null,
+ true);
+
+ receiverClient.HandleImprovedInstantMessage(acceptIm);
+
+ // Test for item remaining in the giver's inventory (here we assume a copy item)
+ // TODO: Test no-copy items.
+ InventoryItemBase originalItemAfterGive
+ = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");
+
+ Assert.That(originalItemAfterGive, Is.Not.Null);
+ Assert.That(originalItemAfterGive.ID, Is.EqualTo(originalItem.ID));
+
+ // Test for item successfully making it into the receiver's inventory
+ InventoryItemBase receivedItem
+ = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, receiverSp.UUID, "Objects/givenObj");
+
+ Assert.That(receivedItem, Is.Not.Null);
+ Assert.That(receivedItem.ID, Is.Not.EqualTo(originalItem.ID));
+
+ // Test that on a delete, item still exists and is accessible for the giver.
+ m_scene.InventoryService.DeleteItems(receiverSp.UUID, new List() { receivedItem.ID });
+
+ InventoryItemBase originalItemAfterDelete
+ = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");
+
+ Assert.That(originalItemAfterDelete, Is.Not.Null);
+
+ // TODO: Test scenario where giver deletes their item first.
+ }
+
+ ///
+ /// Test user rejection of a given item.
+ ///
+ ///
+ /// A rejected item still ends up in the user's trash folder.
+ ///
+ [Test]
+ public void TestRejectGivenItem()
+ {
+// TestHelpers.EnableLogging();
+
+ UUID initialSessionId = TestHelpers.ParseTail(0x10);
+ UUID itemId = TestHelpers.ParseTail(0x100);
+ UUID assetId = TestHelpers.ParseTail(0x200);
+
+ UserAccount ua1
+ = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
+ UserAccount ua2
+ = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");
+
+ ScenePresence giverSp = SceneHelpers.AddScenePresence(m_scene, ua1);
+ TestClient giverClient = (TestClient)giverSp.ControllingClient;
+
+ ScenePresence receiverSp = SceneHelpers.AddScenePresence(m_scene, ua2);
+ TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
+
+ // Create the object to test give
+ InventoryItemBase originalItem
+ = UserInventoryHelpers.CreateInventoryItem(
+ m_scene, "givenObj", itemId, assetId, giverSp.UUID, InventoryType.Object);
+
+ GridInstantMessage receivedIm = null;
+ receiverClient.OnReceivedInstantMessage += im => receivedIm = im;
+
+ byte[] giveImBinaryBucket = new byte[17];
+ byte[] itemIdBytes = itemId.GetBytes();
+ Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
+
+ GridInstantMessage giveIm
+ = new GridInstantMessage(
+ m_scene,
+ giverSp.UUID,
+ giverSp.Name,
+ receiverSp.UUID,
+ (byte)InstantMessageDialog.InventoryOffered,
+ false,
+ "inventory offered msg",
+ initialSessionId,
+ false,
+ Vector3.Zero,
+ giveImBinaryBucket,
+ true);
+
+ giverClient.HandleImprovedInstantMessage(giveIm);
+
+ // These details might not all be correct.
+ // Session ID is now the created item ID (!)
+ GridInstantMessage rejectIm
+ = new GridInstantMessage(
+ m_scene,
+ receiverSp.UUID,
+ receiverSp.Name,
+ giverSp.UUID,
+ (byte)InstantMessageDialog.InventoryDeclined,
+ false,
+ "inventory declined msg",
+ new UUID(receivedIm.imSessionID),
+ false,
+ Vector3.Zero,
+ null,
+ true);
+
+ receiverClient.HandleImprovedInstantMessage(rejectIm);
+
+ // Test for item remaining in the giver's inventory (here we assume a copy item)
+ // TODO: Test no-copy items.
+ InventoryItemBase originalItemAfterGive
+ = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");
+
+ Assert.That(originalItemAfterGive, Is.Not.Null);
+ Assert.That(originalItemAfterGive.ID, Is.EqualTo(originalItem.ID));
+
+ // Test for item successfully making it into the receiver's inventory
+ InventoryItemBase receivedItem
+ = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, receiverSp.UUID, "Trash/givenObj");
+
+ InventoryFolderBase trashFolder
+ = m_scene.InventoryService.GetFolderForType(receiverSp.UUID, AssetType.TrashFolder);
+
+ Assert.That(receivedItem, Is.Not.Null);
+ Assert.That(receivedItem.ID, Is.Not.EqualTo(originalItem.ID));
+ Assert.That(receivedItem.Folder, Is.EqualTo(trashFolder.ID));
+
+ // Test that on a delete, item still exists and is accessible for the giver.
+ m_scene.InventoryService.PurgeFolder(trashFolder);
+
+ InventoryItemBase originalItemAfterDelete
+ = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");
+
+ Assert.That(originalItemAfterDelete, Is.Not.Null);
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index b7a7463..41402a4 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -61,6 +61,7 @@ namespace OpenSim.Tests.Common.Mock
// Test client specific events - for use by tests to implement some IClientAPI behaviour.
public event Action OnReceivedMoveAgentIntoRegion;
public event Action OnTestClientInformClientOfNeighbour;
+ public event Action OnReceivedInstantMessage;
// disable warning: public events, part of the public API
#pragma warning disable 67
@@ -550,7 +551,8 @@ namespace OpenSim.Tests.Common.Mock
public void SendInstantMessage(GridInstantMessage im)
{
-
+ if (OnReceivedInstantMessage != null)
+ OnReceivedInstantMessage(im);
}
public void SendGenericMessage(string method, UUID invoice, List message)
--
cgit v1.1
From 67789201c3ae40bd4697f3479eb183599baa3658 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 29 Apr 2013 22:14:13 +0100
Subject: Add TestRejectGivenFolder() and TestAcceptGivenFolder() regression
tests
---
.../Inventory/Transfer/InventoryTransferModule.cs | 10 +-
.../Transfer/Tests/InventoryTransferModuleTests.cs | 193 +++++++++++++++++++++
.../Tests/Common/Helpers/UserInventoryHelpers.cs | 41 ++++-
.../Tests/Common/Mock/TestXInventoryDataPlugin.cs | 28 ++-
4 files changed, 262 insertions(+), 10 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index c292700..1417a19 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -175,9 +175,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
UUID folderID = new UUID(im.binaryBucket, 1);
- m_log.DebugFormat("[INVENTORY TRANSFER]: Inserting original folder {0} "+
- "into agent {1}'s inventory",
- folderID, new UUID(im.toAgentID));
+ m_log.DebugFormat(
+ "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory",
+ folderID, new UUID(im.toAgentID));
InventoryFolderBase folderCopy
= scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero);
@@ -200,7 +200,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
user.ControllingClient.SendBulkUpdateInventory(folderCopy);
// HACK!!
- // Insert the ID of the copied item into the IM so that we know which item to move to trash if it
+ // Insert the ID of the copied folder into the IM so that we know which item to move to trash if it
// is rejected.
// XXX: This is probably a misuse of the session ID slot.
im.imSessionID = copyID.Guid;
@@ -396,7 +396,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
folder = new InventoryFolderBase(inventoryID, client.AgentId);
folder = invService.GetFolder(folder);
-
+
if (folder != null & trashFolder != null)
{
previousParentFolderID = folder.ParentID;
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/Tests/InventoryTransferModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/Tests/InventoryTransferModuleTests.cs
index b07d38c..162a0c3 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/Tests/InventoryTransferModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/Tests/InventoryTransferModuleTests.cs
@@ -252,5 +252,198 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.Tests
Assert.That(originalItemAfterDelete, Is.Not.Null);
}
+
+ [Test]
+ public void TestAcceptGivenFolder()
+ {
+ TestHelpers.InMethod();
+// TestHelpers.EnableLogging();
+
+ UUID initialSessionId = TestHelpers.ParseTail(0x10);
+ UUID folderId = TestHelpers.ParseTail(0x100);
+
+ UserAccount ua1
+ = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
+ UserAccount ua2
+ = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");
+
+ ScenePresence giverSp = SceneHelpers.AddScenePresence(m_scene, ua1);
+ TestClient giverClient = (TestClient)giverSp.ControllingClient;
+
+ ScenePresence receiverSp = SceneHelpers.AddScenePresence(m_scene, ua2);
+ TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
+
+ InventoryFolderBase originalFolder
+ = UserInventoryHelpers.CreateInventoryFolder(
+ m_scene.InventoryService, giverSp.UUID, folderId, "f1", true);
+
+ byte[] giveImBinaryBucket = new byte[17];
+ giveImBinaryBucket[0] = (byte)AssetType.Folder;
+ byte[] itemIdBytes = folderId.GetBytes();
+ Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
+
+ GridInstantMessage giveIm
+ = new GridInstantMessage(
+ m_scene,
+ giverSp.UUID,
+ giverSp.Name,
+ receiverSp.UUID,
+ (byte)InstantMessageDialog.InventoryOffered,
+ false,
+ "inventory offered msg",
+ initialSessionId,
+ false,
+ Vector3.Zero,
+ giveImBinaryBucket,
+ true);
+
+ giverClient.HandleImprovedInstantMessage(giveIm);
+
+ // These details might not all be correct.
+ GridInstantMessage acceptIm
+ = new GridInstantMessage(
+ m_scene,
+ receiverSp.UUID,
+ receiverSp.Name,
+ giverSp.UUID,
+ (byte)InstantMessageDialog.InventoryAccepted,
+ false,
+ "inventory accepted msg",
+ initialSessionId,
+ false,
+ Vector3.Zero,
+ null,
+ true);
+
+ receiverClient.HandleImprovedInstantMessage(acceptIm);
+
+ // Test for item remaining in the giver's inventory (here we assume a copy item)
+ // TODO: Test no-copy items.
+ InventoryFolderBase originalFolderAfterGive
+ = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");
+
+ Assert.That(originalFolderAfterGive, Is.Not.Null);
+ Assert.That(originalFolderAfterGive.ID, Is.EqualTo(originalFolder.ID));
+
+ // Test for item successfully making it into the receiver's inventory
+ InventoryFolderBase receivedFolder
+ = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, receiverSp.UUID, "f1");
+
+ Assert.That(receivedFolder, Is.Not.Null);
+ Assert.That(receivedFolder.ID, Is.Not.EqualTo(originalFolder.ID));
+
+ // Test that on a delete, item still exists and is accessible for the giver.
+ m_scene.InventoryService.DeleteFolders(receiverSp.UUID, new List() { receivedFolder.ID });
+
+ InventoryFolderBase originalFolderAfterDelete
+ = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");
+
+ Assert.That(originalFolderAfterDelete, Is.Not.Null);
+
+ // TODO: Test scenario where giver deletes their item first.
+ }
+
+ ///
+ /// Test user rejection of a given item.
+ ///
+ ///
+ /// A rejected item still ends up in the user's trash folder.
+ ///
+ [Test]
+ public void TestRejectGivenFolder()
+ {
+ TestHelpers.InMethod();
+// TestHelpers.EnableLogging();
+
+ UUID initialSessionId = TestHelpers.ParseTail(0x10);
+ UUID folderId = TestHelpers.ParseTail(0x100);
+
+ UserAccount ua1
+ = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
+ UserAccount ua2
+ = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");
+
+ ScenePresence giverSp = SceneHelpers.AddScenePresence(m_scene, ua1);
+ TestClient giverClient = (TestClient)giverSp.ControllingClient;
+
+ ScenePresence receiverSp = SceneHelpers.AddScenePresence(m_scene, ua2);
+ TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
+
+ // Create the folder to test give
+ InventoryFolderBase originalFolder
+ = UserInventoryHelpers.CreateInventoryFolder(
+ m_scene.InventoryService, giverSp.UUID, folderId, "f1", true);
+
+ GridInstantMessage receivedIm = null;
+ receiverClient.OnReceivedInstantMessage += im => receivedIm = im;
+
+ byte[] giveImBinaryBucket = new byte[17];
+ giveImBinaryBucket[0] = (byte)AssetType.Folder;
+ byte[] itemIdBytes = folderId.GetBytes();
+ Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
+
+ GridInstantMessage giveIm
+ = new GridInstantMessage(
+ m_scene,
+ giverSp.UUID,
+ giverSp.Name,
+ receiverSp.UUID,
+ (byte)InstantMessageDialog.InventoryOffered,
+ false,
+ "inventory offered msg",
+ initialSessionId,
+ false,
+ Vector3.Zero,
+ giveImBinaryBucket,
+ true);
+
+ giverClient.HandleImprovedInstantMessage(giveIm);
+
+ // These details might not all be correct.
+ // Session ID is now the created item ID (!)
+ GridInstantMessage rejectIm
+ = new GridInstantMessage(
+ m_scene,
+ receiverSp.UUID,
+ receiverSp.Name,
+ giverSp.UUID,
+ (byte)InstantMessageDialog.InventoryDeclined,
+ false,
+ "inventory declined msg",
+ new UUID(receivedIm.imSessionID),
+ false,
+ Vector3.Zero,
+ null,
+ true);
+
+ receiverClient.HandleImprovedInstantMessage(rejectIm);
+
+ // Test for item remaining in the giver's inventory (here we assume a copy item)
+ // TODO: Test no-copy items.
+ InventoryFolderBase originalFolderAfterGive
+ = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");
+
+ Assert.That(originalFolderAfterGive, Is.Not.Null);
+ Assert.That(originalFolderAfterGive.ID, Is.EqualTo(originalFolder.ID));
+
+ // Test for folder successfully making it into the receiver's inventory
+ InventoryFolderBase receivedFolder
+ = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, receiverSp.UUID, "Trash/f1");
+
+ InventoryFolderBase trashFolder
+ = m_scene.InventoryService.GetFolderForType(receiverSp.UUID, AssetType.TrashFolder);
+
+ Assert.That(receivedFolder, Is.Not.Null);
+ Assert.That(receivedFolder.ID, Is.Not.EqualTo(originalFolder.ID));
+ Assert.That(receivedFolder.ParentID, Is.EqualTo(trashFolder.ID));
+
+ // Test that on a delete, item still exists and is accessible for the giver.
+ m_scene.InventoryService.PurgeFolder(trashFolder);
+
+ InventoryFolderBase originalFolderAfterDelete
+ = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");
+
+ Assert.That(originalFolderAfterDelete, Is.Not.Null);
+ }
}
}
\ No newline at end of file
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
index a1794c9..b3b75af 100644
--- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
@@ -218,12 +218,37 @@ namespace OpenSim.Tests.Common
public static InventoryFolderBase CreateInventoryFolder(
IInventoryService inventoryService, UUID userId, string path, bool useExistingFolders)
{
+ return CreateInventoryFolder(inventoryService, userId, UUID.Random(), path, useExistingFolders);
+ }
+
+ ///
+ /// Create inventory folders starting from the user's root folder.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
+ ///
+ ///
+ /// If true, then folders in the path which already the same name are
+ /// used. This applies to the terminal folder as well.
+ /// If false, then all folders in the path are created, even if there is already a folder at a particular
+ /// level with the same name.
+ ///
+ ///
+ /// The folder created. If the path contains multiple folders then the last one created is returned.
+ /// Will return null if the root folder could not be found.
+ ///
+ public static InventoryFolderBase CreateInventoryFolder(
+ IInventoryService inventoryService, UUID userId, UUID folderId, string path, bool useExistingFolders)
+ {
InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
if (null == rootFolder)
return null;
- return CreateInventoryFolder(inventoryService, rootFolder, path, useExistingFolders);
+ return CreateInventoryFolder(inventoryService, folderId, rootFolder, path, useExistingFolders);
}
///
@@ -235,6 +260,7 @@ namespace OpenSim.Tests.Common
/// TODO: May need to make it an option to create duplicate folders.
///
///
+ /// ID of the folder to create
///
///
/// The folder to create.
@@ -249,7 +275,7 @@ namespace OpenSim.Tests.Common
/// The folder created. If the path contains multiple folders then the last one created is returned.
///
public static InventoryFolderBase CreateInventoryFolder(
- IInventoryService inventoryService, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
+ IInventoryService inventoryService, UUID folderId, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
{
string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
@@ -262,9 +288,16 @@ namespace OpenSim.Tests.Common
{
// Console.WriteLine("Creating folder {0} at {1}", components[0], parentFolder.Name);
+ UUID folderIdForCreate;
+
+ if (components.Length > 1)
+ folderIdForCreate = UUID.Random();
+ else
+ folderIdForCreate = folderId;
+
folder
= new InventoryFolderBase(
- UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
+ folderIdForCreate, components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
inventoryService.AddFolder(folder);
}
@@ -274,7 +307,7 @@ namespace OpenSim.Tests.Common
// }
if (components.Length > 1)
- return CreateInventoryFolder(inventoryService, folder, components[1], useExistingFolders);
+ return CreateInventoryFolder(inventoryService, folderId, folder, components[1], useExistingFolders);
else
return folder;
}
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
index ccbdf81..30b1f38 100644
--- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
@@ -53,6 +53,9 @@ namespace OpenSim.Tests.Common.Mock
public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
{
+// Console.WriteLine(
+// "Requesting folders, fields {0}, vals {1}", string.Join(",", fields), string.Join(",", vals));
+
List origFolders
= Get(fields, vals, m_allFolders.Values.ToList());
@@ -104,7 +107,30 @@ namespace OpenSim.Tests.Common.Mock
}
public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); }
- public bool MoveFolder(string id, string newParent) { throw new NotImplementedException(); }
+
+ public bool MoveFolder(string id, string newParent)
+ {
+ // Don't use GetFolders() here - it takes a clone!
+ XInventoryFolder folder = m_allFolders[new UUID(id)];
+
+ if (folder == null)
+ return false;
+
+ folder.parentFolderID = new UUID(newParent);
+
+ XInventoryFolder[] newParentFolders
+ = GetFolders(new string[] { "folderID" }, new string[] { folder.parentFolderID.ToString() });
+
+// Console.WriteLine(
+// "Moved folder {0} {1}, to {2} {3}",
+// folder.folderName, folder.folderID, newParentFolders[0].folderName, folder.parentFolderID);
+
+ // TODO: Really need to implement folder version incrementing, though this should be common code anyway,
+ // not reimplemented in each db plugin.
+
+ return true;
+ }
+
public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); }
public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); }
}
--
cgit v1.1
From 537b243360a69f63210003371d1e6ef9f9c3716c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 29 Apr 2013 22:18:11 +0100
Subject: minor: Eliminate warning in LLimageManagerTests by properly calling
through to OpenSimTestCase.SetUp()
---
OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | 2 ++
1 file changed, 2 insertions(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
index 7d9f581..a0e0078 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
@@ -75,6 +75,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
[SetUp]
public void SetUp()
{
+ base.SetUp();
+
UUID userId = TestHelpers.ParseTail(0x3);
J2KDecoderModule j2kdm = new J2KDecoderModule();
--
cgit v1.1
From 3ce198165c3533d416148a9f4ffa056bf22c602d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 29 Apr 2013 22:21:57 +0100
Subject: minor: remove some mono compiler warnings in ServicesServerBase
---
OpenSim/Server/Base/ServicesServerBase.cs | 5 -----
1 file changed, 5 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index 7c8e6b7..b13c87d 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -171,11 +171,6 @@ namespace OpenSim.Server.Base
m_console = MainConsole.Instance;
- // Configure the appenders for log4net
- //
- OpenSimAppender consoleAppender = null;
- FileAppender fileAppender = null;
-
if (logConfig != null)
{
FileInfo cfg = new FileInfo(logConfig);
--
cgit v1.1
From 46ae84cfba4b3256119422dd5dfba84da5d07165 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Tue, 30 Apr 2013 13:10:15 -0700
Subject: BulletSim: fix error messages created while an avatar has no initial
collisions. Usually happens when logging in an avatar that had been
previously flying. Uninitialized variable.
---
OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 3 +++
1 file changed, 3 insertions(+)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index 309d004..f047176 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -97,6 +97,9 @@ public abstract class BSPhysObject : PhysicsActor
CollisionCollection = new CollisionEventUpdate();
CollisionsLastReported = CollisionCollection;
+ CollisionsLastTick = new CollisionEventUpdate();
+ CollisionsLastTickStep = -1;
+
SubscribedEventsMs = 0;
CollidingStep = 0;
CollidingGroundStep = 0;
--
cgit v1.1