diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | 175 |
1 files changed, 88 insertions, 87 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs index a575e36..109a8e1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | |||
@@ -45,6 +45,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
45 | [TestFixture] | 45 | [TestFixture] |
46 | public class BasicCircuitTests | 46 | public class BasicCircuitTests |
47 | { | 47 | { |
48 | private Scene m_scene; | ||
49 | private TestLLUDPServer m_udpServer; | ||
50 | |||
48 | [TestFixtureSetUp] | 51 | [TestFixtureSetUp] |
49 | public void FixtureInit() | 52 | public void FixtureInit() |
50 | { | 53 | { |
@@ -61,83 +64,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
61 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | 64 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; |
62 | } | 65 | } |
63 | 66 | ||
64 | // /// <summary> | 67 | [SetUp] |
65 | // /// Add a client for testing | 68 | public void SetUp() |
66 | // /// </summary> | 69 | { |
67 | // /// <param name="scene"></param> | 70 | m_scene = new SceneHelpers().SetupScene(); |
68 | // /// <param name="testLLUDPServer"></param> | 71 | } |
69 | // /// <param name="testPacketServer"></param> | ||
70 | // /// <param name="acm">Agent circuit manager used in setting up the stack</param> | ||
71 | // protected void SetupStack( | ||
72 | // IScene scene, out TestLLUDPServer testLLUDPServer, out TestLLPacketServer testPacketServer, | ||
73 | // out AgentCircuitManager acm) | ||
74 | // { | ||
75 | // IConfigSource configSource = new IniConfigSource(); | ||
76 | // ClientStackUserSettings userSettings = new ClientStackUserSettings(); | ||
77 | // testLLUDPServer = new TestLLUDPServer(); | ||
78 | // acm = new AgentCircuitManager(); | ||
79 | // | ||
80 | // uint port = 666; | ||
81 | // testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm); | ||
82 | // testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings); | ||
83 | // testLLUDPServer.LocalScene = scene; | ||
84 | // } | ||
85 | |||
86 | // /// <summary> | ||
87 | // /// Set up a client for tests which aren't concerned with this process itself and where only one client is being | ||
88 | // /// tested | ||
89 | // /// </summary> | ||
90 | // /// <param name="circuitCode"></param> | ||
91 | // /// <param name="epSender"></param> | ||
92 | // /// <param name="testLLUDPServer"></param> | ||
93 | // /// <param name="acm"></param> | ||
94 | // protected void AddClient( | ||
95 | // uint circuitCode, EndPoint epSender, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) | ||
96 | // { | ||
97 | // UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
98 | // UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); | ||
99 | // | ||
100 | // AddClient(circuitCode, epSender, myAgentUuid, mySessionUuid, testLLUDPServer, acm); | ||
101 | // } | ||
102 | |||
103 | // /// <summary> | ||
104 | // /// Set up a client for tests which aren't concerned with this process itself | ||
105 | // /// </summary> | ||
106 | // /// <param name="circuitCode"></param> | ||
107 | // /// <param name="epSender"></param> | ||
108 | // /// <param name="agentId"></param> | ||
109 | // /// <param name="sessionId"></param> | ||
110 | // /// <param name="testLLUDPServer"></param> | ||
111 | // /// <param name="acm"></param> | ||
112 | // protected void AddClient( | ||
113 | // uint circuitCode, EndPoint epSender, UUID agentId, UUID sessionId, | ||
114 | // TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) | ||
115 | // { | ||
116 | // AgentCircuitData acd = new AgentCircuitData(); | ||
117 | // acd.AgentID = agentId; | ||
118 | // acd.SessionID = sessionId; | ||
119 | // | ||
120 | // UseCircuitCodePacket uccp = new UseCircuitCodePacket(); | ||
121 | // | ||
122 | // UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock | ||
123 | // = new UseCircuitCodePacket.CircuitCodeBlock(); | ||
124 | // uccpCcBlock.Code = circuitCode; | ||
125 | // uccpCcBlock.ID = agentId; | ||
126 | // uccpCcBlock.SessionID = sessionId; | ||
127 | // uccp.CircuitCode = uccpCcBlock; | ||
128 | // | ||
129 | // acm.AddNewCircuit(circuitCode, acd); | ||
130 | // | ||
131 | // testLLUDPServer.LoadReceive(uccp, epSender); | ||
132 | // testLLUDPServer.ReceiveData(null); | ||
133 | // } | ||
134 | 72 | ||
135 | /// <summary> | 73 | /// <summary> |
136 | /// Build an object name packet for test purposes | 74 | /// Build an object name packet for test purposes |
137 | /// </summary> | 75 | /// </summary> |
138 | /// <param name="objectLocalId"></param> | 76 | /// <param name="objectLocalId"></param> |
139 | /// <param name="objectName"></param> | 77 | /// <param name="objectName"></param> |
140 | protected ObjectNamePacket BuildTestObjectNamePacket(uint objectLocalId, string objectName) | 78 | private ObjectNamePacket BuildTestObjectNamePacket(uint objectLocalId, string objectName) |
141 | { | 79 | { |
142 | ObjectNamePacket onp = new ObjectNamePacket(); | 80 | ObjectNamePacket onp = new ObjectNamePacket(); |
143 | ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock(); | 81 | ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock(); |
@@ -148,6 +86,55 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
148 | 86 | ||
149 | return onp; | 87 | return onp; |
150 | } | 88 | } |
89 | |||
90 | private void AddUdpServer() | ||
91 | { | ||
92 | AddUdpServer(new IniConfigSource()); | ||
93 | } | ||
94 | |||
95 | private void AddUdpServer(IniConfigSource configSource) | ||
96 | { | ||
97 | uint port = 0; | ||
98 | AgentCircuitManager acm = m_scene.AuthenticateHandler; | ||
99 | |||
100 | m_udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm); | ||
101 | m_udpServer.AddScene(m_scene); | ||
102 | } | ||
103 | |||
104 | /// <summary> | ||
105 | /// Used by tests that aren't testing this stage. | ||
106 | /// </summary> | ||
107 | private ScenePresence AddClient() | ||
108 | { | ||
109 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); | ||
110 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); | ||
111 | uint myCircuitCode = 123456; | ||
112 | IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); | ||
113 | |||
114 | UseCircuitCodePacket uccp = new UseCircuitCodePacket(); | ||
115 | |||
116 | UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock | ||
117 | = new UseCircuitCodePacket.CircuitCodeBlock(); | ||
118 | uccpCcBlock.Code = myCircuitCode; | ||
119 | uccpCcBlock.ID = myAgentUuid; | ||
120 | uccpCcBlock.SessionID = mySessionUuid; | ||
121 | uccp.CircuitCode = uccpCcBlock; | ||
122 | |||
123 | byte[] uccpBytes = uccp.ToBytes(); | ||
124 | UDPPacketBuffer upb = new UDPPacketBuffer(testEp, uccpBytes.Length); | ||
125 | upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. | ||
126 | Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); | ||
127 | |||
128 | AgentCircuitData acd = new AgentCircuitData(); | ||
129 | acd.AgentID = myAgentUuid; | ||
130 | acd.SessionID = mySessionUuid; | ||
131 | |||
132 | m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd); | ||
133 | |||
134 | m_udpServer.PacketReceived(upb); | ||
135 | |||
136 | return m_scene.GetScenePresence(myAgentUuid); | ||
137 | } | ||
151 | 138 | ||
152 | /// <summary> | 139 | /// <summary> |
153 | /// Test adding a client to the stack | 140 | /// Test adding a client to the stack |
@@ -158,19 +145,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
158 | TestHelpers.InMethod(); | 145 | TestHelpers.InMethod(); |
159 | // XmlConfigurator.Configure(); | 146 | // XmlConfigurator.Configure(); |
160 | 147 | ||
161 | TestScene scene = SceneHelpers.SetupScene(); | 148 | AddUdpServer(); |
162 | uint myCircuitCode = 123456; | 149 | |
163 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); | 150 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); |
164 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); | 151 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); |
152 | uint myCircuitCode = 123456; | ||
165 | IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); | 153 | IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); |
166 | 154 | ||
167 | uint port = 0; | ||
168 | AgentCircuitManager acm = scene.AuthenticateHandler; | ||
169 | |||
170 | TestLLUDPServer llUdpServer | ||
171 | = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, new IniConfigSource(), acm); | ||
172 | llUdpServer.AddScene(scene); | ||
173 | |||
174 | UseCircuitCodePacket uccp = new UseCircuitCodePacket(); | 155 | UseCircuitCodePacket uccp = new UseCircuitCodePacket(); |
175 | 156 | ||
176 | UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock | 157 | UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock |
@@ -185,26 +166,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
185 | upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. | 166 | upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. |
186 | Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); | 167 | Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); |
187 | 168 | ||
188 | llUdpServer.PacketReceived(upb); | 169 | m_udpServer.PacketReceived(upb); |
189 | 170 | ||
190 | // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet | 171 | // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet |
191 | Assert.That(scene.GetScenePresence(myAgentUuid), Is.Null); | 172 | Assert.That(m_scene.GetScenePresence(myAgentUuid), Is.Null); |
192 | 173 | ||
193 | AgentCircuitData acd = new AgentCircuitData(); | 174 | AgentCircuitData acd = new AgentCircuitData(); |
194 | acd.AgentID = myAgentUuid; | 175 | acd.AgentID = myAgentUuid; |
195 | acd.SessionID = mySessionUuid; | 176 | acd.SessionID = mySessionUuid; |
196 | 177 | ||
197 | acm.AddNewCircuit(myCircuitCode, acd); | 178 | m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd); |
198 | 179 | ||
199 | llUdpServer.PacketReceived(upb); | 180 | m_udpServer.PacketReceived(upb); |
200 | 181 | ||
201 | // Should succeed now | 182 | // Should succeed now |
202 | ScenePresence sp = scene.GetScenePresence(myAgentUuid); | 183 | ScenePresence sp = m_scene.GetScenePresence(myAgentUuid); |
203 | Assert.That(sp.UUID, Is.EqualTo(myAgentUuid)); | 184 | Assert.That(sp.UUID, Is.EqualTo(myAgentUuid)); |
204 | 185 | ||
205 | Assert.That(llUdpServer.PacketsSent.Count, Is.EqualTo(1)); | 186 | Assert.That(m_udpServer.PacketsSent.Count, Is.EqualTo(1)); |
206 | 187 | ||
207 | Packet packet = llUdpServer.PacketsSent[0]; | 188 | Packet packet = m_udpServer.PacketsSent[0]; |
208 | Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket))); | 189 | Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket))); |
209 | 190 | ||
210 | PacketAckPacket ackPacket = packet as PacketAckPacket; | 191 | PacketAckPacket ackPacket = packet as PacketAckPacket; |
@@ -212,6 +193,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
212 | Assert.That(ackPacket.Packets[0].ID, Is.EqualTo(0)); | 193 | Assert.That(ackPacket.Packets[0].ID, Is.EqualTo(0)); |
213 | } | 194 | } |
214 | 195 | ||
196 | [Test] | ||
197 | public void TestLogoutClientDueToAck() | ||
198 | { | ||
199 | TestHelpers.InMethod(); | ||
200 | // TestHelpers.EnableLogging(); | ||
201 | |||
202 | IniConfigSource ics = new IniConfigSource(); | ||
203 | IConfig config = ics.AddConfig("ClientStack.LindenUDP"); | ||
204 | config.Set("AckTimeout", -1); | ||
205 | AddUdpServer(ics); | ||
206 | |||
207 | ScenePresence sp = AddClient(); | ||
208 | m_udpServer.ClientOutgoingPacketHandler(sp.ControllingClient, true, false, false); | ||
209 | |||
210 | ScenePresence spAfterAckTimeout = m_scene.GetScenePresence(sp.UUID); | ||
211 | Assert.That(spAfterAckTimeout, Is.Null); | ||
212 | |||
213 | // TestHelpers.DisableLogging(); | ||
214 | } | ||
215 | |||
215 | // /// <summary> | 216 | // /// <summary> |
216 | // /// Test removing a client from the stack | 217 | // /// Test removing a client from the stack |
217 | // /// </summary> | 218 | // /// </summary> |