From 7a761560c6482b092b16464b2cde893a74f8ffb6 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Thu, 13 Aug 2009 21:01:39 -0400 Subject: * Add AgentCircuitManager tests for adding, removing, changing circuit code, and authentication. --- .../Framework/Tests/AgentCircuitManagerTests.cs | 201 +++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 OpenSim/Framework/Tests/AgentCircuitManagerTests.cs (limited to 'OpenSim/Framework/Tests/AgentCircuitManagerTests.cs') diff --git a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs new file mode 100644 index 0000000..ab5f04a --- /dev/null +++ b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs @@ -0,0 +1,201 @@ +/* + * 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.Collections.Generic; +using OpenMetaverse; +using NUnit.Framework; +using System; + +namespace OpenSim.Framework.Tests +{ + [TestFixture] + public class AgentCircuitManagerTests + { + private AgentCircuitData m_agentCircuitData1; + private AgentCircuitData m_agentCircuitData2; + private UUID AgentId1; + private UUID AgentId2; + private uint circuitcode1; + private uint circuitcode2; + + private UUID SessionId1; + private UUID SessionId2; + private Random rnd = new Random(Environment.TickCount); + + [SetUp] + public void setup() + { + + AgentId1 = UUID.Random(); + AgentId2 = UUID.Random(); + circuitcode1 = (uint) rnd.Next((int)uint.MinValue, int.MaxValue); + circuitcode2 = (uint) rnd.Next((int)uint.MinValue, int.MaxValue); + SessionId1 = UUID.Random(); + SessionId2 = UUID.Random(); + UUID BaseFolder = UUID.Random(); + string CapsPath = "http://www.opensimulator.org/Caps/Foo"; + Dictionary ChildrenCapsPaths = new Dictionary(); + ChildrenCapsPaths.Add(ulong.MaxValue, "http://www.opensimulator.org/Caps/Foo2"); + string firstname = "CoolAvatarTest"; + string lastname = "test"; + Vector3 StartPos = new Vector3(5, 23, 125); + + UUID SecureSessionId = UUID.Random(); + UUID SessionId = UUID.Random(); + + m_agentCircuitData1 = new AgentCircuitData(); + m_agentCircuitData1.AgentID = AgentId1; + m_agentCircuitData1.Appearance = new AvatarAppearance(AgentId1); + m_agentCircuitData1.BaseFolder = BaseFolder; + m_agentCircuitData1.CapsPath = CapsPath; + m_agentCircuitData1.child = false; + m_agentCircuitData1.ChildrenCapSeeds = ChildrenCapsPaths; + m_agentCircuitData1.circuitcode = circuitcode1; + m_agentCircuitData1.firstname = firstname; + m_agentCircuitData1.InventoryFolder = BaseFolder; + m_agentCircuitData1.lastname = lastname; + m_agentCircuitData1.SecureSessionID = SecureSessionId; + m_agentCircuitData1.SessionID = SessionId1; + m_agentCircuitData1.startpos = StartPos; + + m_agentCircuitData2 = new AgentCircuitData(); + m_agentCircuitData2.AgentID = AgentId2; + m_agentCircuitData2.Appearance = new AvatarAppearance(AgentId2); + m_agentCircuitData2.BaseFolder = BaseFolder; + m_agentCircuitData2.CapsPath = CapsPath; + m_agentCircuitData2.child = false; + m_agentCircuitData2.ChildrenCapSeeds = ChildrenCapsPaths; + m_agentCircuitData2.circuitcode = circuitcode2; + m_agentCircuitData2.firstname = firstname; + m_agentCircuitData2.InventoryFolder = BaseFolder; + m_agentCircuitData2.lastname = lastname; + m_agentCircuitData2.SecureSessionID = SecureSessionId; + m_agentCircuitData2.SessionID = SessionId2; + m_agentCircuitData2.startpos = StartPos; + } + + /// + /// Validate that adding the circuit works appropriately + /// + [Test] + public void AddAgentCircuitTest() + { + AgentCircuitManager agentCircuitManager = new AgentCircuitManager(); + agentCircuitManager.AddNewCircuit(circuitcode1,m_agentCircuitData1); + agentCircuitManager.AddNewCircuit(circuitcode2, m_agentCircuitData2); + AgentCircuitData agent = agentCircuitManager.GetAgentCircuitData(circuitcode1); + + Assert.That((m_agentCircuitData1.AgentID == agent.AgentID)); + Assert.That((m_agentCircuitData1.BaseFolder == agent.BaseFolder)); + + Assert.That((m_agentCircuitData1.CapsPath == agent.CapsPath)); + Assert.That((m_agentCircuitData1.child == agent.child)); + Assert.That((m_agentCircuitData1.ChildrenCapSeeds.Count == agent.ChildrenCapSeeds.Count)); + Assert.That((m_agentCircuitData1.circuitcode == agent.circuitcode)); + Assert.That((m_agentCircuitData1.firstname == agent.firstname)); + Assert.That((m_agentCircuitData1.InventoryFolder == agent.InventoryFolder)); + Assert.That((m_agentCircuitData1.lastname == agent.lastname)); + Assert.That((m_agentCircuitData1.SecureSessionID == agent.SecureSessionID)); + Assert.That((m_agentCircuitData1.SessionID == agent.SessionID)); + Assert.That((m_agentCircuitData1.startpos == agent.startpos)); + } + + /// + /// Validate that removing the circuit code removes it appropriately + /// + [Test] + public void RemoveAgentCircuitTest() + { + AgentCircuitManager agentCircuitManager = new AgentCircuitManager(); + agentCircuitManager.AddNewCircuit(circuitcode1, m_agentCircuitData1); + agentCircuitManager.AddNewCircuit(circuitcode2, m_agentCircuitData2); + agentCircuitManager.RemoveCircuit(circuitcode2); + + AgentCircuitData agent = agentCircuitManager.GetAgentCircuitData(circuitcode2); + Assert.That(agent == null); + + } + + /// + /// Validate that changing the circuit code works + /// + [Test] + public void ChangeAgentCircuitCodeTest() + { + AgentCircuitManager agentCircuitManager = new AgentCircuitManager(); + agentCircuitManager.AddNewCircuit(circuitcode1, m_agentCircuitData1); + agentCircuitManager.AddNewCircuit(circuitcode2, m_agentCircuitData2); + bool result = false; + + result = agentCircuitManager.TryChangeCiruitCode(circuitcode1, 393930); + + AgentCircuitData agent = agentCircuitManager.GetAgentCircuitData(393930); + AgentCircuitData agent2 = agentCircuitManager.GetAgentCircuitData(circuitcode1); + Assert.That(agent != null); + Assert.That(agent2 == null); + Assert.That(result); + + } + + /// + /// Validates that the login authentication scheme is working + /// First one should be authorized + /// Rest should not be authorized + /// + [Test] + public void ValidateLoginTest() + { + AgentCircuitManager agentCircuitManager = new AgentCircuitManager(); + agentCircuitManager.AddNewCircuit(circuitcode1, m_agentCircuitData1); + agentCircuitManager.AddNewCircuit(circuitcode2, m_agentCircuitData2); + + // should be authorized + AuthenticateResponse resp = agentCircuitManager.AuthenticateSession(SessionId1, AgentId1, circuitcode1); + Assert.That(resp.Authorised); + + + //should not be authorized + resp = agentCircuitManager.AuthenticateSession(SessionId1, UUID.Random(), circuitcode1); + Assert.That(!resp.Authorised); + + resp = agentCircuitManager.AuthenticateSession(UUID.Random(), AgentId1, circuitcode1); + Assert.That(!resp.Authorised); + + resp = agentCircuitManager.AuthenticateSession(SessionId1, AgentId1, circuitcode2); + Assert.That(!resp.Authorised); + + resp = agentCircuitManager.AuthenticateSession(SessionId2, AgentId1, circuitcode2); + Assert.That(!resp.Authorised); + + agentCircuitManager.RemoveCircuit(circuitcode2); + + resp = agentCircuitManager.AuthenticateSession(SessionId2, AgentId2, circuitcode2); + Assert.That(!resp.Authorised); + + } + + } +} -- cgit v1.1 From 9d9fcac0386ba6adc7a1f6c08f82bd5c0b6cd1d2 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 14 Aug 2009 17:16:41 +0900 Subject: Misc cleanup. --- OpenSim/Framework/Tests/AgentCircuitManagerTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Tests/AgentCircuitManagerTests.cs') diff --git a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs index ab5f04a..6c98897 100644 --- a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs +++ b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework.Tests Vector3 StartPos = new Vector3(5, 23, 125); UUID SecureSessionId = UUID.Random(); - UUID SessionId = UUID.Random(); + // TODO: unused: UUID SessionId = UUID.Random(); m_agentCircuitData1 = new AgentCircuitData(); m_agentCircuitData1.AgentID = AgentId1; -- cgit v1.1 From b6ac1c46cd473b129b70344f0001f1e8f97d8860 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 2 Aug 2011 00:13:04 +0100 Subject: Get rid of AvatarAppearance.Owner to simplify the code. This is not used for anything - appearances are always properties of objects with ids (ScenePresence, AgentCircuitData) and just has the potential to get out of sync when the appearance is cloned. --- OpenSim/Framework/Tests/AgentCircuitManagerTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Tests/AgentCircuitManagerTests.cs') diff --git a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs index 6c98897..9615f1b 100644 --- a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs +++ b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs @@ -68,7 +68,7 @@ namespace OpenSim.Framework.Tests m_agentCircuitData1 = new AgentCircuitData(); m_agentCircuitData1.AgentID = AgentId1; - m_agentCircuitData1.Appearance = new AvatarAppearance(AgentId1); + m_agentCircuitData1.Appearance = new AvatarAppearance(); m_agentCircuitData1.BaseFolder = BaseFolder; m_agentCircuitData1.CapsPath = CapsPath; m_agentCircuitData1.child = false; @@ -83,7 +83,7 @@ namespace OpenSim.Framework.Tests m_agentCircuitData2 = new AgentCircuitData(); m_agentCircuitData2.AgentID = AgentId2; - m_agentCircuitData2.Appearance = new AvatarAppearance(AgentId2); + m_agentCircuitData2.Appearance = new AvatarAppearance(); m_agentCircuitData2.BaseFolder = BaseFolder; m_agentCircuitData2.CapsPath = CapsPath; m_agentCircuitData2.child = false; -- cgit v1.1 From 4919c6056022053f8632b030a06fd8f48ac02a8e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 3 Dec 2011 18:59:54 +0000 Subject: Add beginning of ScenePresenceAgentTests.TestCreateChildScenePresence() This required an option to be added to NullRegionData via ConnectionString for it to act as a non-static instance, so that regression tests (which only load this class once) don't get hopeless confused and complex to compensate. Normal standalone operation unaffected. --- OpenSim/Framework/Tests/AgentCircuitManagerTests.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Framework/Tests/AgentCircuitManagerTests.cs') diff --git a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs index 9615f1b..ae132c8 100644 --- a/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs +++ b/OpenSim/Framework/Tests/AgentCircuitManagerTests.cs @@ -194,8 +194,6 @@ namespace OpenSim.Framework.Tests resp = agentCircuitManager.AuthenticateSession(SessionId2, AgentId2, circuitcode2); Assert.That(!resp.Authorised); - } - } } -- cgit v1.1