From 689f79feadc1ffb74650a43f226a2d0ba654e739 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 19 Sep 2013 20:24:08 +0100
Subject: Create regression TestCrossOnSameSimulatorNoRootDestPerm() to check
that avatars are not allowed to cross into a neighbour where they are not
authorized, even if a child agent was allowed.
---
OpenSim/Region/Framework/Scenes/Scene.cs | 3 +-
.../Scenes/Tests/ScenePresenceCrossingTests.cs | 86 ++++++++++++++++++++++
2 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 758a012..4357b91 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -731,6 +731,7 @@ namespace OpenSim.Region.Framework.Scenes
m_config = config;
MinFrameTime = 0.089f;
MinMaintenanceTime = 1;
+ SeeIntoRegion = true;
Random random = new Random();
@@ -841,7 +842,7 @@ namespace OpenSim.Region.Framework.Scenes
//Animation states
m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
- SeeIntoRegion = startupConfig.GetBoolean("see_into_region", true);
+ SeeIntoRegion = startupConfig.GetBoolean("see_into_region", SeeIntoRegion);
MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
index 12a778b..cf211a1 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
@@ -38,6 +38,7 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.CoreModules.Framework;
using OpenSim.Region.CoreModules.Framework.EntityTransfer;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
+using OpenSim.Region.CoreModules.World.Permissions;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
@@ -159,5 +160,90 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(agentMovementCompleteReceived, Is.EqualTo(1));
Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False);
}
+
+ ///
+ /// Test a cross attempt where the user can see into the neighbour but does not have permission to become
+ /// root there.
+ ///
+ [Test]
+ public void TestCrossOnSameSimulatorNoRootDestPerm()
+ {
+ TestHelpers.InMethod();
+// TestHelpers.EnableLogging();
+
+ UUID userId = TestHelpers.ParseTail(0x1);
+
+ EntityTransferModule etmA = new EntityTransferModule();
+ EntityTransferModule etmB = new EntityTransferModule();
+ LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
+
+ IConfigSource config = new IniConfigSource();
+ IConfig modulesConfig = config.AddConfig("Modules");
+ modulesConfig.Set("EntityTransferModule", etmA.Name);
+ modulesConfig.Set("SimulationServices", lscm.Name);
+
+ SceneHelpers sh = new SceneHelpers();
+ TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
+ TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
+
+ SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
+ SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
+
+ // We need to set up the permisions module on scene B so that our later use of agent limit to deny
+ // QueryAccess won't succeed anyway because administrators are always allowed in and the default
+ // IsAdministrator if no permissions module is present is true.
+ SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new PermissionsModule(), etmB);
+
+ AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
+ TestClient tc = new TestClient(acd, sceneA);
+ List destinationTestClients = new List();
+ EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
+
+ // Make sure sceneB will not accept this avatar.
+ sceneB.RegionInfo.EstateSettings.PublicAccess = false;
+
+ ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
+ originalSp.AbsolutePosition = new Vector3(128, 32, 10);
+
+ AgentUpdateArgs moveArgs = new AgentUpdateArgs();
+ //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
+ moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
+ moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
+ moveArgs.SessionID = acd.SessionID;
+
+ originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
+
+ sceneA.Update(1);
+
+// Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);
+
+ // FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
+ // But really we want to do this in a more robust way.
+ for (int i = 0; i < 100; i++)
+ {
+ sceneA.Update(1);
+// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
+ }
+
+ // sceneA agent should still be root
+ ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
+ Assert.That(spAfterCrossSceneA.IsChildAgent, Is.False);
+
+ ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);
+
+ // sceneB agent should also still be root
+ Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
+
+ // sceneB should ignore unauthorized attempt to upgrade agent to root
+ TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);
+
+ int agentMovementCompleteReceived = 0;
+ sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;
+
+ sceneBTc.CompleteMovement();
+
+ Assert.That(agentMovementCompleteReceived, Is.EqualTo(0));
+ Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
+ }
}
}
\ No newline at end of file
--
cgit v1.1