* 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>
|
/// </summary>
|
||||||
/// <param name="testLLUDPServer"></param>
|
/// <param name="testLLUDPServer"></param>
|
||||||
/// <param name="acm">Agent circuit manager used in setting up the stack</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();
|
ClientStackUserSettings userSettings = new ClientStackUserSettings();
|
||||||
testLLUDPServer = new TestLLUDPServer();
|
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
|
/// Set up a client for tests which aren't concerned with this process itself
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="circuitCode"></param>
|
/// <param name="circuitCode"></param>
|
||||||
|
/// <param name="epSender"></param>
|
||||||
/// <param name="testLLUDPServer"></param>
|
/// <param name="testLLUDPServer"></param>
|
||||||
/// <param name="acm"></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 myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001");
|
||||||
UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
|
UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002");
|
||||||
|
@ -98,18 +100,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
uccpCcBlock.SessionID = mySessionUuid;
|
uccpCcBlock.SessionID = mySessionUuid;
|
||||||
uccp.CircuitCode = uccpCcBlock;
|
uccp.CircuitCode = uccpCcBlock;
|
||||||
|
|
||||||
EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999);
|
|
||||||
|
|
||||||
acm.AddNewCircuit(circuitCode, acd);
|
acm.AddNewCircuit(circuitCode, acd);
|
||||||
|
|
||||||
testLLUDPServer.LoadReceive(uccp, testEp);
|
testLLUDPServer.LoadReceive(uccp, epSender);
|
||||||
testLLUDPServer.ReceiveData(null);
|
testLLUDPServer.ReceiveData(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test adding a client to the stack
|
/// Test adding a client to the stack
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Test]
|
||||||
public void TestAddClient()
|
public void TestAddClient()
|
||||||
{
|
{
|
||||||
uint myCircuitCode = 123456;
|
uint myCircuitCode = 123456;
|
||||||
|
@ -151,10 +151,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
Assert.IsFalse(testLLUDPServer.HasCircuit(101));
|
Assert.IsFalse(testLLUDPServer.HasCircuit(101));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test removing a client from the stack
|
/// Test removing a client from the stack
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Test]
|
||||||
public void TestRemoveClient()
|
public void TestRemoveClient()
|
||||||
{
|
{
|
||||||
uint myCircuitCode = 123457;
|
uint myCircuitCode = 123457;
|
||||||
|
@ -162,7 +162,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
TestLLUDPServer testLLUDPServer;
|
TestLLUDPServer testLLUDPServer;
|
||||||
AgentCircuitManager acm;
|
AgentCircuitManager acm;
|
||||||
SetupStack(out testLLUDPServer, out acm);
|
SetupStack(out testLLUDPServer, out acm);
|
||||||
AddClient(myCircuitCode, testLLUDPServer, acm);
|
AddClient(myCircuitCode, new IPEndPoint(IPAddress.Loopback, 1000), testLLUDPServer, acm);
|
||||||
|
|
||||||
testLLUDPServer.RemoveClientCircuit(myCircuitCode);
|
testLLUDPServer.RemoveClientCircuit(myCircuitCode);
|
||||||
Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode));
|
Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode));
|
||||||
|
@ -171,5 +171,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
|
||||||
testLLUDPServer.RemoveClientCircuit(101);
|
testLLUDPServer.RemoveClientCircuit(101);
|
||||||
Assert.IsFalse(testLLUDPServer.HasCircuit(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
|
// 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>
|
/// <summary>
|
||||||
/// Load a packet to be received by the LLUDPServer on the next receive call
|
/// Load a packet to be received by the LLUDPServer on the next receive call
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packet"></param>
|
/// <param name="packet"></param>
|
||||||
public void LoadReceive(Packet packet, EndPoint epSender)
|
public void LoadReceive(Packet packet, EndPoint epSender)
|
||||||
{
|
{
|
||||||
m_chunksToLoad.Enqueue(new ChunkSenderTuple(packet.ToBytes(), epSender));
|
LoadReceive(packet.ToBytes(), epSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue