diff options
author | Diva Canto | 2017-05-01 14:58:03 -0700 |
---|---|---|
committer | Diva Canto | 2017-05-01 14:58:03 -0700 |
commit | 1ca2a7937ebf246bb2ebe4b1355f8068912ea4b0 (patch) | |
tree | 997eaca547303eb70a4c0591b674044c9a435ebd /OpenSim/Tests | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-1ca2a7937ebf246bb2ebe4b1355f8068912ea4b0.zip opensim-SC-1ca2a7937ebf246bb2ebe4b1355f8068912ea4b0.tar.gz opensim-SC-1ca2a7937ebf246bb2ebe4b1355f8068912ea4b0.tar.bz2 opensim-SC-1ca2a7937ebf246bb2ebe4b1355f8068912ea4b0.tar.xz |
Permissions tests: added test with 2 direct transfers with permission changes in between (in inventory)
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r-- | OpenSim/Tests/Permissions/Common.cs | 64 | ||||
-rw-r--r-- | OpenSim/Tests/Permissions/DirectTransferTests.cs | 51 |
2 files changed, 110 insertions, 5 deletions
diff --git a/OpenSim/Tests/Permissions/Common.cs b/OpenSim/Tests/Permissions/Common.cs index 63b91b6..84dadf2 100644 --- a/OpenSim/Tests/Permissions/Common.cs +++ b/OpenSim/Tests/Permissions/Common.cs | |||
@@ -93,11 +93,16 @@ namespace OpenSim.Tests.Permissions | |||
93 | AddA1Object("Box MT", 14, PermissionMask.Modify | PermissionMask.Transfer); | 93 | AddA1Object("Box MT", 14, PermissionMask.Modify | PermissionMask.Transfer); |
94 | AddA1Object("Box T", 15, PermissionMask.Transfer); | 94 | AddA1Object("Box T", 15, PermissionMask.Transfer); |
95 | 95 | ||
96 | // MCT-C | ||
97 | AddA1Object("Box MCT-C", 16, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer); | ||
98 | |||
96 | Thread.Sleep(5000); | 99 | Thread.Sleep(5000); |
97 | 100 | ||
98 | InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[0].UUID, "Objects"); | 101 | InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, m_Avatars[0].UUID, "Objects"); |
99 | List<InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(m_Avatars[0].UUID, objsFolder.ID); | 102 | List<InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(m_Avatars[0].UUID, objsFolder.ID); |
100 | Assert.That(items.Count, Is.EqualTo(6)); | 103 | Assert.That(items.Count, Is.EqualTo(7)); |
104 | |||
105 | RevokePermission(0, "Box MCT-C", PermissionMask.Copy); | ||
101 | } | 106 | } |
102 | 107 | ||
103 | private ScenePresence AddScenePresence(string first, string last, UUID id) | 108 | private ScenePresence AddScenePresence(string first, string last, UUID id) |
@@ -139,6 +144,30 @@ namespace OpenSim.Tests.Permissions | |||
139 | 144 | ||
140 | } | 145 | } |
141 | 146 | ||
147 | public void RevokePermission(int ownerIndex, string name, PermissionMask perm) | ||
148 | { | ||
149 | InventoryItemBase item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name); | ||
150 | Assert.That(item, Is.Not.Null); | ||
151 | |||
152 | // Clone it, so to avoid aliasing -- just like the viewer does. | ||
153 | InventoryItemBase clone = Common.TheInstance.CloneInventoryItem(item); | ||
154 | // Revoke the permission in this copy | ||
155 | clone.NextPermissions &= ~(uint)perm; | ||
156 | Common.TheInstance.AssertPermissions((PermissionMask)clone.NextPermissions & ~perm, | ||
157 | (PermissionMask)clone.NextPermissions, Common.TheInstance.IdStr(clone)); | ||
158 | Assert.That(clone.ID == item.ID); | ||
159 | |||
160 | // Update properties of the item in inventory. This should affect the original item above. | ||
161 | Common.TheScene.UpdateInventoryItemAsset(m_Avatars[ownerIndex].ControllingClient, UUID.Zero, clone.ID, clone); | ||
162 | |||
163 | item = Common.TheInstance.GetItemFromInventory(m_Avatars[ownerIndex].UUID, "Objects", name); | ||
164 | Assert.That(item, Is.Not.Null); | ||
165 | Common.TheInstance.PrintPerms(item); | ||
166 | Common.TheInstance.AssertPermissions((PermissionMask)item.NextPermissions & ~perm, | ||
167 | (PermissionMask)item.NextPermissions, Common.TheInstance.IdStr(item)); | ||
168 | |||
169 | } | ||
170 | |||
142 | public void PrintPerms(SceneObjectGroup sog) | 171 | public void PrintPerms(SceneObjectGroup sog) |
143 | { | 172 | { |
144 | Console.WriteLine("SOG " + sog.Name + " (" + sog.OwnerID.ToString().Substring(34) + "): " + | 173 | Console.WriteLine("SOG " + sog.Name + " (" + sog.OwnerID.ToString().Substring(34) + "): " + |
@@ -210,6 +239,39 @@ namespace OpenSim.Tests.Permissions | |||
210 | return item; | 239 | return item; |
211 | } | 240 | } |
212 | 241 | ||
242 | public InventoryItemBase CloneInventoryItem(InventoryItemBase item) | ||
243 | { | ||
244 | InventoryItemBase clone = new InventoryItemBase(item.ID); | ||
245 | clone.Name = item.Name; | ||
246 | clone.Description = item.Description; | ||
247 | clone.AssetID = item.AssetID; | ||
248 | clone.AssetType = item.AssetType; | ||
249 | clone.BasePermissions = item.BasePermissions; | ||
250 | clone.CreatorId = item.CreatorId; | ||
251 | clone.CurrentPermissions = item.CurrentPermissions; | ||
252 | clone.EveryOnePermissions = item.EveryOnePermissions; | ||
253 | clone.Flags = item.Flags; | ||
254 | clone.Folder = item.Folder; | ||
255 | clone.GroupID = item.GroupID; | ||
256 | clone.GroupOwned = item.GroupOwned; | ||
257 | clone.GroupPermissions = item.GroupPermissions; | ||
258 | clone.InvType = item.InvType; | ||
259 | clone.NextPermissions = item.NextPermissions; | ||
260 | clone.Owner = item.Owner; | ||
261 | |||
262 | return clone; | ||
263 | } | ||
264 | |||
265 | public string IdStr(InventoryItemBase item) | ||
266 | { | ||
267 | return item.Owner.ToString().Substring(34) + " : " + item.Name; | ||
268 | } | ||
269 | |||
270 | public string IdStr(SceneObjectGroup sog) | ||
271 | { | ||
272 | return sog.OwnerID.ToString().Substring(34) + " : " + sog.Name; | ||
273 | } | ||
274 | |||
213 | public void GiveInventoryItem(UUID itemId, ScenePresence giverSp, ScenePresence receiverSp) | 275 | public void GiveInventoryItem(UUID itemId, ScenePresence giverSp, ScenePresence receiverSp) |
214 | { | 276 | { |
215 | TestClient giverClient = (TestClient)giverSp.ControllingClient; | 277 | TestClient giverClient = (TestClient)giverSp.ControllingClient; |
diff --git a/OpenSim/Tests/Permissions/DirectTransferTests.cs b/OpenSim/Tests/Permissions/DirectTransferTests.cs index e103d01..3ca711a 100644 --- a/OpenSim/Tests/Permissions/DirectTransferTests.cs +++ b/OpenSim/Tests/Permissions/DirectTransferTests.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Tests.Permissions | |||
48 | /// Basic scene object tests (create, read and delete but not update). | 48 | /// Basic scene object tests (create, read and delete but not update). |
49 | /// </summary> | 49 | /// </summary> |
50 | [TestFixture] | 50 | [TestFixture] |
51 | public class DirectTransferTests | 51 | public class DirectTransferTests |
52 | { | 52 | { |
53 | 53 | ||
54 | [SetUp] | 54 | [SetUp] |
@@ -57,15 +57,15 @@ namespace OpenSim.Tests.Permissions | |||
57 | } | 57 | } |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Test giving a C object. | 60 | /// Test giving simple objecta with various combinations of next owner perms. |
61 | /// </summary> | 61 | /// </summary> |
62 | [Test] | 62 | [Test] |
63 | public void TestGiveCBox() | 63 | public void TestGiveBox() |
64 | { | 64 | { |
65 | TestHelpers.InMethod(); | 65 | TestHelpers.InMethod(); |
66 | 66 | ||
67 | // C, CT, MC, MCT, MT, T | 67 | // C, CT, MC, MCT, MT, T |
68 | string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T"}; | 68 | string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T" }; |
69 | PermissionMask[] perms = new PermissionMask[6] { | 69 | PermissionMask[] perms = new PermissionMask[6] { |
70 | PermissionMask.Copy, | 70 | PermissionMask.Copy, |
71 | PermissionMask.Copy | PermissionMask.Transfer, | 71 | PermissionMask.Copy | PermissionMask.Transfer, |
@@ -108,5 +108,48 @@ namespace OpenSim.Tests.Permissions | |||
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | /// <summary> | ||
112 | /// Test giving simple objecta with variour combinations of next owner perms. | ||
113 | /// </summary> | ||
114 | [Test] | ||
115 | public void TestDoubleGiveWithChange() | ||
116 | { | ||
117 | TestHelpers.InMethod(); | ||
118 | |||
119 | string name = "Box MCT-C"; | ||
120 | InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[0].UUID, "Objects", name); | ||
121 | |||
122 | // Now give the item to A2. We give the original item, not a clone. | ||
123 | // The giving methods are supposed to duplicate it. | ||
124 | Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[0], Common.TheAvatars[1]); | ||
125 | |||
126 | item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name); | ||
127 | |||
128 | // Check the receiver | ||
129 | Common.TheInstance.PrintPerms(item); | ||
130 | Common.TheInstance.AssertPermissions(PermissionMask.Modify | PermissionMask.Transfer, | ||
131 | (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item)); | ||
132 | |||
133 | // --------------------------- | ||
134 | // Second transfer | ||
135 | //---------------------------- | ||
136 | |||
137 | // A2 revokes M | ||
138 | Common.TheInstance.RevokePermission(1, name, PermissionMask.Modify); | ||
139 | |||
140 | item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name); | ||
141 | |||
142 | // Now give the item to A3. We give the original item, not a clone. | ||
143 | // The giving methods are supposed to duplicate it. | ||
144 | Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[1], Common.TheAvatars[2]); | ||
145 | |||
146 | item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[2].UUID, "Objects", name); | ||
147 | |||
148 | // Check the receiver | ||
149 | Common.TheInstance.PrintPerms(item); | ||
150 | Common.TheInstance.AssertPermissions(PermissionMask.Transfer, | ||
151 | (PermissionMask)item.BasePermissions, Common.TheInstance.IdStr(item)); | ||
152 | |||
153 | } | ||
111 | } | 154 | } |
112 | } \ No newline at end of file | 155 | } \ No newline at end of file |