aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Permissions
diff options
context:
space:
mode:
authorDiva Canto2017-05-01 16:42:47 -0700
committerDiva Canto2017-05-01 16:42:47 -0700
commit3c43cdbbcc2687e2f5d4319c5c3c3cbad4930fab (patch)
tree8eafe90d31a23b255b474e01ef62a7148cdb8146 /OpenSim/Tests/Permissions
parentPermissions tests: added test with 2 direct transfers with permission changes... (diff)
downloadopensim-SC-3c43cdbbcc2687e2f5d4319c5c3c3cbad4930fab.zip
opensim-SC-3c43cdbbcc2687e2f5d4319c5c3c3cbad4930fab.tar.gz
opensim-SC-3c43cdbbcc2687e2f5d4319c5c3c3cbad4930fab.tar.bz2
opensim-SC-3c43cdbbcc2687e2f5d4319c5c3c3cbad4930fab.tar.xz
Added some indirect transfer tests -- Take Copy by another avatar
Diffstat (limited to 'OpenSim/Tests/Permissions')
-rw-r--r--OpenSim/Tests/Permissions/Common.cs40
-rw-r--r--OpenSim/Tests/Permissions/DirectTransferTests.cs10
-rw-r--r--OpenSim/Tests/Permissions/IndirectTransferTests.cs137
3 files changed, 169 insertions, 18 deletions
diff --git a/OpenSim/Tests/Permissions/Common.cs b/OpenSim/Tests/Permissions/Common.cs
index 84dadf2..e62991b 100644
--- a/OpenSim/Tests/Permissions/Common.cs
+++ b/OpenSim/Tests/Permissions/Common.cs
@@ -1,6 +1,31 @@
1using 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 */
27using System;
2using System.Collections.Generic; 28using System.Collections.Generic;
3using System.Reflection;
4using System.Threading; 29using System.Threading;
5using Nini.Config; 30using Nini.Config;
6using NUnit.Framework; 31using NUnit.Framework;
@@ -10,7 +35,6 @@ using OpenSim.Region.Framework.Scenes;
10using OpenSim.Region.CoreModules.World.Permissions; 35using OpenSim.Region.CoreModules.World.Permissions;
11using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer; 36using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer;
12using OpenSim.Region.CoreModules.Framework.InventoryAccess; 37using OpenSim.Region.CoreModules.Framework.InventoryAccess;
13using OpenSim.Region.Framework.Scenes.Serialization;
14using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
15using OpenSim.Tests.Common; 39using OpenSim.Tests.Common;
16using PermissionMask = OpenSim.Framework.PermissionMask; 40using 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)
diff --git a/OpenSim/Tests/Permissions/DirectTransferTests.cs b/OpenSim/Tests/Permissions/DirectTransferTests.cs
index 3ca711a..3b711a1 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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using Nini.Config;
33using NUnit.Framework; 28using NUnit.Framework;
34using OpenMetaverse; 29using OpenMetaverse;
35using OpenSim.Framework; 30using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes; 31using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.CoreModules.World.Permissions;
38using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer;
39using OpenSim.Region.CoreModules.Framework.InventoryAccess;
40using OpenSim.Region.Framework.Scenes.Serialization;
41using OpenSim.Services.Interfaces;
42using OpenSim.Tests.Common; 32using OpenSim.Tests.Common;
43using PermissionMask = OpenSim.Framework.PermissionMask; 33using PermissionMask = OpenSim.Framework.PermissionMask;
44 34
diff --git a/OpenSim/Tests/Permissions/IndirectTransferTests.cs b/OpenSim/Tests/Permissions/IndirectTransferTests.cs
new file mode 100644
index 0000000..6a6ba2f
--- /dev/null
+++ b/OpenSim/Tests/Permissions/IndirectTransferTests.cs
@@ -0,0 +1,137 @@
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
28using System.Collections.Generic;
29using System.Threading;
30using NUnit.Framework;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Tests.Common;
35using PermissionMask = OpenSim.Framework.PermissionMask;
36
37namespace 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 // Delete everything in A2 and A3's Objects folders from previous tests
50 for (int i = 1; i < 3; i++)
51 {
52 InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[i].UUID, "Objects");
53 Assert.That(objsFolder, Is.Not.Null);
54
55 List<InventoryItemBase> items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID);
56 List<UUID> ids = new List<UUID>();
57 foreach (InventoryItemBase it in items)
58 ids.Add(it.ID);
59
60 Common.TheScene.InventoryService.DeleteItems(Common.TheAvatars[i].UUID, ids);
61 items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[i].UUID, objsFolder.ID);
62 Assert.That(items.Count, Is.EqualTo(0), "A" + (i+1));
63 }
64 }
65
66 /// <summary>
67 /// Test giving simple objecta with various combinations of next owner perms.
68 /// </summary>
69 [Test]
70 public void SimpleTakeCopy()
71 {
72 TestHelpers.InMethod();
73
74 // The Objects folder of A2
75 InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(Common.TheScene.InventoryService, Common.TheAvatars[1].UUID, "Objects");
76
77 // C, CT, MC, MCT, MT, T
78 string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T" };
79 PermissionMask[] perms = new PermissionMask[6] {
80 PermissionMask.Copy,
81 PermissionMask.Copy | PermissionMask.Transfer,
82 PermissionMask.Modify | PermissionMask.Copy,
83 PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer,
84 PermissionMask.Modify | PermissionMask.Transfer,
85 PermissionMask.Transfer
86 };
87
88 // Try A2 takes copies of objects that cannot be copied.
89 for (int i = 0; i < 6; i++)
90 TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]);
91 Thread.Sleep(5000);
92
93 List<InventoryItemBase> items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID);
94 Assert.That(items.Count, Is.EqualTo(0));
95
96 // A1 makes the objects copyable
97 for (int i = 0; i < 6; i++)
98 MakeCopyable(Common.TheScene.GetSceneObjectGroups(), names[i]);
99
100 // Try A2 takes copies of objects that can be copied.
101 for (int i = 0; i < 6; i++)
102 TakeOneBox(Common.TheScene.GetSceneObjectGroups(), names[i], perms[i]);
103 Thread.Sleep(5000);
104
105 items = Common.TheScene.InventoryService.GetFolderItems(Common.TheAvatars[1].UUID, objsFolder.ID);
106 Assert.That(items.Count, Is.EqualTo(6));
107
108 for (int i = 0; i < 6; i++)
109 {
110 InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", names[i]);
111 Assert.That(item, Is.Not.Null);
112 Common.TheInstance.AssertPermissions(perms[i], (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item));
113 }
114 }
115
116 private void TakeOneBox(List<SceneObjectGroup> objs, string name, PermissionMask mask)
117 {
118 SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID);
119 Assert.That(box, Is.Not.Null, name);
120
121 // A2's inventory (index 1)
122 Common.TheInstance.TakeCopyToInventory(1, box);
123 }
124
125 private void MakeCopyable(List<SceneObjectGroup> objs, string name)
126 {
127 SceneObjectGroup box = objs.Find(sog => sog.Name == name && sog.OwnerID == Common.TheAvatars[0].UUID);
128 Assert.That(box, Is.Not.Null, name);
129
130 // field = 8 is Everyone
131 // set = 1 means add the permission; set = 0 means remove permission
132 Common.TheScene.HandleObjectPermissionsUpdate((IClientAPI)Common.TheAvatars[0].ClientView, Common.TheAvatars[0].UUID,
133 Common.TheAvatars[0].ControllingClient.SessionId, 8, box.LocalId, (uint)PermissionMask.Copy, 1);
134 Common.TheInstance.PrintPerms(box);
135 }
136 }
137} \ No newline at end of file