From c56f928c804de01f523b23c519ada63475961f1c Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 29 Apr 2009 17:46:13 +0000 Subject: * Adjust load iar unit test to check load of items with creator names that exist in the system but which are not the loading user --- OpenSim/Framework/Communications/OspResolver.cs | 15 ++++++++++++-- .../Archiver/Tests/InventoryArchiverTests.cs | 24 +++++++++++++++------- 2 files changed, 30 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/OspResolver.cs b/OpenSim/Framework/Communications/OspResolver.cs index 708bb84..f246692 100644 --- a/OpenSim/Framework/Communications/OspResolver.cs +++ b/OpenSim/Framework/Communications/OspResolver.cs @@ -47,7 +47,18 @@ namespace OpenSim.Framework.Communications public const string OSPA_NAME_VALUE_SEPARATOR = " "; public const string OSPA_TUPLE_SEPARATOR = "|"; public static readonly char[] OSPA_TUPLE_SEPARATOR_ARRAY = OSPA_TUPLE_SEPARATOR.ToCharArray(); - public const string OSPA_KEY_VALUE_PAIR_SEPARATOR = "="; + public const string OSPA_PAIR_SEPARATOR = "="; + + /// + /// Make an OSPA given an avatar name + /// + /// + /// + public static string MakeOspa(string firstName, string lastName) + { + return + OSPA_PREFIX + OSPA_NAME_KEY + OSPA_PAIR_SEPARATOR + firstName + OSPA_NAME_VALUE_SEPARATOR + lastName; + } /// /// Resolve an osp string into the most suitable internal OpenSim identifier. @@ -73,7 +84,7 @@ namespace OpenSim.Framework.Communications foreach (string tuple in ospaTuples) { - int tupleSeparatorIndex = tuple.IndexOf(OSPA_TUPLE_SEPARATOR); + int tupleSeparatorIndex = tuple.IndexOf(OSPA_PAIR_SEPARATOR); if (tupleSeparatorIndex < 0) { diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 5ae1cbd..bdca84e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -198,16 +198,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests [Test] public void TestLoadIarV0p1() { - Console.WriteLine("Started TestLoadIarV0p1()"); + Console.WriteLine("Started {0}", MethodBase.GetCurrentMethod()); log4net.Config.XmlConfigurator.Configure(); string userFirstName = "Mr"; string userLastName = "Tiddles"; UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555"); + string user2FirstName = "Lord"; + string user2LastName = "Lucan"; + UUID user2Uuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); + string itemName = "b.lsl"; string archiveItemName - = string.Format("{0}{1}{2}", itemName, "_", UUID.Random()); + = string.Format("{0}{1}{2}", itemName, "_", UUID.Random()); MemoryStream archiveWriteStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); @@ -216,9 +220,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests item1.Name = itemName; item1.AssetID = UUID.Random(); item1.GroupID = UUID.Random(); - item1.CreatorId = userUuid.ToString(); + item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName); + //item1.CreatorId = userUuid.ToString(); //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; - item1.Owner = UUID.Parse(item1.CreatorId); + item1.Owner = UUID.Zero; string item1FileName = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); @@ -231,9 +236,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene Scene scene = SceneSetupHelpers.SetupScene(); + IUserAdminService userAdminService = scene.CommsManager.UserAdminService; + SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); - scene.CommsManager.UserAdminService.AddUser( + userAdminService.AddUser( userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); + userAdminService.AddUser( + user2FirstName, user2LastName, "hampshire", String.Empty, 1000, 1000, user2Uuid); + archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream); CachedUserInfo userInfo @@ -241,10 +251,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); // Currently, creator and ownership both revert to the loader - Assert.That(foundItem.CreatorId, Is.EqualTo(userUuid.ToString())); + Assert.That(foundItem.CreatorId, Is.EqualTo(user2Uuid.ToString())); Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); - Console.WriteLine("Finished TestLoadIarV0p1()"); + Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod()); } /// -- cgit v1.1