* test: Test that the client stack doesn't completely blow up if a client passes it malformed data
							parent
							
								
									7165dd83fa
								
							
						
					
					
						commit
						419775c72b
					
				|  | @ -62,7 +62,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
|         /// </summary> | ||||
|         /// <param name="testLLUDPServer"></param> | ||||
|         /// <param name="acm">Agent circuit manager used in setting up the stack</param>         | ||||
|         protected void SetupStack( out TestLLUDPServer testLLUDPServer, out AgentCircuitManager acm) | ||||
|         protected void SetupStack(out TestLLUDPServer testLLUDPServer, out AgentCircuitManager acm) | ||||
|         { | ||||
|             ClientStackUserSettings userSettings = new ClientStackUserSettings(); | ||||
|             testLLUDPServer = new TestLLUDPServer();              | ||||
|  | @ -78,9 +78,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
|         /// Set up a client for tests which aren't concerned with this process itself | ||||
|         /// </summary> | ||||
|         /// <param name="circuitCode"></param> | ||||
|         /// <param name="epSender"></param> | ||||
|         /// <param name="testLLUDPServer"></param> | ||||
|         /// <param name="acm"></param> | ||||
|         protected void AddClient(uint circuitCode, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) | ||||
|         protected void AddClient( | ||||
|             uint circuitCode, EndPoint epSender, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) | ||||
|         { | ||||
|             UUID myAgentUuid   = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||||
|             UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); | ||||
|  | @ -97,19 +99,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
|             uccpCcBlock.ID = myAgentUuid; | ||||
|             uccpCcBlock.SessionID = mySessionUuid; | ||||
|             uccp.CircuitCode = uccpCcBlock; | ||||
|              | ||||
|             EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); | ||||
|              | ||||
| 
 | ||||
|             acm.AddNewCircuit(circuitCode, acd); | ||||
|              | ||||
|             testLLUDPServer.LoadReceive(uccp, testEp);             | ||||
|             testLLUDPServer.LoadReceive(uccp, epSender);             | ||||
|             testLLUDPServer.ReceiveData(null); | ||||
|         } | ||||
|          | ||||
|         [Test] | ||||
|         /// <summary> | ||||
|         /// Test adding a client to the stack | ||||
|         /// </summary> | ||||
|         [Test]         | ||||
|         public void TestAddClient() | ||||
|         {             | ||||
|             uint myCircuitCode = 123456; | ||||
|  | @ -151,10 +151,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
|             Assert.IsFalse(testLLUDPServer.HasCircuit(101)); | ||||
|         } | ||||
| 
 | ||||
|         [Test] | ||||
|         /// <summary> | ||||
|         /// Test removing a client from the stack | ||||
|         /// </summary> | ||||
|         [Test]         | ||||
|         public void TestRemoveClient() | ||||
|         { | ||||
|             uint myCircuitCode = 123457; | ||||
|  | @ -162,7 +162,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
|             TestLLUDPServer testLLUDPServer; | ||||
|             AgentCircuitManager acm; | ||||
|             SetupStack(out testLLUDPServer, out acm);             | ||||
|             AddClient(myCircuitCode, testLLUDPServer, acm); | ||||
|             AddClient(myCircuitCode, new IPEndPoint(IPAddress.Loopback, 1000), testLLUDPServer, acm); | ||||
|              | ||||
|             testLLUDPServer.RemoveClientCircuit(myCircuitCode);             | ||||
|             Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode)); | ||||
|  | @ -171,5 +171,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
|             testLLUDPServer.RemoveClientCircuit(101);             | ||||
|             Assert.IsFalse(testLLUDPServer.HasCircuit(101)); | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         /// Make sure that the client stack reacts okay to malformed packets | ||||
|         /// </summary> | ||||
|         [Test] | ||||
|         public void TestMalformedPacketSend() | ||||
|         { | ||||
|             uint myCircuitCode = 123458; | ||||
|             EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 1001);            | ||||
|              | ||||
|             TestLLUDPServer testLLUDPServer; | ||||
|             AgentCircuitManager acm; | ||||
|             SetupStack(out testLLUDPServer, out acm);             | ||||
|             AddClient(myCircuitCode, testEp, testLLUDPServer, acm);   | ||||
|              | ||||
|             byte[] data = new byte[] { 0x01, 0x02, 0x03, 0x04 }; | ||||
|              | ||||
|             testLLUDPServer.LoadReceive(data, testEp); | ||||
|             testLLUDPServer.ReceiveData(null);  | ||||
|              | ||||
|             // Check that we are still here | ||||
|             Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -71,13 +71,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
|             // Don't do anything just yet | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         /// Load some data to be received by the LLUDPServer on the next receive call | ||||
|         /// </summary> | ||||
|         /// <param name="data"></param> | ||||
|         /// <param name="epSender"></param> | ||||
|         public void LoadReceive(byte[] data, EndPoint epSender) | ||||
|         { | ||||
|             m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender)); | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|         /// Load a packet to be received by the LLUDPServer on the next receive call | ||||
|         /// </summary> | ||||
|         /// <param name="packet"></param> | ||||
|         public void LoadReceive(Packet packet, EndPoint epSender) | ||||
|         { | ||||
|             m_chunksToLoad.Enqueue(new ChunkSenderTuple(packet.ToBytes(), epSender)); | ||||
|             LoadReceive(packet.ToBytes(), epSender); | ||||
|         } | ||||
|          | ||||
|         /// <summary> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Justin Clarke Casey
						Justin Clarke Casey