diff options
author | Justin Clarke Casey | 2008-10-30 20:17:30 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-10-30 20:17:30 +0000 |
commit | 419775c72bcf0297e84ff3c74354a0aba523e1e2 (patch) | |
tree | 76f661af80bc8eebe0ed1509a7249e7a2db7b044 /OpenSim | |
parent | * Remove OpenSim.Data.SQLite.Tests.dll.config that probably accidentally made... (diff) | |
download | opensim-SC_OLD-419775c72bcf0297e84ff3c74354a0aba523e1e2.zip opensim-SC_OLD-419775c72bcf0297e84ff3c74354a0aba523e1e2.tar.gz opensim-SC_OLD-419775c72bcf0297e84ff3c74354a0aba523e1e2.tar.bz2 opensim-SC_OLD-419775c72bcf0297e84ff3c74354a0aba523e1e2.tar.xz |
* test: Test that the client stack doesn't completely blow up if a client passes it malformed data
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs | 41 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs | 12 |
2 files changed, 43 insertions, 10 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs index 07fbf55..c75a5b3 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/BasicCircuitTests.cs | |||
@@ -62,7 +62,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
62 | /// </summary> | 62 | /// </summary> |
63 | /// <param name="testLLUDPServer"></param> | 63 | /// <param name="testLLUDPServer"></param> |
64 | /// <param name="acm">Agent circuit manager used in setting up the stack</param> | 64 | /// <param name="acm">Agent circuit manager used in setting up the stack</param> |
65 | protected void SetupStack( out TestLLUDPServer testLLUDPServer, out AgentCircuitManager acm) | 65 | protected void SetupStack(out TestLLUDPServer testLLUDPServer, out AgentCircuitManager acm) |
66 | { | 66 | { |
67 | ClientStackUserSettings userSettings = new ClientStackUserSettings(); | 67 | ClientStackUserSettings userSettings = new ClientStackUserSettings(); |
68 | testLLUDPServer = new TestLLUDPServer(); | 68 | testLLUDPServer = new TestLLUDPServer(); |
@@ -78,9 +78,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
78 | /// Set up a client for tests which aren't concerned with this process itself | 78 | /// Set up a client for tests which aren't concerned with this process itself |
79 | /// </summary> | 79 | /// </summary> |
80 | /// <param name="circuitCode"></param> | 80 | /// <param name="circuitCode"></param> |
81 | /// <param name="epSender"></param> | ||
81 | /// <param name="testLLUDPServer"></param> | 82 | /// <param name="testLLUDPServer"></param> |
82 | /// <param name="acm"></param> | 83 | /// <param name="acm"></param> |
83 | protected void AddClient(uint circuitCode, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) | 84 | protected void AddClient( |
85 | uint circuitCode, EndPoint epSender, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) | ||
84 | { | 86 | { |
85 | UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); | 87 | UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
86 | UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); | 88 | UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); |
@@ -97,19 +99,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
97 | uccpCcBlock.ID = myAgentUuid; | 99 | uccpCcBlock.ID = myAgentUuid; |
98 | uccpCcBlock.SessionID = mySessionUuid; | 100 | uccpCcBlock.SessionID = mySessionUuid; |
99 | uccp.CircuitCode = uccpCcBlock; | 101 | uccp.CircuitCode = uccpCcBlock; |
100 | 102 | ||
101 | EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); | ||
102 | |||
103 | acm.AddNewCircuit(circuitCode, acd); | 103 | acm.AddNewCircuit(circuitCode, acd); |
104 | 104 | ||
105 | testLLUDPServer.LoadReceive(uccp, testEp); | 105 | testLLUDPServer.LoadReceive(uccp, epSender); |
106 | testLLUDPServer.ReceiveData(null); | 106 | testLLUDPServer.ReceiveData(null); |
107 | } | 107 | } |
108 | 108 | ||
109 | [Test] | ||
110 | /// <summary> | 109 | /// <summary> |
111 | /// Test adding a client to the stack | 110 | /// Test adding a client to the stack |
112 | /// </summary> | 111 | /// </summary> |
112 | [Test] | ||
113 | public void TestAddClient() | 113 | public void TestAddClient() |
114 | { | 114 | { |
115 | uint myCircuitCode = 123456; | 115 | uint myCircuitCode = 123456; |
@@ -151,10 +151,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
151 | Assert.IsFalse(testLLUDPServer.HasCircuit(101)); | 151 | Assert.IsFalse(testLLUDPServer.HasCircuit(101)); |
152 | } | 152 | } |
153 | 153 | ||
154 | [Test] | ||
155 | /// <summary> | 154 | /// <summary> |
156 | /// Test removing a client from the stack | 155 | /// Test removing a client from the stack |
157 | /// </summary> | 156 | /// </summary> |
157 | [Test] | ||
158 | public void TestRemoveClient() | 158 | public void TestRemoveClient() |
159 | { | 159 | { |
160 | uint myCircuitCode = 123457; | 160 | uint myCircuitCode = 123457; |
@@ -162,7 +162,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
162 | TestLLUDPServer testLLUDPServer; | 162 | TestLLUDPServer testLLUDPServer; |
163 | AgentCircuitManager acm; | 163 | AgentCircuitManager acm; |
164 | SetupStack(out testLLUDPServer, out acm); | 164 | SetupStack(out testLLUDPServer, out acm); |
165 | AddClient(myCircuitCode, testLLUDPServer, acm); | 165 | AddClient(myCircuitCode, new IPEndPoint(IPAddress.Loopback, 1000), testLLUDPServer, acm); |
166 | 166 | ||
167 | testLLUDPServer.RemoveClientCircuit(myCircuitCode); | 167 | testLLUDPServer.RemoveClientCircuit(myCircuitCode); |
168 | Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode)); | 168 | Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode)); |
@@ -171,5 +171,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
171 | testLLUDPServer.RemoveClientCircuit(101); | 171 | testLLUDPServer.RemoveClientCircuit(101); |
172 | Assert.IsFalse(testLLUDPServer.HasCircuit(101)); | 172 | Assert.IsFalse(testLLUDPServer.HasCircuit(101)); |
173 | } | 173 | } |
174 | |||
175 | /// <summary> | ||
176 | /// Make sure that the client stack reacts okay to malformed packets | ||
177 | /// </summary> | ||
178 | [Test] | ||
179 | public void TestMalformedPacketSend() | ||
180 | { | ||
181 | uint myCircuitCode = 123458; | ||
182 | EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 1001); | ||
183 | |||
184 | TestLLUDPServer testLLUDPServer; | ||
185 | AgentCircuitManager acm; | ||
186 | SetupStack(out testLLUDPServer, out acm); | ||
187 | AddClient(myCircuitCode, testEp, testLLUDPServer, acm); | ||
188 | |||
189 | byte[] data = new byte[] { 0x01, 0x02, 0x03, 0x04 }; | ||
190 | |||
191 | testLLUDPServer.LoadReceive(data, testEp); | ||
192 | testLLUDPServer.ReceiveData(null); | ||
193 | |||
194 | // Check that we are still here | ||
195 | Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode)); | ||
196 | } | ||
174 | } | 197 | } |
175 | } | 198 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs index 8170150..95ee516 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLUDPServer.cs | |||
@@ -72,12 +72,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
72 | } | 72 | } |
73 | 73 | ||
74 | /// <summary> | 74 | /// <summary> |
75 | /// Load some data to be received by the LLUDPServer on the next receive call | ||
76 | /// </summary> | ||
77 | /// <param name="data"></param> | ||
78 | /// <param name="epSender"></param> | ||
79 | public void LoadReceive(byte[] data, EndPoint epSender) | ||
80 | { | ||
81 | m_chunksToLoad.Enqueue(new ChunkSenderTuple(data, epSender)); | ||
82 | } | ||
83 | |||
84 | /// <summary> | ||
75 | /// Load a packet to be received by the LLUDPServer on the next receive call | 85 | /// Load a packet to be received by the LLUDPServer on the next receive call |
76 | /// </summary> | 86 | /// </summary> |
77 | /// <param name="packet"></param> | 87 | /// <param name="packet"></param> |
78 | public void LoadReceive(Packet packet, EndPoint epSender) | 88 | public void LoadReceive(Packet packet, EndPoint epSender) |
79 | { | 89 | { |
80 | m_chunksToLoad.Enqueue(new ChunkSenderTuple(packet.ToBytes(), epSender)); | 90 | LoadReceive(packet.ToBytes(), epSender); |
81 | } | 91 | } |
82 | 92 | ||
83 | /// <summary> | 93 | /// <summary> |