diff options
author | UbitUmarov | 2017-05-02 01:09:32 +0100 |
---|---|---|
committer | UbitUmarov | 2017-05-02 01:09:32 +0100 |
commit | ed22c5f3beaa9b2b408b7f441e319267ab7c775b (patch) | |
tree | 79ca9f31f59bd12f3949c496c5516e33be538c7f | |
parent | save a few nanoseconds (diff) | |
parent | Shuffle some code around (diff) | |
download | opensim-SC-ed22c5f3beaa9b2b408b7f441e319267ab7c775b.zip opensim-SC-ed22c5f3beaa9b2b408b7f441e319267ab7c775b.tar.gz opensim-SC-ed22c5f3beaa9b2b408b7f441e319267ab7c775b.tar.bz2 opensim-SC-ed22c5f3beaa9b2b408b7f441e319267ab7c775b.tar.xz |
Merge branch 'master' of opensimulator.org:/var/git/opensim
-rw-r--r-- | OpenSim/Tests/Permissions/Common.cs | 60 | ||||
-rw-r--r-- | OpenSim/Tests/Permissions/DirectTransferTests.cs | 11 | ||||
-rw-r--r-- | OpenSim/Tests/Permissions/IndirectTransferTests.cs | 123 |
3 files changed, 176 insertions, 18 deletions
diff --git a/OpenSim/Tests/Permissions/Common.cs b/OpenSim/Tests/Permissions/Common.cs index 84dadf2..f93c120 100644 --- a/OpenSim/Tests/Permissions/Common.cs +++ b/OpenSim/Tests/Permissions/Common.cs | |||
@@ -1,6 +1,31 @@ | |||
1 | using System; | 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 | using System; | ||
2 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
3 | using System.Reflection; | ||
4 | using System.Threading; | 29 | using System.Threading; |
5 | using Nini.Config; | 30 | using Nini.Config; |
6 | using NUnit.Framework; | 31 | using NUnit.Framework; |
@@ -10,7 +35,6 @@ using OpenSim.Region.Framework.Scenes; | |||
10 | using OpenSim.Region.CoreModules.World.Permissions; | 35 | using OpenSim.Region.CoreModules.World.Permissions; |
11 | using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer; | 36 | using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer; |
12 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | 37 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; |
13 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
14 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
15 | using OpenSim.Tests.Common; | 39 | using OpenSim.Tests.Common; |
16 | using PermissionMask = OpenSim.Framework.PermissionMask; | 40 | using PermissionMask = OpenSim.Framework.PermissionMask; |
@@ -67,7 +91,7 @@ namespace OpenSim.Tests.Permissions | |||
67 | /// - 6 simple boxes inworld belonging to A0 and with Next Owner perms: | 91 | /// - 6 simple boxes inworld belonging to A0 and with Next Owner perms: |
68 | /// C, CT, MC, MCT, MT, T | 92 | /// C, CT, MC, MCT, MT, T |
69 | /// - Copies of all of these boxes in A0's inventory in the Objects folder | 93 | /// - Copies of all of these boxes in A0's inventory in the Objects folder |
70 | /// - One additional box in A0's inventory which is a copy of MCT, but | 94 | /// - One additional box inworld and in A0's inventory which is a copy of MCT, but |
71 | /// with C removed in inventory. This one is called MCT-C | 95 | /// with C removed in inventory. This one is called MCT-C |
72 | /// </summary> | 96 | /// </summary> |
73 | private void SetUpBasicEnvironment() | 97 | private void SetUpBasicEnvironment() |
@@ -140,7 +164,7 @@ namespace OpenSim.Tests.Permissions | |||
140 | PrintPerms(box); | 164 | PrintPerms(box); |
141 | AssertPermissions(nextOwnerPerms, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name); | 165 | AssertPermissions(nextOwnerPerms, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name); |
142 | 166 | ||
143 | TakeCopyToInventory(box); | 167 | TakeCopyToInventory(0, box); |
144 | 168 | ||
145 | } | 169 | } |
146 | 170 | ||
@@ -218,14 +242,14 @@ namespace OpenSim.Tests.Permissions | |||
218 | return so; | 242 | return so; |
219 | } | 243 | } |
220 | 244 | ||
221 | public void TakeCopyToInventory(SceneObjectGroup sog) | 245 | public void TakeCopyToInventory(int userIndex, SceneObjectGroup sog) |
222 | { | 246 | { |
223 | InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, sog.OwnerID, "Objects"); | 247 | InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[userIndex].UUID, "Objects"); |
224 | Assert.That(objsFolder, Is.Not.Null); | 248 | Assert.That(objsFolder, Is.Not.Null); |
225 | 249 | ||
226 | List<uint> localIds = new List<uint>(); localIds.Add(sog.LocalId); | 250 | List<uint> localIds = new List<uint>(); localIds.Add(sog.LocalId); |
227 | // This is an async operation | 251 | // This is an async operation |
228 | m_Scene.DeRezObjects((IClientAPI)m_Avatars[0].ClientView, localIds, sog.UUID, DeRezAction.TakeCopy, objsFolder.ID); | 252 | m_Scene.DeRezObjects((IClientAPI)m_Avatars[userIndex].ClientView, localIds, m_Avatars[userIndex].UUID, DeRezAction.TakeCopy, objsFolder.ID); |
229 | } | 253 | } |
230 | 254 | ||
231 | public InventoryItemBase GetItemFromInventory(UUID userID, string folderName, string itemName) | 255 | public InventoryItemBase GetItemFromInventory(UUID userID, string folderName, string itemName) |
@@ -262,6 +286,26 @@ namespace OpenSim.Tests.Permissions | |||
262 | return clone; | 286 | return clone; |
263 | } | 287 | } |
264 | 288 | ||
289 | public void DeleteObjectsFolders() | ||
290 | { | ||
291 | // Delete everything in A2 and A3's Objects folders, so we can restart | ||
292 | for (int i = 1; i < 3; i++) | ||
293 | { | ||
294 | InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[i].UUID, "Objects"); | ||
295 | Assert.That(objsFolder, Is.Not.Null); | ||
296 | |||
297 | List<InventoryItemBase> items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID); | ||
298 | List<UUID> ids = new List<UUID>(); | ||
299 | foreach (InventoryItemBase it in items) | ||
300 | ids.Add(it.ID); | ||
301 | |||
302 | Common.TheScene.InventoryService.DeleteItems(Common.TheAvatars[i].UUID, ids); | ||
303 | items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID); | ||
304 | Assert.That(items.Count, Is.EqualTo(0), "A" + (i + 1)); | ||
305 | } | ||
306 | |||
307 | } | ||
308 | |||
265 | public string IdStr(InventoryItemBase item) | 309 | public string IdStr(InventoryItemBase item) |
266 | { | 310 | { |
267 | return item.Owner.ToString().Substring(34) + " : " + item.Name; | 311 | return item.Owner.ToString().Substring(34) + " : " + item.Name; |
diff --git a/OpenSim/Tests/Permissions/DirectTransferTests.cs b/OpenSim/Tests/Permissions/DirectTransferTests.cs index 3ca711a..c68bbdf 100644 --- a/OpenSim/Tests/Permissions/DirectTransferTests.cs +++ b/OpenSim/Tests/Permissions/DirectTransferTests.cs | |||
@@ -25,20 +25,10 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using Nini.Config; | ||
33 | using NUnit.Framework; | 28 | using NUnit.Framework; |
34 | using OpenMetaverse; | 29 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Scenes; | 31 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Region.CoreModules.World.Permissions; | ||
38 | using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer; | ||
39 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | ||
40 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using OpenSim.Tests.Common; | 32 | using OpenSim.Tests.Common; |
43 | using PermissionMask = OpenSim.Framework.PermissionMask; | 33 | using PermissionMask = OpenSim.Framework.PermissionMask; |
44 | 34 | ||
@@ -54,6 +44,7 @@ namespace OpenSim.Tests.Permissions | |||
54 | [SetUp] | 44 | [SetUp] |
55 | public void SetUp() | 45 | public void SetUp() |
56 | { | 46 | { |
47 | Common.TheInstance.DeleteObjectsFolders(); | ||
57 | } | 48 | } |
58 | 49 | ||
59 | /// <summary> | 50 | /// <summary> |
diff --git a/OpenSim/Tests/Permissions/IndirectTransferTests.cs b/OpenSim/Tests/Permissions/IndirectTransferTests.cs new file mode 100644 index 0000000..7d8027f --- /dev/null +++ b/OpenSim/Tests/Permissions/IndirectTransferTests.cs | |||
@@ -0,0 +1,123 @@ | |||
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.Collections.Generic; | ||
29 | using System.Threading; | ||
30 | using NUnit.Framework; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.Framework.Scenes; | ||
34 | using OpenSim.Tests.Common; | ||
35 | using PermissionMask = OpenSim.Framework.PermissionMask; | ||
36 | |||
37 | namespace OpenSim.Tests.Permissions | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// Basic scene object tests (create, read and delete but not update). | ||
41 | /// </summary> | ||
42 | [TestFixture] | ||
43 | public class IndirectTransferTests | ||
44 | { | ||
45 | |||
46 | [SetUp] | ||
47 | public void SetUp() | ||
48 | { | ||
49 | Common.TheInstance.DeleteObjectsFolders(); | ||
50 | } | ||
51 | |||
52 | /// <summary> | ||
53 | /// Test giving simple objecta with various combinations of next owner perms. | ||
54 | /// </summary> | ||
55 | [Test] | ||
56 | public void SimpleTakeCopy() | ||
57 | { | ||
58 | TestHelpers.InMethod(); | ||
59 | |||
60 | // The Objects folder of A2 | ||
61 | InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[1].UUID, "Objects"); | ||
62 | |||
63 | // C, CT, MC, MCT, MT, T | ||
64 | string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T" }; | ||
65 | PermissionMask[] perms = new PermissionMask[6] { | ||
66 | PermissionMask.Copy, | ||
67 | PermissionMask.Copy | PermissionMask.Transfer, | ||
68 | PermissionMask.Modify | PermissionMask.Copy, | ||
69 | PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer, | ||
70 | PermissionMask.Modify | PermissionMask.Transfer, | ||
71 | PermissionMask.Transfer | ||
72 | }; | ||
73 | |||
74 | // Try A2 takes copies of objects that cannot be copied. | ||
75 | for (int i = 0; i < 6; i++) | ||
76 | TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]); | ||
77 | Thread.Sleep(5000); | ||
78 | |||
79 | List<InventoryItemBase> items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID); | ||
80 | Assert.That(items.Count, Is.EqualTo(0)); | ||
81 | |||
82 | // A1 makes the objects copyable | ||
83 | for (int i = 0; i < 6; i++) | ||
84 | MakeCopyable(Common.TheScene.GetSceneObjectGroups(), names[i]); | ||
85 | |||
86 | // Try A2 takes copies of objects that can be copied. | ||
87 | for (int i = 0; i < 6; i++) | ||
88 | TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]); | ||
89 | Thread.Sleep(5000); | ||
90 | |||
91 | items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID); | ||
92 | Assert.That(items.Count, Is.EqualTo(6)); | ||
93 | |||
94 | for (int i = 0; i < 6; i++) | ||
95 | { | ||
96 | InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", names[i]); | ||
97 | Assert.That(item, Is.Not.Null); | ||
98 | Common.TheInstance.AssertPermissions(perms[i], (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item)); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | private void TakeOneBox(List<SceneObjectGroup> objs, string name, PermissionMask mask) | ||
103 | { | ||
104 | SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID); | ||
105 | Assert.That(box, Is.Not.Null, name); | ||
106 | |||
107 | // A2's inventory (index 1) | ||
108 | Common.TheInstance.TakeCopyToInventory(1, box); | ||
109 | } | ||
110 | |||
111 | private void MakeCopyable(List<SceneObjectGroup> objs, string name) | ||
112 | { | ||
113 | SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID); | ||
114 | Assert.That(box, Is.Not.Null, name); | ||
115 | |||
116 | // field = 8 is Everyone | ||
117 | // set = 1 means add the permission; set = 0 means remove permission | ||
118 | Common.TheScene.HandleObjectPermissionsUpdate((IClientAPI)Common.TheAvatars[0].ClientView, Common.TheAvatars[0].UUID, | ||
119 | Common.TheAvatars[0].ControllingClient.SessionId, 8, box.LocalId, (uint)PermissionMask.Copy, 1); | ||
120 | Common.TheInstance.PrintPerms(box); | ||
121 | } | ||
122 | } | ||
123 | } \ No newline at end of file | ||