diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs | 346 |
1 files changed, 346 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs new file mode 100644 index 0000000..0b196c1 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCopyTests.cs | |||
@@ -0,0 +1,346 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using Nini.Config; | ||
32 | using NUnit.Framework; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
36 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | ||
37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
38 | using OpenSim.Region.CoreModules.World.Permissions; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Tests.Common; | ||
42 | |||
43 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
44 | { | ||
45 | /// <summary> | ||
46 | /// Test copying of scene objects. | ||
47 | /// </summary> | ||
48 | /// <remarks> | ||
49 | /// This is at a level above the SceneObjectBasicTests, which act on the scene directly. | ||
50 | /// </remarks> | ||
51 | [TestFixture] | ||
52 | public class SceneObjectCopyTests : OpenSimTestCase | ||
53 | { | ||
54 | [TestFixtureSetUp] | ||
55 | public void FixtureInit() | ||
56 | { | ||
57 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. | ||
58 | // This facility was added after the original async delete tests were written, so it may be possible now | ||
59 | // to not bother explicitly disabling their async (since everything will be running sync). | ||
60 | Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; | ||
61 | } | ||
62 | |||
63 | [TestFixtureTearDown] | ||
64 | public void TearDown() | ||
65 | { | ||
66 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple | ||
67 | // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression | ||
68 | // tests really shouldn't). | ||
69 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | ||
70 | } | ||
71 | |||
72 | [Test] | ||
73 | public void TestTakeCopyWhenCopierIsOwnerWithPerms() | ||
74 | { | ||
75 | TestHelpers.InMethod(); | ||
76 | // TestHelpers.EnableLogging(); | ||
77 | |||
78 | IConfigSource config = new IniConfigSource(); | ||
79 | config.AddConfig("Modules"); | ||
80 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
81 | |||
82 | TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); | ||
83 | SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); | ||
84 | UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); | ||
85 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; | ||
86 | |||
87 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
88 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
89 | sogd.Enabled = false; | ||
90 | |||
91 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID); | ||
92 | uint soLocalId = so.LocalId; | ||
93 | // so.UpdatePermissions( | ||
94 | // ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Copy, 1); | ||
95 | // so.UpdatePermissions( | ||
96 | // ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); | ||
97 | // so.UpdatePermissions( | ||
98 | // ua.PrincipalID, (byte)PermissionWho.Base, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); | ||
99 | // scene.HandleObjectPermissionsUpdate(client, client.AgentId, client.SessionId, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0); | ||
100 | |||
101 | // Ideally we might change these via client-focussed method calls as commented out above. However, this | ||
102 | // becomes very convoluted so we will set only the copy perm directly. | ||
103 | so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
104 | // so.RootPart.OwnerMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
105 | |||
106 | List<uint> localIds = new List<uint>(); | ||
107 | localIds.Add(so.LocalId); | ||
108 | |||
109 | // Specifying a UUID.Zero in this case will currently plop it in Lost and Found | ||
110 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
111 | |||
112 | // Check that object isn't copied until we crank the sogd handle. | ||
113 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
114 | Assert.That(retrievedPart, Is.Not.Null); | ||
115 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
116 | |||
117 | sogd.InventoryDeQueueAndDelete(); | ||
118 | |||
119 | // Check that object is still there. | ||
120 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
121 | Assert.That(retrievedPart2, Is.Not.Null); | ||
122 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
123 | |||
124 | // Check that we have a copy in inventory | ||
125 | InventoryItemBase item | ||
126 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1"); | ||
127 | Assert.That(item, Is.Not.Null); | ||
128 | } | ||
129 | |||
130 | [Test] | ||
131 | public void TestTakeCopyWhenCopierIsOwnerWithoutPerms() | ||
132 | { | ||
133 | TestHelpers.InMethod(); | ||
134 | // TestHelpers.EnableLogging(); | ||
135 | |||
136 | IConfigSource config = new IniConfigSource(); | ||
137 | config.AddConfig("Modules"); | ||
138 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
139 | |||
140 | TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); | ||
141 | SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); | ||
142 | UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); | ||
143 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; | ||
144 | |||
145 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
146 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
147 | sogd.Enabled = false; | ||
148 | |||
149 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID); | ||
150 | uint soLocalId = so.LocalId; | ||
151 | |||
152 | so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.All & ~OpenMetaverse.PermissionMask.Copy); | ||
153 | //so.RootPart.OwnerMask = (uint)(OpenMetaverse.PermissionMask.Copy & ~OpenMetaverse.PermissionMask.Copy); | ||
154 | |||
155 | List<uint> localIds = new List<uint>(); | ||
156 | localIds.Add(so.LocalId); | ||
157 | |||
158 | // Specifying a UUID.Zero in this case will currently plop it in Lost and Found | ||
159 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
160 | |||
161 | // Check that object isn't copied until we crank the sogd handle. | ||
162 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
163 | Assert.That(retrievedPart, Is.Not.Null); | ||
164 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
165 | |||
166 | sogd.InventoryDeQueueAndDelete(); | ||
167 | |||
168 | // Check that object is still there. | ||
169 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
170 | Assert.That(retrievedPart2, Is.Not.Null); | ||
171 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
172 | |||
173 | // Check that we do not have a copy in inventory | ||
174 | InventoryItemBase item | ||
175 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1"); | ||
176 | Assert.That(item, Is.Null); | ||
177 | } | ||
178 | |||
179 | [Test] | ||
180 | public void TestTakeCopyWhenCopierIsNotOwnerWithPerms() | ||
181 | { | ||
182 | TestHelpers.InMethod(); | ||
183 | // TestHelpers.EnableLogging(); | ||
184 | |||
185 | IConfigSource config = new IniConfigSource(); | ||
186 | config.AddConfig("Modules"); | ||
187 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
188 | |||
189 | TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); | ||
190 | SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); | ||
191 | UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); | ||
192 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; | ||
193 | |||
194 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
195 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
196 | sogd.Enabled = false; | ||
197 | |||
198 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", TestHelpers.ParseTail(0x2)); | ||
199 | uint soLocalId = so.LocalId; | ||
200 | |||
201 | // Base must allow transfer and copy | ||
202 | so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.Copy | OpenMetaverse.PermissionMask.Transfer); | ||
203 | // Must be set so anyone can copy | ||
204 | so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
205 | |||
206 | List<uint> localIds = new List<uint>(); | ||
207 | localIds.Add(so.LocalId); | ||
208 | |||
209 | // Specifying a UUID.Zero in this case will plop it in the Objects folder | ||
210 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
211 | |||
212 | // Check that object isn't copied until we crank the sogd handle. | ||
213 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
214 | Assert.That(retrievedPart, Is.Not.Null); | ||
215 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
216 | |||
217 | sogd.InventoryDeQueueAndDelete(); | ||
218 | |||
219 | // Check that object is still there. | ||
220 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
221 | Assert.That(retrievedPart2, Is.Not.Null); | ||
222 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
223 | |||
224 | // Check that we have a copy in inventory | ||
225 | InventoryItemBase item | ||
226 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); | ||
227 | Assert.That(item, Is.Not.Null); | ||
228 | } | ||
229 | |||
230 | [Test] | ||
231 | public void TestTakeCopyWhenCopierIsNotOwnerWithoutPerms() | ||
232 | { | ||
233 | TestHelpers.InMethod(); | ||
234 | // TestHelpers.EnableLogging(); | ||
235 | |||
236 | IConfigSource config = new IniConfigSource(); | ||
237 | config.AddConfig("Modules"); | ||
238 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
239 | |||
240 | TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config); | ||
241 | SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule()); | ||
242 | UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1)); | ||
243 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient; | ||
244 | |||
245 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
246 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
247 | sogd.Enabled = false; | ||
248 | |||
249 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "so1", TestHelpers.ParseTail(0x2)); | ||
250 | uint soLocalId = so.LocalId; | ||
251 | |||
252 | { | ||
253 | // Check that object is not copied if copy base perms is missing. | ||
254 | // Should not allow copy if base does not have this. | ||
255 | so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Transfer; | ||
256 | // Must be set so anyone can copy | ||
257 | so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
258 | |||
259 | // Check that object is not copied | ||
260 | List<uint> localIds = new List<uint>(); | ||
261 | localIds.Add(so.LocalId); | ||
262 | |||
263 | // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms | ||
264 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
265 | |||
266 | // Check that object isn't copied until we crank the sogd handle. | ||
267 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
268 | Assert.That(retrievedPart, Is.Not.Null); | ||
269 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
270 | |||
271 | sogd.InventoryDeQueueAndDelete(); | ||
272 | // Check that object is still there. | ||
273 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
274 | Assert.That(retrievedPart2, Is.Not.Null); | ||
275 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
276 | |||
277 | // Check that we have a copy in inventory | ||
278 | InventoryItemBase item | ||
279 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); | ||
280 | Assert.That(item, Is.Null); | ||
281 | } | ||
282 | |||
283 | { | ||
284 | // Check that object is not copied if copy trans perms is missing. | ||
285 | // Should not allow copy if base does not have this. | ||
286 | so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
287 | // Must be set so anyone can copy | ||
288 | so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy; | ||
289 | |||
290 | // Check that object is not copied | ||
291 | List<uint> localIds = new List<uint>(); | ||
292 | localIds.Add(so.LocalId); | ||
293 | |||
294 | // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms | ||
295 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
296 | |||
297 | // Check that object isn't copied until we crank the sogd handle. | ||
298 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
299 | Assert.That(retrievedPart, Is.Not.Null); | ||
300 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
301 | |||
302 | sogd.InventoryDeQueueAndDelete(); | ||
303 | // Check that object is still there. | ||
304 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
305 | Assert.That(retrievedPart2, Is.Not.Null); | ||
306 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
307 | |||
308 | // Check that we have a copy in inventory | ||
309 | InventoryItemBase item | ||
310 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); | ||
311 | Assert.That(item, Is.Null); | ||
312 | } | ||
313 | |||
314 | { | ||
315 | // Check that object is not copied if everyone copy perms is missing. | ||
316 | // Should not allow copy if base does not have this. | ||
317 | so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.Copy | OpenMetaverse.PermissionMask.Transfer); | ||
318 | // Make sure everyone perm does not allow copy | ||
319 | so.RootPart.EveryoneMask = (uint)(OpenMetaverse.PermissionMask.All & ~OpenMetaverse.PermissionMask.Copy); | ||
320 | |||
321 | // Check that object is not copied | ||
322 | List<uint> localIds = new List<uint>(); | ||
323 | localIds.Add(so.LocalId); | ||
324 | |||
325 | // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms | ||
326 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero); | ||
327 | |||
328 | // Check that object isn't copied until we crank the sogd handle. | ||
329 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
330 | Assert.That(retrievedPart, Is.Not.Null); | ||
331 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
332 | |||
333 | sogd.InventoryDeQueueAndDelete(); | ||
334 | // Check that object is still there. | ||
335 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
336 | Assert.That(retrievedPart2, Is.Not.Null); | ||
337 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(0)); | ||
338 | |||
339 | // Check that we have a copy in inventory | ||
340 | InventoryItemBase item | ||
341 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1"); | ||
342 | Assert.That(item, Is.Null); | ||
343 | } | ||
344 | } | ||
345 | } | ||
346 | } \ No newline at end of file | ||