aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs7
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs39
2 files changed, 42 insertions, 4 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs
index 0c83b26..4798dc2 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs
@@ -111,10 +111,9 @@ namespace OpenSim.Capabilities.Handlers
111 } 111 }
112 112
113 // Filter duplicate folder ids that bad viewers may send 113 // Filter duplicate folder ids that bad viewers may send
114 var unique = folders.GroupBy(f => f.folder_id).Select(n => n.First()); 114 if (folders.Find(f => f.folder_id == llsdRequest.folder_id) == null)
115 folders.Clear(); 115 folders.Add(llsdRequest);
116 foreach (var f in unique) 116
117 folders.Add(f);
118 } 117 }
119 118
120 if (folders.Count > 0) 119 if (folders.Count > 0)
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs
index d34423d..056b4db 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq; 30using System.Linq;
31using System.Net; 31using System.Net;
32using System.Text.RegularExpressions;
32using log4net; 33using log4net;
33using log4net.Config; 34using log4net.Config;
34using NUnit.Framework; 35using NUnit.Framework;
@@ -223,6 +224,44 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests
223 pos2 = llsdresponse.IndexOf("Link to Objects folder"); 224 pos2 = llsdresponse.IndexOf("Link to Objects folder");
224 Assert.Less(pos1, pos2, "Contents of source of folder link is after folder link"); 225 Assert.Less(pos1, pos2, "Contents of source of folder link is after folder link");
225 } 226 }
227
228 [Test]
229 public void Test_004_DuplicateFolders()
230 {
231 TestHelpers.InMethod();
232
233 FetchInvDescHandler handler = new FetchInvDescHandler(m_scene.InventoryService, null);
234 TestOSHttpRequest req = new TestOSHttpRequest();
235 TestOSHttpResponse resp = new TestOSHttpResponse();
236
237 string request = "<llsd><map><key>folders</key><array>";
238 request += "<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
239 request += m_rootFolderID;
240 request += "</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>";
241 request += "<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
242 request += m_notecardsFolder;
243 request += "</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>";
244 request += "<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
245 request += m_rootFolderID;
246 request += "</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>";
247 request += "<map><key>fetch_folders</key><integer>1</integer><key>fetch_items</key><boolean>1</boolean><key>folder_id</key><uuid>";
248 request += m_notecardsFolder;
249 request += "</uuid><key>owner_id</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>sort_order</key><integer>1</integer></map>";
250 request += "</array></map></llsd>";
251
252 string llsdresponse = handler.FetchInventoryDescendentsRequest(request, "/FETCH", string.Empty, req, resp);
253 Console.WriteLine(llsdresponse);
254
255 string root_folder = "<key>folder_id</key><uuid>" + m_rootFolderID + "</uuid>";
256 string notecards_folder = "<key>folder_id</key><uuid>" + m_notecardsFolder + "</uuid>";
257
258 Assert.That(llsdresponse.Contains(root_folder), "Missing root folder");
259 Assert.That(llsdresponse.Contains(notecards_folder), "Missing notecards folder");
260 int count = Regex.Matches(llsdresponse, root_folder).Count;
261 Assert.AreEqual(1, count, "More than 1 root folder in response");
262 count = Regex.Matches(llsdresponse, notecards_folder).Count;
263 Assert.AreEqual(2, count, "More than 1 notecards folder in response"); // Notecards will also be under root, so 2
264 }
226 } 265 }
227 266
228} \ No newline at end of file 267} \ No newline at end of file