aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests
diff options
context:
space:
mode:
authorDiva Canto2017-05-01 10:09:31 -0700
committerDiva Canto2017-05-01 10:09:31 -0700
commit9c6dd5d967d44d2eb222a2382d9f19572b871d87 (patch)
tree03d927d37f1320cfaff4bcd4862f971e77f48ee2 /OpenSim/Tests
parentInitial commit of the emerging test suite for permissions and more. (diff)
downloadopensim-SC_OLD-9c6dd5d967d44d2eb222a2382d9f19572b871d87.zip
opensim-SC_OLD-9c6dd5d967d44d2eb222a2382d9f19572b871d87.tar.gz
opensim-SC_OLD-9c6dd5d967d44d2eb222a2382d9f19572b871d87.tar.bz2
opensim-SC_OLD-9c6dd5d967d44d2eb222a2382d9f19572b871d87.tar.xz
Perms test framework: make a lot of things more generic.
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r--OpenSim/Tests/Permissions/Common.cs259
-rw-r--r--OpenSim/Tests/Permissions/DirectTransferTests.cs208
2 files changed, 293 insertions, 174 deletions
diff --git a/OpenSim/Tests/Permissions/Common.cs b/OpenSim/Tests/Permissions/Common.cs
new file mode 100644
index 0000000..63b91b6
--- /dev/null
+++ b/OpenSim/Tests/Permissions/Common.cs
@@ -0,0 +1,259 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using System.Threading;
5using Nini.Config;
6using NUnit.Framework;
7using OpenMetaverse;
8using OpenSim.Framework;
9using OpenSim.Region.Framework.Scenes;
10using OpenSim.Region.CoreModules.World.Permissions;
11using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer;
12using OpenSim.Region.CoreModules.Framework.InventoryAccess;
13using OpenSim.Region.Framework.Scenes.Serialization;
14using OpenSim.Services.Interfaces;
15using OpenSim.Tests.Common;
16using PermissionMask = OpenSim.Framework.PermissionMask;
17
18namespace OpenSim.Tests.Permissions
19{
20 [SetUpFixture]
21 public class Common : OpenSimTestCase
22 {
23 public static Common TheInstance;
24
25 public static TestScene TheScene
26 {
27 get { return TheInstance.m_Scene; }
28 }
29
30 public static ScenePresence[] TheAvatars
31 {
32 get { return TheInstance.m_Avatars; }
33 }
34
35 private static string Perms = "Owner: {0}; Group: {1}; Everyone: {2}; Next: {3}";
36 private TestScene m_Scene;
37 private ScenePresence[] m_Avatars = new ScenePresence[3];
38
39 [SetUp]
40 public override void SetUp()
41 {
42 if (TheInstance == null)
43 TheInstance = this;
44
45 base.SetUp();
46 TestHelpers.EnableLogging();
47
48 IConfigSource config = new IniConfigSource();
49 config.AddConfig("Messaging");
50 config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule");
51 config.AddConfig("Modules");
52 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
53 config.AddConfig("InventoryService");
54 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService");
55 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin");
56
57 m_Scene = new SceneHelpers().SetupScene("Test", UUID.Random(), 1000, 1000, config);
58 // Add modules
59 SceneHelpers.SetupSceneModules(m_Scene, config, new DefaultPermissionsModule(), new InventoryTransferModule(), new BasicInventoryAccessModule());
60
61 SetUpBasicEnvironment();
62 }
63
64 /// <summary>
65 /// The basic environment consists of:
66 /// - 3 avatars: A1, A2, A3
67 /// - 6 simple boxes inworld belonging to A0 and with Next Owner perms:
68 /// C, CT, MC, MCT, MT, T
69 /// - 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
71 /// with C removed in inventory. This one is called MCT-C
72 /// </summary>
73 private void SetUpBasicEnvironment()
74 {
75 Console.WriteLine("===> SetUpBasicEnvironment <===");
76
77 // Add 3 avatars
78 for (int i = 0; i < 3; i++)
79 {
80 UUID id = TestHelpers.ParseTail(i + 1);
81
82 m_Avatars[i] = AddScenePresence("Bot", "Bot_" + (i+1), id);
83 Assert.That(m_Avatars[i], Is.Not.Null);
84 Assert.That(m_Avatars[i].IsChildAgent, Is.False);
85 Assert.That(m_Avatars[i].UUID, Is.EqualTo(id));
86 Assert.That(m_Scene.GetScenePresences().Count, Is.EqualTo(i + 1));
87 }
88
89 AddA1Object("Box C", 10, PermissionMask.Copy);
90 AddA1Object("Box CT", 11, PermissionMask.Copy | PermissionMask.Transfer);
91 AddA1Object("Box MC", 12, PermissionMask.Modify | PermissionMask.Copy);
92 AddA1Object("Box MCT", 13, PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer);
93 AddA1Object("Box MT", 14, PermissionMask.Modify | PermissionMask.Transfer);
94 AddA1Object("Box T", 15, PermissionMask.Transfer);
95
96 Thread.Sleep(5000);
97
98 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);
100 Assert.That(items.Count, Is.EqualTo(6));
101 }
102
103 private ScenePresence AddScenePresence(string first, string last, UUID id)
104 {
105 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_Scene, first, last, id, "pw");
106 ScenePresence sp = SceneHelpers.AddScenePresence(m_Scene, id);
107 Assert.That(m_Scene.AuthenticateHandler.GetAgentCircuitData(id), Is.Not.Null);
108
109 return sp;
110 }
111
112 private void AddA1Object(string name, int suffix, PermissionMask nextOwnerPerms)
113 {
114 // Create a Box. Default permissions are just T
115 SceneObjectGroup box = AddSceneObject(name, suffix, 1, m_Avatars[0].UUID);
116 Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Copy) == 0);
117 Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Modify) == 0);
118 Assert.True((box.RootPart.NextOwnerMask & (int)PermissionMask.Transfer) != 0);
119
120 // field = 16 is NextOwner
121 // set = 1 means add the permission; set = 0 means remove permission
122
123 if ((nextOwnerPerms & PermissionMask.Copy) != 0)
124 m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID,
125 ((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, box.LocalId, (uint)PermissionMask.Copy, 1);
126
127 if ((nextOwnerPerms & PermissionMask.Modify) != 0)
128 m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID,
129 ((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, box.LocalId, (uint)PermissionMask.Modify, 1);
130
131 if ((nextOwnerPerms & PermissionMask.Transfer) == 0)
132 m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID,
133 ((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, box.LocalId, (uint)PermissionMask.Transfer, 0);
134
135 PrintPerms(box);
136 AssertPermissions(nextOwnerPerms, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name);
137
138 TakeCopyToInventory(box);
139
140 }
141
142 public void PrintPerms(SceneObjectGroup sog)
143 {
144 Console.WriteLine("SOG " + sog.Name + " (" + sog.OwnerID.ToString().Substring(34) + "): " +
145 String.Format(Perms, (PermissionMask)sog.EffectiveOwnerPerms,
146 (PermissionMask)sog.EffectiveGroupPerms, (PermissionMask)sog.EffectiveEveryOnePerms, (PermissionMask)sog.RootPart.NextOwnerMask));
147
148 }
149
150 public void PrintPerms(InventoryItemBase item)
151 {
152 Console.WriteLine("Inv " + item.Name + " (" + item.Owner.ToString().Substring(34) + "): " +
153 String.Format(Perms, (PermissionMask)item.BasePermissions,
154 (PermissionMask)item.GroupPermissions, (PermissionMask)item.EveryOnePermissions, (PermissionMask)item.NextPermissions));
155
156 }
157
158 public void AssertPermissions(PermissionMask desired, PermissionMask actual, string message)
159 {
160 if ((desired & PermissionMask.Copy) != 0)
161 Assert.True((actual & PermissionMask.Copy) != 0, message);
162 else
163 Assert.True((actual & PermissionMask.Copy) == 0, message);
164
165 if ((desired & PermissionMask.Modify) != 0)
166 Assert.True((actual & PermissionMask.Modify) != 0, message);
167 else
168 Assert.True((actual & PermissionMask.Modify) == 0, message);
169
170 if ((desired & PermissionMask.Transfer) != 0)
171 Assert.True((actual & PermissionMask.Transfer) != 0, message);
172 else
173 Assert.True((actual & PermissionMask.Transfer) == 0, message);
174
175 }
176
177 public SceneObjectGroup AddSceneObject(string name, int suffix, int partsToTestCount, UUID ownerID)
178 {
179 SceneObjectGroup so = SceneHelpers.CreateSceneObject(partsToTestCount, ownerID, name, suffix);
180 so.Name = name;
181 so.Description = name;
182
183 Assert.That(m_Scene.AddNewSceneObject(so, false), Is.True);
184 SceneObjectGroup retrievedSo = m_Scene.GetSceneObjectGroup(so.UUID);
185
186 // If the parts have the same UUID then we will consider them as one and the same
187 Assert.That(retrievedSo.PrimCount, Is.EqualTo(partsToTestCount));
188
189 return so;
190 }
191
192 public void TakeCopyToInventory(SceneObjectGroup sog)
193 {
194 InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, sog.OwnerID, "Objects");
195 Assert.That(objsFolder, Is.Not.Null);
196
197 List<uint> localIds = new List<uint>(); localIds.Add(sog.LocalId);
198 // This is an async operation
199 m_Scene.DeRezObjects((IClientAPI)m_Avatars[0].ClientView, localIds, sog.UUID, DeRezAction.TakeCopy, objsFolder.ID);
200 }
201
202 public InventoryItemBase GetItemFromInventory(UUID userID, string folderName, string itemName)
203 {
204 InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, userID, folderName);
205 Assert.That(objsFolder, Is.Not.Null);
206 List<InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(userID, objsFolder.ID);
207 InventoryItemBase item = items.Find(i => i.Name == itemName);
208 Assert.That(item, Is.Not.Null);
209
210 return item;
211 }
212
213 public void GiveInventoryItem(UUID itemId, ScenePresence giverSp, ScenePresence receiverSp)
214 {
215 TestClient giverClient = (TestClient)giverSp.ControllingClient;
216 TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
217
218 UUID initialSessionId = TestHelpers.ParseTail(0x10);
219 byte[] giveImBinaryBucket = new byte[17];
220 byte[] itemIdBytes = itemId.GetBytes();
221 Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
222
223 GridInstantMessage giveIm
224 = new GridInstantMessage(
225 m_Scene,
226 giverSp.UUID,
227 giverSp.Name,
228 receiverSp.UUID,
229 (byte)InstantMessageDialog.InventoryOffered,
230 false,
231 "inventory offered msg",
232 initialSessionId,
233 false,
234 Vector3.Zero,
235 giveImBinaryBucket,
236 true);
237
238 giverClient.HandleImprovedInstantMessage(giveIm);
239
240 // These details might not all be correct.
241 GridInstantMessage acceptIm
242 = new GridInstantMessage(
243 m_Scene,
244 receiverSp.UUID,
245 receiverSp.Name,
246 giverSp.UUID,
247 (byte)InstantMessageDialog.InventoryAccepted,
248 false,
249 "inventory accepted msg",
250 initialSessionId,
251 false,
252 Vector3.Zero,
253 null,
254 true);
255
256 receiverClient.HandleImprovedInstantMessage(acceptIm);
257 }
258 }
259}
diff --git a/OpenSim/Tests/Permissions/DirectTransferTests.cs b/OpenSim/Tests/Permissions/DirectTransferTests.cs
index 7716776..e103d01 100644
--- a/OpenSim/Tests/Permissions/DirectTransferTests.cs
+++ b/OpenSim/Tests/Permissions/DirectTransferTests.cs
@@ -48,205 +48,65 @@ 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 : OpenSimTestCase 51 public class DirectTransferTests
52 { 52 {
53 private static string Perms = "Owner: {0}; Group: {1}; Everyone: {2}; Next: {3}";
54 protected TestScene m_Scene;
55 private ScenePresence[] m_Avatars = new ScenePresence[3];
56 53
57 [SetUp] 54 [SetUp]
58 public override void SetUp() 55 public void SetUp()
59 { 56 {
60 base.SetUp();
61 TestHelpers.EnableLogging();
62
63 IConfigSource config = new IniConfigSource();
64 config.AddConfig("Messaging");
65 config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule");
66 config.AddConfig("Modules");
67 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
68 config.AddConfig("InventoryService");
69 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService");
70 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin");
71
72 m_Scene = new SceneHelpers().SetupScene("Test", UUID.Random(), 1000, 1000, config);
73 // Add modules
74 SceneHelpers.SetupSceneModules(m_Scene, config, new DefaultPermissionsModule(), new InventoryTransferModule(), new BasicInventoryAccessModule());
75
76 // Add 3 avatars
77 for (int i = 0; i < 3; i++)
78 {
79 UUID id = TestHelpers.ParseTail(i+1);
80
81 m_Avatars[i] = AddScenePresence("Bot", "Bot_" + i, id);
82 Assert.That(m_Avatars[i], Is.Not.Null);
83 Assert.That(m_Avatars[i].IsChildAgent, Is.False);
84 Assert.That(m_Avatars[i].UUID, Is.EqualTo(id));
85
86 Assert.That(m_Scene.GetScenePresences().Count, Is.EqualTo(i+1));
87 }
88 } 57 }
89 58
90 /// <summary> 59 /// <summary>
91 /// Test adding an object to a scene. 60 /// Test giving a C object.
92 /// </summary> 61 /// </summary>
93 [Test] 62 [Test]
94 public void TestGiveCBox() 63 public void TestGiveCBox()
95 { 64 {
96 TestHelpers.InMethod(); 65 TestHelpers.InMethod();
97 66
98 // Create a C Box 67 // C, CT, MC, MCT, MT, T
99 SceneObjectGroup boxC = AddSceneObject("Box C", 10, 1, m_Avatars[0].UUID); 68 string[] names = new string[6] { "Box C", "Box CT", "Box MC", "Box MCT", "Box MT", "Box T"};
100 69 PermissionMask[] perms = new PermissionMask[6] {
101 // field = 16 is NextOwner 70 PermissionMask.Copy,
102 // set = 1 means add the permission; set = 0 means remove permission 71 PermissionMask.Copy | PermissionMask.Transfer,
103 m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID, 72 PermissionMask.Modify | PermissionMask.Copy,
104 ((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, boxC.LocalId, (uint)PermissionMask.Copy, 1); 73 PermissionMask.Modify | PermissionMask.Copy | PermissionMask.Transfer,
105 74 PermissionMask.Modify | PermissionMask.Transfer,
106 m_Scene.HandleObjectPermissionsUpdate((IClientAPI)m_Avatars[0].ClientView, m_Avatars[0].UUID, 75 PermissionMask.Transfer
107 ((IClientAPI)(m_Avatars[0].ClientView)).SessionId, 16, boxC.LocalId, (uint)PermissionMask.Transfer, 0); 76 };
108 PrintPerms(boxC); 77
109 78 for (int i = 0; i < 6; i++)
110 Assert.True((boxC.RootPart.NextOwnerMask & (int)PermissionMask.Copy) != 0); 79 TestOneBox(names[i], perms[i]);
111 Assert.True((boxC.RootPart.NextOwnerMask & (int)PermissionMask.Modify) == 0);
112 Assert.True((boxC.RootPart.NextOwnerMask & (int)PermissionMask.Transfer) == 0);
113
114 InventoryItemBase item = TakeCopyToInventory(boxC);
115
116 GiveInventoryItem(item.ID, m_Avatars[0], m_Avatars[1]);
117
118 item = GetItemFromInventory(m_Avatars[1].UUID, "Objects", "Box C");
119
120 // Check the receiver
121 PrintPerms(item);
122 Assert.True((item.BasePermissions & (int)PermissionMask.Copy) != 0);
123 Assert.True((item.BasePermissions & (int)PermissionMask.Modify) == 0);
124 Assert.True((item.BasePermissions & (int)PermissionMask.Transfer) == 0);
125
126 // Rez it and check perms in scene too
127 m_Scene.RezObject(m_Avatars[1].ControllingClient, item.ID, UUID.Zero, Vector3.One, Vector3.Zero, UUID.Zero, 0, false, false, false, UUID.Zero);
128 Assert.That(m_Scene.GetSceneObjectGroups().Count, Is.EqualTo(2));
129 SceneObjectGroup copyBoxC = m_Scene.GetSceneObjectGroups().Find(sog => sog.OwnerID == m_Avatars[1].UUID);
130 PrintPerms(copyBoxC);
131 Assert.That(copyBoxC, Is.Not.Null);
132
133 }
134
135 #region Helper Functions
136
137 private void PrintPerms(SceneObjectGroup sog)
138 {
139 Console.WriteLine("SOG " + sog.Name + ": " + String.Format(Perms, (PermissionMask)sog.EffectiveOwnerPerms,
140 (PermissionMask)sog.EffectiveGroupPerms, (PermissionMask)sog.EffectiveEveryOnePerms, (PermissionMask)sog.RootPart.NextOwnerMask));
141
142 }
143
144 private void PrintPerms(InventoryItemBase item)
145 {
146 Console.WriteLine("Inv " + item.Name + ": " + String.Format(Perms, (PermissionMask)item.BasePermissions,
147 (PermissionMask)item.GroupPermissions, (PermissionMask)item.EveryOnePermissions, (PermissionMask)item.NextPermissions));
148
149 } 80 }
150 81
151 private ScenePresence AddScenePresence(string first, string last, UUID id) 82 private void TestOneBox(string name, PermissionMask mask)
152 { 83 {
153 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_Scene, first, last, id, "pw"); 84 InventoryItemBase item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[0].UUID, "Objects", name);
154 ScenePresence sp = SceneHelpers.AddScenePresence(m_Scene, id);
155 Assert.That(m_Scene.AuthenticateHandler.GetAgentCircuitData(id), Is.Not.Null);
156
157 return sp;
158 }
159
160 private SceneObjectGroup AddSceneObject(string name, int suffix, int partsToTestCount, UUID ownerID)
161 {
162 TestHelpers.InMethod();
163
164 SceneObjectGroup so = SceneHelpers.CreateSceneObject(partsToTestCount, ownerID, name, suffix);
165 so.Name = name;
166 so.Description = name;
167
168 Assert.That(m_Scene.AddNewSceneObject(so, false), Is.True);
169 SceneObjectGroup retrievedSo = m_Scene.GetSceneObjectGroup(so.UUID);
170 85
171 // If the parts have the same UUID then we will consider them as one and the same 86 Common.TheInstance.GiveInventoryItem(item.ID, Common.TheAvatars[0], Common.TheAvatars[1]);
172 Assert.That(retrievedSo.PrimCount, Is.EqualTo(partsToTestCount));
173 87
174 return so; 88 item = Common.TheInstance.GetItemFromInventory(Common.TheAvatars[1].UUID, "Objects", name);
175 }
176 89
177 private InventoryItemBase TakeCopyToInventory(SceneObjectGroup sog) 90 // Check the receiver
178 { 91 Common.TheInstance.PrintPerms(item);
179 InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, sog.OwnerID, "Objects"); 92 Common.TheInstance.AssertPermissions(mask, (PermissionMask)item.BasePermissions, item.Owner.ToString().Substring(34) + " : " + item.Name);
180 Assert.That(objsFolder, Is.Not.Null);
181 93
182 List<uint> localIds = new List<uint>(); localIds.Add(sog.LocalId); 94 int nObjects = Common.TheScene.GetSceneObjectGroups().Count;
183 m_Scene.DeRezObjects((IClientAPI)m_Avatars[0].ClientView, localIds, sog.UUID, DeRezAction.TakeCopy, objsFolder.ID); 95 // Rez it and check perms in scene too
184 Thread.Sleep(5000); 96 Common.TheScene.RezObject(Common.TheAvatars[1].ControllingClient, item.ID, UUID.Zero, Vector3.One, Vector3.Zero, UUID.Zero, 0, false, false, false, UUID.Zero);
97 Assert.That(Common.TheScene.GetSceneObjectGroups().Count, Is.EqualTo(nObjects + 1));
185 98
186 List<InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(sog.OwnerID, objsFolder.ID); 99 SceneObjectGroup box = Common.TheScene.GetSceneObjectGroups().Find(sog => sog.OwnerID == Common.TheAvatars[1].UUID && sog.Name == name);
187 InventoryItemBase item = items.Find(i => i.Name == sog.Name); 100 Common.TheInstance.PrintPerms(box);
188 Assert.That(item, Is.Not.Null); 101 Assert.That(box, Is.Not.Null);
189 102
190 return item; 103 // Check Owner permissions
104 Common.TheInstance.AssertPermissions(mask, (PermissionMask)box.EffectiveOwnerPerms, box.OwnerID.ToString().Substring(34) + " : " + box.Name);
191 105
192 } 106 // Check Next Owner permissions
107 Common.TheInstance.AssertPermissions(mask, (PermissionMask)box.RootPart.NextOwnerMask, box.OwnerID.ToString().Substring(34) + " : " + box.Name);
193 108
194 private InventoryItemBase GetItemFromInventory(UUID userID, string folderName, string itemName)
195 {
196 InventoryFolderBase objsFolder = UserInventoryHelpers.GetInventoryFolder(m_Scene.InventoryService, userID, folderName);
197 Assert.That(objsFolder, Is.Not.Null);
198 List<InventoryItemBase> items = m_Scene.InventoryService.GetFolderItems(userID, objsFolder.ID);
199 InventoryItemBase item = items.Find(i => i.Name == itemName);
200 Assert.That(item, Is.Not.Null);
201
202 return item;
203 } 109 }
204 110
205 private void GiveInventoryItem(UUID itemId, ScenePresence giverSp, ScenePresence receiverSp)
206 {
207 TestClient giverClient = (TestClient)giverSp.ControllingClient;
208 TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
209
210 UUID initialSessionId = TestHelpers.ParseTail(0x10);
211 byte[] giveImBinaryBucket = new byte[17];
212 byte[] itemIdBytes = itemId.GetBytes();
213 Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
214
215 GridInstantMessage giveIm
216 = new GridInstantMessage(
217 m_Scene,
218 giverSp.UUID,
219 giverSp.Name,
220 receiverSp.UUID,
221 (byte)InstantMessageDialog.InventoryOffered,
222 false,
223 "inventory offered msg",
224 initialSessionId,
225 false,
226 Vector3.Zero,
227 giveImBinaryBucket,
228 true);
229
230 giverClient.HandleImprovedInstantMessage(giveIm);
231
232 // These details might not all be correct.
233 GridInstantMessage acceptIm
234 = new GridInstantMessage(
235 m_Scene,
236 receiverSp.UUID,
237 receiverSp.Name,
238 giverSp.UUID,
239 (byte)InstantMessageDialog.InventoryAccepted,
240 false,
241 "inventory accepted msg",
242 initialSessionId,
243 false,
244 Vector3.Zero,
245 null,
246 true);
247
248 receiverClient.HandleImprovedInstantMessage(acceptIm);
249 }
250 #endregion
251 } 111 }
252} \ No newline at end of file 112} \ No newline at end of file