diff options
author | Justin Clark-Casey (justincc) | 2010-11-22 22:51:26 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-11-22 22:54:13 +0000 |
commit | 34b13a4765cd74a5a09739beb13968da5b9e3e16 (patch) | |
tree | f515b7ecd51f0c90fbccf122fae5e1559d945970 /OpenSim/Region/Framework/Scenes/Tests | |
parent | Fox case on a method (diff) | |
download | opensim-SC_OLD-34b13a4765cd74a5a09739beb13968da5b9e3e16.zip opensim-SC_OLD-34b13a4765cd74a5a09739beb13968da5b9e3e16.tar.gz opensim-SC_OLD-34b13a4765cd74a5a09739beb13968da5b9e3e16.tar.bz2 opensim-SC_OLD-34b13a4765cd74a5a09739beb13968da5b9e3e16.tar.xz |
add basic tests to check that under default permissions module owner can delete objects and that non-owners (who are also not administrators, etc.) cannot
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserTests.cs | 124 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | 2 |
2 files changed, 126 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserTests.cs new file mode 100644 index 0000000..7851f72 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserTests.cs | |||
@@ -0,0 +1,124 @@ | |||
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.Reflection; | ||
30 | using Nini.Config; | ||
31 | using NUnit.Framework; | ||
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Region.CoreModules.World.Permissions; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Tests.Common; | ||
39 | using OpenSim.Tests.Common.Mock; | ||
40 | using OpenSim.Tests.Common.Setup; | ||
41 | |||
42 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// Tests manipulation of scene objects by users. | ||
46 | /// </summary> | ||
47 | /// | ||
48 | /// This is at a level above the SceneObjectBasicTests, which act on the scene directly. | ||
49 | /// FIXME: These tests are very incomplete - they only test for a few conditions. | ||
50 | [TestFixture] | ||
51 | public class SceneObjectUserTests | ||
52 | { | ||
53 | /// <summary> | ||
54 | /// Test deleting an object from a scene. | ||
55 | /// </summary> | ||
56 | [Test] | ||
57 | public void TestDeRezSceneObject() | ||
58 | { | ||
59 | TestHelper.InMethod(); | ||
60 | // log4net.Config.XmlConfigurator.Configure(); | ||
61 | |||
62 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | ||
63 | |||
64 | TestScene scene = SceneSetupHelpers.SetupScene(); | ||
65 | IConfigSource configSource = new IniConfigSource(); | ||
66 | IConfig config = configSource.AddConfig("Startup"); | ||
67 | config.Set("serverside_object_permissions", true); | ||
68 | SceneSetupHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() }); | ||
69 | TestClient client = SceneSetupHelpers.AddRootAgent(scene, userId); | ||
70 | |||
71 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
72 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
73 | sogd.Enabled = false; | ||
74 | |||
75 | SceneObjectPart part | ||
76 | = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); | ||
77 | part.Name = "obj1"; | ||
78 | scene.AddNewSceneObject(new SceneObjectGroup(part), false); | ||
79 | |||
80 | scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); | ||
81 | sogd.InventoryDeQueueAndDelete(); | ||
82 | |||
83 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
84 | Assert.That(retrievedPart, Is.Null); | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Test deleting an object from a scene where the deleter is not the owner | ||
89 | /// </summary> | ||
90 | /// | ||
91 | /// This test assumes that the deleter is not a god. | ||
92 | [Test] | ||
93 | public void TestDeRezSceneObjectNotOwner() | ||
94 | { | ||
95 | TestHelper.InMethod(); | ||
96 | // log4net.Config.XmlConfigurator.Configure(); | ||
97 | |||
98 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | ||
99 | UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); | ||
100 | |||
101 | TestScene scene = SceneSetupHelpers.SetupScene(); | ||
102 | IConfigSource configSource = new IniConfigSource(); | ||
103 | IConfig config = configSource.AddConfig("Startup"); | ||
104 | config.Set("serverside_object_permissions", true); | ||
105 | SceneSetupHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() }); | ||
106 | TestClient client = SceneSetupHelpers.AddRootAgent(scene, userId); | ||
107 | |||
108 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
109 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
110 | sogd.Enabled = false; | ||
111 | |||
112 | SceneObjectPart part | ||
113 | = new SceneObjectPart(objectOwnerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); | ||
114 | part.Name = "obj1"; | ||
115 | scene.AddNewSceneObject(new SceneObjectGroup(part), false); | ||
116 | |||
117 | scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); | ||
118 | sogd.InventoryDeQueueAndDelete(); | ||
119 | |||
120 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
121 | Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID)); | ||
122 | } | ||
123 | } | ||
124 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index ab5968c..ef52363 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -65,6 +65,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
65 | [TestFixtureSetUp] | 65 | [TestFixtureSetUp] |
66 | public void Init() | 66 | public void Init() |
67 | { | 67 | { |
68 | TestHelper.InMethod(); | ||
69 | |||
68 | scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); | 70 | scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); |
69 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | 71 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); |
70 | scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); | 72 | scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); |