예제 #1
0
        public void TestLoadIarV0_1ExistingUsers()
        {
            TestHelper.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            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");

            SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);

            UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood");
            UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");

            archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream);

            InventoryItemBase foundItem1
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name);

            Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");

// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
// UUID, not the OSPA itself.
//            Assert.That(
//                foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
//                "Loaded item non-uuid creator doesn't match original");
            Assert.That(
                foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()),
                "Loaded item non-uuid creator doesn't match original");

            Assert.That(
                foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID),
                "Loaded item uuid creator doesn't match original");
            Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID),
                        "Loaded item owner doesn't match inventory reciever");

            // Now try loading to a root child folder
            UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA");
            MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());

            archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream);

            InventoryItemBase foundItem2
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name);

            Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");

            // Now try loading to a more deeply nested folder
            UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xB/xC");
            archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
            archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream);

            InventoryItemBase foundItem3
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name);

            Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
        }
예제 #2
0
        public void TestPartExistingIarPath()
        {
            TestHelper.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            Scene       scene = SceneSetupHelpers.SetupScene("inventory");
            UserAccount ua1   = UserProfileTestUtils.CreateUserWithInventory(scene);

            string folder1ExistingName = "a";
            string folder2Name         = "b";

            InventoryFolderBase folder1
                = UserInventoryTestUtils.CreateInventoryFolder(
                      scene.InventoryService, ua1.PrincipalID, folder1ExistingName);

            string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
            string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());

            string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });

            new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false)
            .ReplicateArchivePathToUserInventory(
                itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
                new Dictionary <string, InventoryFolderBase>(), new HashSet <InventoryNodeBase>());

            List <InventoryFolderBase> folder1PostCandidates
                = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);

            Assert.That(folder1PostCandidates.Count, Is.EqualTo(2));

            // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder.
            InventoryFolderBase folder1Post = null;

            foreach (InventoryFolderBase folder in folder1PostCandidates)
            {
                if (folder.ID != folder1.ID)
                {
                    folder1Post = folder;
                    break;
                }
            }
//            Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID));

            List <InventoryFolderBase> folder2PostCandidates
                = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b");

            Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
        }
        public void TestLoadIarToInventoryPaths()
        {
            TestHelper.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            SerialiserModule        serialiserModule = new SerialiserModule();
            InventoryArchiverModule archiverModule   = new InventoryArchiverModule();

            // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene
            Scene scene = SceneSetupHelpers.SetupScene();

            SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);

            UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "meowfood");
            UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire");

            archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream);
            InventoryItemBase foundItem1
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name);

            Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");

            // Now try loading to a root child folder
            UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA");
            MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray());

            archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream);

            InventoryItemBase foundItem2
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name);

            Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");

            // Now try loading to a more deeply nested folder
            UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC");
            archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
            archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream);

            InventoryItemBase foundItem3
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name);

            Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
        }
예제 #4
0
        public void TestMergeIarPath()
        {
            TestHelper.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            Scene       scene = SceneSetupHelpers.SetupScene("inventory");
            UserAccount ua1   = UserProfileTestUtils.CreateUserWithInventory(scene);

            string folder1ExistingName = "a";
            string folder2Name         = "b";

            InventoryFolderBase folder1
                = UserInventoryTestUtils.CreateInventoryFolder(
                      scene.InventoryService, ua1.PrincipalID, folder1ExistingName);

            string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random());
            string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());

            string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });

            new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true)
            .ReplicateArchivePathToUserInventory(
                itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
                new Dictionary <string, InventoryFolderBase>(), new HashSet <InventoryNodeBase>());

            List <InventoryFolderBase> folder1PostCandidates
                = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName);

            Assert.That(folder1PostCandidates.Count, Is.EqualTo(1));
            Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID));

            List <InventoryFolderBase> folder2PostCandidates
                = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b");

            Assert.That(folder2PostCandidates.Count, Is.EqualTo(1));
        }
예제 #5
0
        public void TestLoadIarV0_1ExistingUsers()
        {
            TestHelper.InMethod();
            //log4net.Config.XmlConfigurator.Configure();

            string userFirstName            = "Mr";
            string userLastName             = "Tiddles";
            UUID   userUuid                 = UUID.Parse("00000000-0000-0000-0000-000000000555");
            string userItemCreatorFirstName = "Lord";
            string userItemCreatorLastName  = "Lucan";
            UUID   userItemCreatorUuid      = UUID.Parse("00000000-0000-0000-0000-000000000666");

            string item1Name       = "b.lsl";
            string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random());

            MemoryStream     archiveWriteStream = new MemoryStream();
            TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);

            InventoryItemBase item1 = new InventoryItemBase();

            item1.Name      = item1Name;
            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");

            SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);

            UserProfileTestUtils.CreateUserWithInventory(
                scene, userFirstName, userLastName, userUuid, "meowfood");
            UserProfileTestUtils.CreateUserWithInventory(
                scene, userItemCreatorFirstName, userItemCreatorLastName, userItemCreatorUuid, "hampshire");

            archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream);

            InventoryItemBase foundItem1
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, item1Name);

            Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");

// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
// UUID, not the OSPA itself.
//            Assert.That(
//                foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
//                "Loaded item non-uuid creator doesn't match original");
            Assert.That(
                foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()),
                "Loaded item non-uuid creator doesn't match original");

            Assert.That(
                foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid),
                "Loaded item uuid creator doesn't match original");
            Assert.That(foundItem1.Owner, Is.EqualTo(userUuid),
                        "Loaded item owner doesn't match inventory reciever");

            // Now try loading to a root child folder
            UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userUuid, "xA");
            archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
            archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream);

            InventoryItemBase foundItem2
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, "xA/" + item1Name);

            Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2");

            // Now try loading to a more deeply nested folder
            UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userUuid, "xB/xC");
            archiveReadStream = new MemoryStream(archiveReadStream.ToArray());
            archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream);

            InventoryItemBase foundItem3
                = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, "xB/xC/" + item1Name);

            Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3");
        }