From 0683cf6e0d541571d04d6511dc0ecabb17dd1e1e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Sep 2009 18:03:49 +0100 Subject: Add test to check behaviour if an iar is loaded where no user profile exists for the creators Disable generation of temporary profiles for now, instead record loading user as creator --- .../Archiver/InventoryArchiveReadRequest.cs | 2 + .../Archiver/Tests/InventoryArchiverTests.cs | 79 +++++++++++++++++++++- 2 files changed, 78 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 50c0f93..2a1c82e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -177,6 +177,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); if (UUID.Zero != ospResolvedId) item.CreatorIdAsUuid = ospResolvedId; + else + item.CreatorIdAsUuid = m_userInfo.UserProfile.ID; item.Owner = m_userInfo.UserProfile.ID; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 384a1f2..9c5f8f3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests public void TestSaveIarV0_1() { TestHelper.InMethod(); - log4net.Config.XmlConfigurator.Configure(); + //log4net.Config.XmlConfigurator.Configure(); InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); @@ -202,12 +202,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where /// an account exists with the creator name. /// + /// + /// This test also does some deeper probing of loading into nested inventory structures [Test] public void TestLoadIarV0_1ExistingUsers() { TestHelper.InMethod(); - log4net.Config.XmlConfigurator.Configure(); + //log4net.Config.XmlConfigurator.Configure(); string userFirstName = "Mr"; string userLastName = "Tiddles"; @@ -291,6 +293,77 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where + /// embedded creators do not exist in the system + /// + /// + /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature + /// (as tested in the a later commented out test) + [Test] + public void TestLoadIarV0_1AbsentUsers() + { + TestHelper.InMethod(); + + log4net.Config.XmlConfigurator.Configure(); + + string userFirstName = "Charlie"; + string userLastName = "Chan"; + UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999"); + string userItemCreatorFirstName = "Bat"; + string userItemCreatorLastName = "Man"; + //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888"); + + string itemName = "b.lsl"; + string archiveItemName + = string.Format("{0}{1}{2}", itemName, "_", UUID.Random()); + + MemoryStream archiveWriteStream = new MemoryStream(); + TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); + + InventoryItemBase item1 = new InventoryItemBase(); + item1.Name = itemName; + item1.AssetID = UUID.Random(); + item1.GroupID = UUID.Random(); + item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); + //item1.CreatorId = userUuid.ToString(); + //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; + item1.Owner = UUID.Zero; + + string item1FileName + = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); + tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); + tar.Close(); + + MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); + SerialiserModule serialiserModule = new SerialiserModule(); + InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); + + // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene + Scene scene = SceneSetupHelpers.SetupScene("inventory"); + IUserAdminService userAdminService = scene.CommsManager.UserAdminService; + + SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); + userAdminService.AddUser( + userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); + + archiverModule.DearchiveInventory(userFirstName, userLastName, "/", archiveReadStream); + + CachedUserInfo userInfo + = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); + + InventoryItemBase foundItem1 + = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); + + Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); +// Assert.That( +// foundItem1.CreatorId, Is.EqualTo(userUuid), +// "Loaded item non-uuid creator doesn't match that of the loading user"); + Assert.That( + foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), + "Loaded item uuid creator doesn't match that of the loading user"); + } + + /// + /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where /// no account exists with the creator name /// /// Disabled since temporary profiles have not yet been implemented. @@ -376,7 +449,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests { TestHelper.InMethod(); - log4net.Config.XmlConfigurator.Configure(); + //log4net.Config.XmlConfigurator.Configure(); Scene scene = SceneSetupHelpers.SetupScene("inventory"); CommunicationsManager commsManager = scene.CommsManager; -- cgit v1.1