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.

varregion
Justin Clark-Casey (justincc) 2013-09-19 20:24:08 +01:00
parent 997700c4aa
commit 83c113896e
2 changed files with 88 additions and 1 deletions

View File

@ -731,6 +731,7 @@ namespace OpenSim.Region.Framework.Scenes
m_config = config; m_config = config;
MinFrameTime = 0.089f; MinFrameTime = 0.089f;
MinMaintenanceTime = 1; MinMaintenanceTime = 1;
SeeIntoRegion = true;
Random random = new Random(); Random random = new Random();
@ -841,7 +842,7 @@ namespace OpenSim.Region.Framework.Scenes
//Animation states //Animation states
m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 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); MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20);

View File

@ -38,6 +38,7 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.CoreModules.Framework; using OpenSim.Region.CoreModules.Framework;
using OpenSim.Region.CoreModules.Framework.EntityTransfer; using OpenSim.Region.CoreModules.Framework.EntityTransfer;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
using OpenSim.Region.CoreModules.World.Permissions;
using OpenSim.Tests.Common; using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock; using OpenSim.Tests.Common.Mock;
@ -159,5 +160,90 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(agentMovementCompleteReceived, Is.EqualTo(1)); Assert.That(agentMovementCompleteReceived, Is.EqualTo(1));
Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False); Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False);
} }
/// <summary>
/// Test a cross attempt where the user can see into the neighbour but does not have permission to become
/// root there.
/// </summary>
[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<TestClient> destinationTestClients = new List<TestClient>();
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);
}
} }
} }