Пример #1
0
        public void TestLlRequestAgentDataOnline()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

            UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, userId);

            SceneObjectPart   part       = SceneHelpers.AddSceneObject(m_scene).RootPart;
            TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, part);

            LSL_Api apiGrp1 = new LSL_Api();

            apiGrp1.Initialize(m_engine, part, scriptItem);

            // Initially long timeout to test cache
            apiGrp1.LlRequestAgentDataCacheTimeoutMs = 20000;

            // Offline test
            {
                apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE);

                Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID));

                List <EventParams> events = m_engine.PostedEvents[scriptItem.ItemID];
                Assert.That(events.Count, Is.EqualTo(1));
                EventParams eventParams = events[0];
                Assert.That(eventParams.EventName, Is.EqualTo("dataserver"));

                string data = eventParams.Params[1].ToString();
                Assert.AreEqual(0, int.Parse(data));

                m_engine.PostedEvents.Clear();
            }

            // Online test.  Should get the 'wrong' result because of caching.
            ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1);

            {
                apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE);

                Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID));

                List <EventParams> events = m_engine.PostedEvents[scriptItem.ItemID];
                Assert.That(events.Count, Is.EqualTo(1));
                EventParams eventParams = events[0];
                Assert.That(eventParams.EventName, Is.EqualTo("dataserver"));

                string data = eventParams.Params[1].ToString();
                Assert.AreEqual(0, int.Parse(data));

                m_engine.PostedEvents.Clear();
            }

            apiGrp1.LlRequestAgentDataCacheTimeoutMs = 20;

            // Make absolutely sure that we should trigger cache timeout.
            Thread.Sleep(apiGrp1.LlRequestAgentDataCacheTimeoutMs + 50);

            {
                apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE);

                Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID));

                List <EventParams> events = m_engine.PostedEvents[scriptItem.ItemID];
                Assert.That(events.Count, Is.EqualTo(1));
                EventParams eventParams = events[0];
                Assert.That(eventParams.EventName, Is.EqualTo("dataserver"));

                string data = eventParams.Params[1].ToString();
                Assert.AreEqual(1, int.Parse(data));

                m_engine.PostedEvents.Clear();
            }

            m_scene.CloseAgent(userId, false);

            Thread.Sleep(apiGrp1.LlRequestAgentDataCacheTimeoutMs + 50);

            {
                apiGrp1.llRequestAgentData(userId.ToString(), ScriptBaseClass.DATA_ONLINE);

                Assert.That(m_engine.PostedEvents.ContainsKey(scriptItem.ItemID));

                List <EventParams> events = m_engine.PostedEvents[scriptItem.ItemID];
                Assert.That(events.Count, Is.EqualTo(1));
                EventParams eventParams = events[0];
                Assert.That(eventParams.EventName, Is.EqualTo("dataserver"));

                string data = eventParams.Params[1].ToString();
                Assert.AreEqual(0, int.Parse(data));

                m_engine.PostedEvents.Clear();
            }
        }
Пример #2
0
        public void TestLoadIarPathWithEscapedChars()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            string itemName             = "You & you are a mean/man/";
            string humanEscapedItemName = @"You & you are a mean\/man\/";
            string userPassword         = "******";

            InventoryArchiverModule archiverModule = new InventoryArchiverModule();

            Scene scene = new SceneHelpers().SetupScene();

            SceneHelpers.SetupSceneModules(scene, archiverModule);

            // Create user
            string userFirstName = "Jock";
            string userLastName  = "Stirrup";
            UUID   userId        = UUID.Parse("00000000-0000-0000-0000-000000000020");

            UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood");

            // Create asset
            SceneObjectGroup object1;
            SceneObjectPart  part1;
            {
                string             partName       = "part name";
                UUID               ownerId        = UUID.Parse("00000000-0000-0000-0000-000000000040");
                PrimitiveBaseShape shape          = PrimitiveBaseShape.CreateSphere();
                Vector3            groupPosition  = new Vector3(10, 20, 30);
                Quaternion         rotationOffset = new Quaternion(20, 30, 40, 50);
                Vector3            offsetPosition = new Vector3(5, 10, 15);

                part1
                    = new SceneObjectPart(
                          ownerId, shape, groupPosition, rotationOffset, offsetPosition);
                part1.Name = partName;

                object1 = new SceneObjectGroup(part1);
                scene.AddNewSceneObject(object1, false);
            }

            UUID      asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
            AssetBase asset1   = AssetHelpers.CreateAsset(asset1Id, object1);

            scene.AssetService.Store(asset1);

            // Create item
            UUID item1Id            = UUID.Parse("00000000-0000-0000-0000-000000000080");
            InventoryItemBase item1 = new InventoryItemBase();

            item1.Name    = itemName;
            item1.AssetID = asset1.FullID;
            item1.ID      = item1Id;
            InventoryFolderBase objsFolder
                = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, userId, "Objects")[0];

            item1.Folder = objsFolder.ID;
            scene.AddInventoryItem(item1);

            MemoryStream archiveWriteStream = new MemoryStream();

            archiverModule.OnInventoryArchiveSaved += SaveCompleted;

            mre.Reset();
            archiverModule.ArchiveInventory(
                UUID.Random(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
            mre.WaitOne(60000, false);

            // LOAD ITEM
            MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());

            archiverModule.DearchiveInventory(UUID.Random(), userFirstName, userLastName, "Scripts", userPassword, archiveReadStream);

            InventoryItemBase foundItem1
                = InventoryArchiveUtils.FindItemByPath(
                      scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName);

            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.Name, Is.EqualTo(itemName),
                "Loaded item name doesn't match saved name");
        }
Пример #3
0
        public void TestNewIarPath()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            Scene       scene = new SceneHelpers().SetupScene();
            UserAccount ua1   = UserAccountHelpers.CreateUserWithInventory(scene);

            Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary <string, InventoryFolderBase>();
            HashSet <InventoryNodeBase> nodesLoaded = new HashSet <InventoryNodeBase>();

            string folder1Name  = "1";
            string folder2aName = "2a";
            string folder2bName = "2b";

            string folder1ArchiveName  = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random());
            string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random());
            string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random());

            string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName });
            string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName });

            {
                // Test replication of path1
                new InventoryArchiveReadRequest(UUID.Random(), null, scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false)
                .ReplicateArchivePathToUserInventory(
                    iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
                    foldersCreated, nodesLoaded);

                List <InventoryFolderBase> folder1Candidates
                    = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
                Assert.That(folder1Candidates.Count, Is.EqualTo(1));

                InventoryFolderBase        folder1 = folder1Candidates[0];
                List <InventoryFolderBase> folder2aCandidates
                    = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2aName);
                Assert.That(folder2aCandidates.Count, Is.EqualTo(1));
            }

            {
                // Test replication of path2
                new InventoryArchiveReadRequest(UUID.Random(), null, scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false)
                .ReplicateArchivePathToUserInventory(
                    iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
                    foldersCreated, nodesLoaded);

                List <InventoryFolderBase> folder1Candidates
                    = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, ua1.PrincipalID, folder1Name);
                Assert.That(folder1Candidates.Count, Is.EqualTo(1));

                InventoryFolderBase folder1 = folder1Candidates[0];

                List <InventoryFolderBase> folder2aCandidates
                    = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2aName);
                Assert.That(folder2aCandidates.Count, Is.EqualTo(1));

                List <InventoryFolderBase> folder2bCandidates
                    = InventoryArchiveUtils.FindFoldersByPath(scene.InventoryService, folder1, folder2bName);
                Assert.That(folder2bCandidates.Count, Is.EqualTo(1));
            }
        }
Пример #4
0
        public void TestSameSimulatorNeighbouringRegionsTeleport()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            AttachmentsModule              attModA = new AttachmentsModule();
            AttachmentsModule              attModB = new AttachmentsModule();
            EntityTransferModule           etmA    = new EntityTransferModule();
            EntityTransferModule           etmB    = new EntityTransferModule();
            LocalSimulationConnectorModule lscm    = new LocalSimulationConnectorModule();

            IConfigSource config        = new IniConfigSource();
            IConfig       modulesConfig = config.AddConfig("Modules");

            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);
            IConfig entityTransferConfig = config.AddConfig("EntityTransfer");

            // In order to run a single threaded regression test we do not want the entity transfer module waiting
            // for a callback from the destination scene before removing its avatar data.
            entityTransferConfig.Set("wait_for_callback", false);

            modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");

            SceneHelpers sh     = new SceneHelpers();
            TestScene    sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene    sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(
                sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule());
            SceneHelpers.SetupSceneModules(
                sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());

            UserAccount   ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1);
            ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, ua1.PrincipalID, sh.SceneManager);

            beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);

            InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20);

            sceneA.AttachmentsModule.RezSingleAttachmentFromInventory(
                beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt   = new Vector3(20, 21, 22);

            m_numberOfAttachEventsFired = 0;
            sceneA.RequestTeleportLocation(
                beforeTeleportSp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            ((TestClient)beforeTeleportSp.ControllingClient).CompleteTeleportClientSide();

            // Check attachments have made it into sceneB
            ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID);

            // This is appearance data, as opposed to actually rezzed attachments
            List <AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments();

            Assert.That(sceneBAttachments.Count, Is.EqualTo(1));
            Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
            Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID));
            Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
            Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));

            // This is the actual attachment
            List <SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments();

            Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1));
            SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0];

            Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name));
            Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest));

            Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1));

            // Check attachments have been removed from sceneA
            ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID);

            // Since this is appearance data, it is still present on the child avatar!
            List <AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments();

            Assert.That(sceneAAttachments.Count, Is.EqualTo(1));
            Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));

            // This is the actual attachment, which should no longer exist
            List <SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments();

            Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0));

            Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0));

            // Check events
            Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
        }
Пример #5
0
        protected void ConstructDefaultIarBytesForTestLoad()
        {
            //            log4net.Config.XmlConfigurator.Configure();

            InventoryArchiverModule archiverModule = new InventoryArchiverModule();
            Scene scene = new SceneHelpers().SetupScene();

            SceneHelpers.SetupSceneModules(scene, archiverModule);

            UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire");

            MemoryStream archiveWriteStream = new MemoryStream();

            // Create scene object asset
            UUID             ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
            SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "Ray Gun Object", 0x50);

            UUID      asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
            AssetBase asset1   = AssetHelpers.CreateAsset(asset1Id, object1);

            scene.AssetService.Store(asset1);

            // Create scene object item
            InventoryItemBase item1 = new InventoryItemBase();

            item1.Name      = m_item1Name;
            item1.ID        = UUID.Parse("00000000-0000-0000-0000-000000000020");
            item1.AssetID   = asset1.FullID;
            item1.GroupID   = UUID.Random();
            item1.CreatorId = m_uaLL1.PrincipalID.ToString();
            item1.Owner     = m_uaLL1.PrincipalID;
            item1.Folder    = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
            scene.AddInventoryItem(item1);

            // Create coalesced objects asset
            SceneObjectGroup cobj1 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object1", 0x120);

            cobj1.AbsolutePosition = new Vector3(15, 30, 45);

            SceneObjectGroup cobj2 = SceneHelpers.CreateSceneObject(1, m_uaLL1.PrincipalID, "Object2", 0x140);

            cobj2.AbsolutePosition = new Vector3(25, 50, 75);

            CoalescedSceneObjects coa = new CoalescedSceneObjects(m_uaLL1.PrincipalID, cobj1, cobj2);

            AssetBase coaAsset = AssetHelpers.CreateAsset(0x160, coa);

            scene.AssetService.Store(coaAsset);

            // Create coalesced objects inventory item
            InventoryItemBase coaItem = new InventoryItemBase();

            coaItem.Name      = m_coaItemName;
            coaItem.ID        = UUID.Parse("00000000-0000-0000-0000-000000000180");
            coaItem.AssetID   = coaAsset.FullID;
            coaItem.GroupID   = UUID.Random();
            coaItem.CreatorId = m_uaLL1.PrincipalID.ToString();
            coaItem.Owner     = m_uaLL1.PrincipalID;
            coaItem.Folder    = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID;
            scene.AddInventoryItem(coaItem);

            archiverModule.ArchiveInventory(
                UUID.Random(), m_uaLL1.FirstName, m_uaLL1.LastName, "/*", "hampshire", archiveWriteStream);

            m_iarStreamBytes = archiveWriteStream.ToArray();
        }
Пример #6
0
        public void TestDeleteSceneObjectAsyncToUserInventory()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

            UUID   agentId      = UUID.Parse("00000000-0000-0000-0000-000000000001");
            string myObjectName = "Fred";

            TestScene scene = new SceneHelpers().SetupScene();

            IConfigSource configSource = new IniConfigSource();
            IConfig       config       = configSource.AddConfig("Modules");

            config.Set("InventoryAccessModule", "BasicInventoryAccessModule");
            SceneHelpers.SetupSceneModules(
                scene, configSource, new object[] { new BasicInventoryAccessModule() });

            SceneHelpers.SetupSceneModules(scene, new object[] { });

            // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
            AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;

            sogd.Enabled = false;

            SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId);

            UserAccount         ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId);
            InventoryFolderBase folder1
                = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1", false);

            IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;

            scene.DeRezObjects(client, new List <uint>()
            {
                so.LocalId
            }, UUID.Zero, DeRezAction.Take, folder1.ID);

            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);

            Assert.That(retrievedPart, Is.Not.Null);
            Assert.That(so.IsDeleted, Is.False);

            sogd.InventoryDeQueueAndDelete();

            Assert.That(so.IsDeleted, Is.True);

            SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);

            Assert.That(retrievedPart2, Is.Null);

            //            SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client);

            InventoryItemBase retrievedItem
                = UserInventoryHelpers.GetInventoryItem(
                      scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName);

            // Check that we now have the taken part in our inventory
            Assert.That(retrievedItem, Is.Not.Null);

            // Check that the taken part has actually disappeared
            //            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
            //            Assert.That(retrievedPart, Is.Null);
        }
Пример #7
0
        public void TestTakeCopyWhenCopierIsNotOwnerWithoutPerms()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            IConfigSource config = new IniConfigSource();

            config.AddConfig("Modules");
            config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");

            TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config);

            SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule());
            UserAccount ua     = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));
            TestClient  client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient;

            // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
            AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;

            sogd.Enabled = false;

            SceneObjectGroup so        = SceneHelpers.AddSceneObject(scene, "so1", TestHelpers.ParseTail(0x2));
            uint             soLocalId = so.LocalId;

            {
                // Check that object is not copied if copy base perms is missing.
                // Should not allow copy if base does not have this.
                so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Transfer;
                // Must be set so anyone can copy
                so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy;

                // Check that object is not copied
                List <uint> localIds = new List <uint>();
                localIds.Add(so.LocalId);

                // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms
                scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);

                // Check that object isn't copied until we crank the sogd handle.
                SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
                Assert.That(retrievedPart, Is.Not.Null);
                Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);

                sogd.InventoryDeQueueAndDelete();
                // Check that object is still there.
                SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
                Assert.That(retrievedPart2, Is.Not.Null);
                Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));

                // Check that we have a copy in inventory
                InventoryItemBase item
                    = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1");
                Assert.That(item, Is.Null);
            }

            {
                // Check that object is not copied if copy trans perms is missing.
                // Should not allow copy if base does not have this.
                so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy;
                // Must be set so anyone can copy
                so.RootPart.EveryoneMask = (uint)OpenMetaverse.PermissionMask.Copy;

                // Check that object is not copied
                List <uint> localIds = new List <uint>();
                localIds.Add(so.LocalId);

                // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms
                scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);

                // Check that object isn't copied until we crank the sogd handle.
                SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
                Assert.That(retrievedPart, Is.Not.Null);
                Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);

                sogd.InventoryDeQueueAndDelete();
                // Check that object is still there.
                SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
                Assert.That(retrievedPart2, Is.Not.Null);
                Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));

                // Check that we have a copy in inventory
                InventoryItemBase item
                    = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1");
                Assert.That(item, Is.Null);
            }

            {
                // Check that object is not copied if everyone copy perms is missing.
                // Should not allow copy if base does not have this.
                so.RootPart.BaseMask = (uint)(OpenMetaverse.PermissionMask.Copy | OpenMetaverse.PermissionMask.Transfer);
                // Make sure everyone perm does not allow copy
                so.RootPart.EveryoneMask = (uint)(OpenMetaverse.PermissionMask.All & ~OpenMetaverse.PermissionMask.Copy);

                // Check that object is not copied
                List <uint> localIds = new List <uint>();
                localIds.Add(so.LocalId);

                // Specifying a UUID.Zero in this case will plop it in the Objects folder if we have perms
                scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);

                // Check that object isn't copied until we crank the sogd handle.
                SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
                Assert.That(retrievedPart, Is.Not.Null);
                Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);

                sogd.InventoryDeQueueAndDelete();
                // Check that object is still there.
                SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
                Assert.That(retrievedPart2, Is.Not.Null);
                Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));

                // Check that we have a copy in inventory
                InventoryItemBase item
                    = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Objects/so1");
                Assert.That(item, Is.Null);
            }
        }
Пример #8
0
        public void TestLoadPublishedOar()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            SceneObjectPart  part1 = CreateSceneObjectPart1();
            SceneObjectGroup sog1  = new SceneObjectGroup(part1);

            m_scene.AddNewSceneObject(sog1, false);

            SceneObjectPart part2 = CreateSceneObjectPart2();

            AssetNotecard nc = new AssetNotecard();

            nc.BodyText = "Hello World!";
            nc.Encode();
            UUID      ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000");
            UUID      ncItemUuid  = new UUID("00000000-0000-0000-1100-000000000000");
            AssetBase ncAsset
                = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);

            m_scene.AssetService.Store(ncAsset);
            SceneObjectGroup  sog2 = new SceneObjectGroup(part2);
            TaskInventoryItem ncItem
                = new TaskInventoryItem {
                Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid
                };

            part2.Inventory.AddInventoryItem(ncItem, true);

            m_scene.AddNewSceneObject(sog2, false);

            MemoryStream archiveWriteStream = new MemoryStream();

            m_scene.EventManager.OnOarFileSaved += SaveCompleted;

            Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");

            lock (this)
            {
                m_archiverModule.ArchiveRegion(
                    archiveWriteStream, requestId, new Dictionary <string, Object>()
                {
                    { "wipe-owners", Boolean.TrueString }
                });

                Monitor.Wait(this, 60000);
            }

            Assert.That(m_lastRequestId, Is.EqualTo(requestId));

            byte[]       archive           = archiveWriteStream.ToArray();
            MemoryStream archiveReadStream = new MemoryStream(archive);

            {
                UUID estateOwner = TestHelpers.ParseTail(0x4747);
                UUID objectOwner = TestHelpers.ParseTail(0x15);

                // Reload to new scene
                ArchiverModule   archiverModule   = new ArchiverModule();
                SerialiserModule serialiserModule = new SerialiserModule();
                TerrainModule    terrainModule    = new TerrainModule();

                SceneHelpers m_sceneHelpers2 = new SceneHelpers();
                TestScene    scene2          = m_sceneHelpers2.SetupScene();
                SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule);

                // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is
                // behaving correctly
                UserAccountHelpers.CreateUserWithInventory(scene2, objectOwner);

                scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner;

                lock (this)
                {
                    scene2.EventManager.OnOarFileLoaded += LoadCompleted;
                    archiverModule.DearchiveRegion(archiveReadStream);
                }

                Assert.That(m_lastErrorMessage, Is.Null);

                SceneObjectGroup loadedSog = scene2.GetSceneObjectGroup(part1.Name);
                Assert.That(loadedSog.OwnerID, Is.EqualTo(estateOwner));
                Assert.That(loadedSog.LastOwnerID, Is.EqualTo(estateOwner));
            }
        }
Пример #9
0
        public void TestPostAssetRewrite()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            XEngine xengine = new OpenSim.Region.ScriptEngine.XEngine.XEngine();

            xengine.DebugLevel = 1;

            IniConfigSource configSource = new IniConfigSource();

            IConfig startupConfig = configSource.AddConfig("Startup");

            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = configSource.AddConfig("XEngine");

            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");
            xEngineConfig.Set("AppDomainLoading", "false");

            string homeUrl       = "http://hg.HomeTestPostAssetRewriteGrid.com";
            string foreignUrl    = "http://hg.ForeignTestPostAssetRewriteGrid.com";
            int    soIdTail      = 0x1;
            UUID   assetId       = TestHelpers.ParseTail(0x10);
            UUID   userId        = TestHelpers.ParseTail(0x100);
            UUID   sceneId       = TestHelpers.ParseTail(0x1000);
            string userFirstName = "TestPostAsset";
            string userLastName  = "Rewrite";
            int    soPartsCount  = 3;

            Scene scene = new SceneHelpers().SetupScene("TestPostAssetRewriteScene", sceneId, 1000, 1000, configSource);

            SceneHelpers.SetupSceneModules(scene, configSource, xengine);
            scene.StartScripts();

            HGAssetMapper hgam = new HGAssetMapper(scene, homeUrl);
            UserAccount   ua
                = UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "password");

            SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, soPartsCount, ua.PrincipalID, "part", soIdTail);

            RezScript(
                scene, so.UUID, "default { state_entry() { llSay(0, \"Hello World\"); } }", "item1", ua.PrincipalID);

            AssetBase asset = AssetHelpers.CreateAsset(assetId, so);

            asset.CreatorID = foreignUrl;
            hgam.PostAsset(foreignUrl, asset);

            // Check transformed asset.
            AssetBase ncAssetGet = scene.AssetService.Get(assetId.ToString());

            Assert.AreEqual(foreignUrl, ncAssetGet.CreatorID);
            string      xmlData          = Utils.BytesToString(ncAssetGet.Data);
            XmlDocument ncAssetGetXmlDoc = new XmlDocument();

            ncAssetGetXmlDoc.LoadXml(xmlData);

//            Console.WriteLine(ncAssetGetXmlDoc.OuterXml);

            XmlNodeList creatorDataNodes = ncAssetGetXmlDoc.GetElementsByTagName("CreatorData");

            Assert.AreEqual(soPartsCount, creatorDataNodes.Count);
            //Console.WriteLine("creatorDataNodes {0}", creatorDataNodes.Count);

            foreach (XmlNode creatorDataNode in creatorDataNodes)
            {
                Assert.AreEqual(
                    string.Format("{0};{1} {2}", homeUrl, ua.FirstName, ua.LastName), creatorDataNode.InnerText);
            }

            // Check that saved script nodes have attributes
            XmlNodeList savedScriptStateNodes = ncAssetGetXmlDoc.GetElementsByTagName("SavedScriptState");

            Assert.AreEqual(1, savedScriptStateNodes.Count);
            Assert.AreEqual(1, savedScriptStateNodes[0].Attributes.Count);
            XmlNode uuidAttribute = savedScriptStateNodes[0].Attributes.GetNamedItem("UUID");

            Assert.NotNull(uuidAttribute);
            // XXX: To check the actual UUID attribute we would have to do some work to retreive the UUID of the task
            // item created earlier.
        }
Пример #10
0
        public void TestWearAttachmentFromInventory()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            Scene         scene = CreateTestScene();
            UserAccount   ua1   = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            ScenePresence sp    = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);

            InventoryItemBase attItem1 = CreateAttachmentItem(scene, ua1.PrincipalID, "att1", 0x10, 0x20);
            InventoryItemBase attItem2 = CreateAttachmentItem(scene, ua1.PrincipalID, "att2", 0x11, 0x21);

            {
                m_numberOfAttachEventsFired = 0;
                scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem1.ID, (uint)AttachmentPoint.Default);

                // default attachment point is currently the left hand.
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(attItem1.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);

                // Check appearance status
                Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
                Assert.That(sp.Appearance.GetAttachpoint(attItem1.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
            }

            // Test wearing a second attachment at the same position
            // Until multiple attachments at one point is implemented, this will remove the first attachment
            // This test relies on both attachments having the same default attachment point (in this case LeftHand
            // since none other has been set).
            {
                scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default);

                // default attachment point is currently the left hand.
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(attItem2.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);

                // Check appearance status
                Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
                Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
            }

            // Test wearing an already attached attachment
            {
                scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default);

                // default attachment point is currently the left hand.
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(attItem2.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);

                // Check appearance status
                Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
                Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
            }
        }
Пример #11
0
        public void TestSameSimulatorNeighbouringRegionsTeleportV2()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            BaseHttpServer httpServer = new BaseHttpServer(99999);

            MainServer.AddHttpServer(httpServer);
            MainServer.Instance = httpServer;

            AttachmentsModule              attModA = new AttachmentsModule();
            AttachmentsModule              attModB = new AttachmentsModule();
            EntityTransferModule           etmA    = new EntityTransferModule();
            EntityTransferModule           etmB    = new EntityTransferModule();
            LocalSimulationConnectorModule lscm    = new LocalSimulationConnectorModule();

            IConfigSource config        = new IniConfigSource();
            IConfig       modulesConfig = config.AddConfig("Modules");

            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");

            SceneHelpers sh     = new SceneHelpers();
            TestScene    sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene    sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(
                sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule());
            SceneHelpers.SetupSceneModules(
                sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());

            UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1);

            AgentCircuitData  acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
            TestClient        tc  = new TestClient(acd, sceneA);
            List <TestClient> destinationTestClients = new List <TestClient>();

            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

            ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);

            beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);

            Assert.That(destinationTestClients.Count, Is.EqualTo(1));
            Assert.That(destinationTestClients[0], Is.Not.Null);

            InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20);

            sceneA.AttachmentsModule.RezSingleAttachmentFromInventory(
                beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt   = new Vector3(20, 21, 22);

            // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement().  This
            // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to
            // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt
            // Both these operations will occur on different threads and will wait for each other.
            // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1
            // test protocol, where we are trying to avoid unpredictable async operations in regression tests.
            tc.OnTestClientSendRegionTeleport
                += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL)
                   => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null);

            m_numberOfAttachEventsFired = 0;
            sceneA.RequestTeleportLocation(
                beforeTeleportSp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            // Check attachments have made it into sceneB
            ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID);

            // This is appearance data, as opposed to actually rezzed attachments
            List <AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments();

            Assert.That(sceneBAttachments.Count, Is.EqualTo(1));
            Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
            Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID));
            Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
            Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));

            // This is the actual attachment
            List <SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments();

            Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1));
            SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0];

            Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name));
            Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest));
            Assert.IsFalse(actualSceneBAtt.Backup);

            Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1));

            // Check attachments have been removed from sceneA
            ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID);

            // Since this is appearance data, it is still present on the child avatar!
            List <AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments();

            Assert.That(sceneAAttachments.Count, Is.EqualTo(1));
            Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));

            // This is the actual attachment, which should no longer exist
            List <SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments();

            Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0));

            Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0));

            // Check events
            Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
        }
Пример #12
0
        public void TestRezAttachmentFromInventory()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            Scene         scene = CreateTestScene();
            UserAccount   ua1   = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            ScenePresence sp    = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);

            InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);

            {
                scene.AttachmentsModule.RezSingleAttachmentFromInventory(
                    sp, attItem.ID, (uint)AttachmentPoint.Chest);

                // Check scene presence status
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
                Assert.That(attSo.IsAttachment);
                Assert.That(attSo.UsesPhysics, Is.False);
                Assert.That(attSo.IsTemporary, Is.False);
                Assert.IsFalse(attSo.Backup);

                // Check appearance status
                Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
                Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
            }

            // Test attaching an already attached attachment
            {
                scene.AttachmentsModule.RezSingleAttachmentFromInventory(
                    sp, attItem.ID, (uint)AttachmentPoint.Chest);

                // Check scene presence status
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
                Assert.That(attSo.IsAttachment);
                Assert.That(attSo.UsesPhysics, Is.False);
                Assert.That(attSo.IsTemporary, Is.False);

                // Check appearance status
                Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
                Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
            }
        }
Пример #13
0
        public void TestWearAttachmentFromGround()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            Scene         scene = CreateTestScene();
            UserAccount   ua1   = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            ScenePresence sp    = SceneHelpers.AddScenePresence(scene, ua1);

            SceneObjectGroup so2 = SceneHelpers.AddSceneObject(scene, "att2", sp.UUID);

            {
                SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID);

                m_numberOfAttachEventsFired = 0;
                scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false);

                // Check status on scene presence
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(so.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);
                Assert.That(attSo.UsesPhysics, Is.False);
                Assert.That(attSo.IsTemporary, Is.False);

                // Check item status
                Assert.That(
                    sp.Appearance.GetAttachpoint(attSo.FromItemID),
                    Is.EqualTo((int)AttachmentPoint.LeftHand));

                InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
                Assert.That(attachmentItem, Is.Not.Null);
                Assert.That(attachmentItem.Name, Is.EqualTo(so.Name));

                InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
                Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));

                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(2));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
            }

            // Test wearing a different attachment from the ground.
            {
                scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false);

                // Check status on scene presence
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(so2.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);
                Assert.That(attSo.UsesPhysics, Is.False);
                Assert.That(attSo.IsTemporary, Is.False);

                // Check item status
                Assert.That(
                    sp.Appearance.GetAttachpoint(attSo.FromItemID),
                    Is.EqualTo((int)AttachmentPoint.LeftHand));

                InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
                Assert.That(attachmentItem, Is.Not.Null);
                Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name));

                InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
                Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));

                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
            }

            // Test rewearing an already worn attachment from ground.  Nothing should happen.
            {
                scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false);

                // Check status on scene presence
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(so2.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);
                Assert.That(attSo.UsesPhysics, Is.False);
                Assert.That(attSo.IsTemporary, Is.False);

                // Check item status
                Assert.That(
                    sp.Appearance.GetAttachpoint(attSo.FromItemID),
                    Is.EqualTo((int)AttachmentPoint.LeftHand));

                InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
                Assert.That(attachmentItem, Is.Not.Null);
                Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name));

                InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
                Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));

                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
            }
        }
Пример #14
0
        public void TestTakeCopyWhenCopierIsOwnerWithPerms()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            IConfigSource config = new IniConfigSource();

            config.AddConfig("Modules");
            config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");

            TestScene scene = new SceneHelpers().SetupScene("s1", TestHelpers.ParseTail(0x99), 1000, 1000, config);

            SceneHelpers.SetupSceneModules(scene, config, new PermissionsModule(), new BasicInventoryAccessModule());
            UserAccount ua     = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));
            TestClient  client = (TestClient)SceneHelpers.AddScenePresence(scene, ua.PrincipalID).ControllingClient;

            // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
            AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;

            sogd.Enabled = false;

            SceneObjectGroup so        = SceneHelpers.AddSceneObject(scene, "so1", ua.PrincipalID);
            uint             soLocalId = so.LocalId;

//            so.UpdatePermissions(
//                ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Copy, 1);
//            so.UpdatePermissions(
//                ua.PrincipalID, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0);
//            so.UpdatePermissions(
//                ua.PrincipalID, (byte)PermissionWho.Base, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0);
//            scene.HandleObjectPermissionsUpdate(client, client.AgentId, client.SessionId, (byte)PermissionWho.Owner, so.LocalId, (uint)OpenMetaverse.PermissionMask.Transfer, 0);

            // Ideally we might change these via client-focussed method calls as commented out above.  However, this
            // becomes very convoluted so we will set only the copy perm directly.
            so.RootPart.BaseMask = (uint)OpenMetaverse.PermissionMask.Copy;
//            so.RootPart.OwnerMask = (uint)OpenMetaverse.PermissionMask.Copy;

            List <uint> localIds = new List <uint>();

            localIds.Add(so.LocalId);

            // Specifying a UUID.Zero in this case will currently plop it in Lost and Found
            scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.TakeCopy, UUID.Zero);

            // Check that object isn't copied until we crank the sogd handle.
            SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);

            Assert.That(retrievedPart, Is.Not.Null);
            Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False);

            sogd.InventoryDeQueueAndDelete();

            // Check that object is still there.
            SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);

            Assert.That(retrievedPart2, Is.Not.Null);
            Assert.That(client.ReceivedKills.Count, Is.EqualTo(0));

            // Check that we have a copy in inventory
            InventoryItemBase item
                = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, ua.PrincipalID, "Lost And Found/so1");

            Assert.That(item, Is.Not.Null);
        }
Пример #15
0
        public void TestSaveItemToIarNoAssets()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            // Create user
            string userFirstName = "Jock";
            string userLastName  = "Stirrup";
            string userPassword  = "******";
            UUID   userId        = UUID.Parse("00000000-0000-0000-0000-000000000020");

            UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);

            // Create asset
            UUID             ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
            SceneObjectGroup object1 = SceneHelpers.CreateSceneObject(1, ownerId, "My Little Dog Object", 0x50);

            UUID      asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
            AssetBase asset1   = AssetHelpers.CreateAsset(asset1Id, object1);

            m_scene.AssetService.Store(asset1);

            // Create item
            UUID              item1Id   = UUID.Parse("00000000-0000-0000-0000-000000000080");
            string            item1Name = "My Little Dog";
            InventoryItemBase item1     = new InventoryItemBase();

            item1.Name    = item1Name;
            item1.AssetID = asset1.FullID;
            item1.ID      = item1Id;
            InventoryFolderBase objsFolder
                = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0];

            item1.Folder = objsFolder.ID;
            m_scene.AddInventoryItem(item1);

            MemoryStream archiveWriteStream = new MemoryStream();

            Dictionary <string, Object> options = new Dictionary <string, Object>();

            options.Add("noassets", true);

            // When we're not saving assets, archiving is being done synchronously.
            m_archiverModule.ArchiveInventory(
                Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream, options);

            byte[]           archive           = archiveWriteStream.ToArray();
            MemoryStream     archiveReadStream = new MemoryStream(archive);
            TarArchiveReader tar = new TarArchiveReader(archiveReadStream);

            //bool gotControlFile = false;
            bool gotObject1File = false;
            //bool gotObject2File = false;
            string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
            string expectedObject1FilePath = string.Format(
                "{0}{1}",
                ArchiveConstants.INVENTORY_PATH,
                expectedObject1FileName);

            string filePath;

            TarArchiveReader.TarEntryType tarEntryType;

//            Console.WriteLine("Reading archive");

            while (tar.ReadEntry(out filePath, out tarEntryType) != null)
            {
                Console.WriteLine("Got {0}", filePath);

//                if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
//                {
//                    gotControlFile = true;
//                }

                if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
                {
//                    string fileName = filePath.Remove(0, "Objects/".Length);
//
//                    if (fileName.StartsWith(part1.Name))
//                    {
                    Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
                    gotObject1File = true;
//                    }
//                    else if (fileName.StartsWith(part2.Name))
//                    {
//                        Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
//                        gotObject2File = true;
//                    }
                }
                else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
                {
                    Assert.Fail("Found asset path in TestSaveItemToIarNoAssets()");
                }
            }

//            Assert.That(gotControlFile, Is.True, "No control file in archive");
            Assert.That(gotObject1File, Is.True, "No item1 file in archive");
//            Assert.That(gotObject2File, Is.True, "No object2 file in archive");

            // TODO: Test presence of more files and contents of files.
        }
Пример #16
0
        public void TestSaveNonRootFolderToIar()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            string userFirstName = "Jock";
            string userLastName  = "Stirrup";
            string userPassword  = "******";
            UUID   userId        = TestHelpers.ParseTail(0x20);

            UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword);

            // Create base folder
            InventoryFolderBase f1
                = UserInventoryHelpers.CreateInventoryFolder(m_scene.InventoryService, userId, "f1", true);

            // Create item1
            SceneObjectGroup  so1 = SceneHelpers.CreateSceneObject(1, userId, "My Little Dog Object", 0x5);
            InventoryItemBase i1  = UserInventoryHelpers.AddInventoryItem(m_scene, so1, 0x50, 0x60, "f1");

            // Create embedded folder
            InventoryFolderBase f1_1
                = UserInventoryHelpers.CreateInventoryFolder(m_scene.InventoryService, userId, "f1/f1.1", true);

            // Create embedded item
            SceneObjectGroup  so1_1 = SceneHelpers.CreateSceneObject(1, userId, "My Little Cat Object", 0x6);
            InventoryItemBase i2    = UserInventoryHelpers.AddInventoryItem(m_scene, so1_1, 0x500, 0x600, "f1/f1.1");

            MemoryStream archiveWriteStream = new MemoryStream();

            m_archiverModule.OnInventoryArchiveSaved += SaveCompleted;

            mre.Reset();
            m_archiverModule.ArchiveInventory(
                Guid.NewGuid(), userFirstName, userLastName, "f1", userPassword, archiveWriteStream);
            mre.WaitOne(60000, false);

            // Test created iar
            byte[]           archive           = archiveWriteStream.ToArray();
            MemoryStream     archiveReadStream = new MemoryStream(archive);
            TarArchiveReader tar = new TarArchiveReader(archiveReadStream);

//            InventoryArchiveUtils.
            bool gotf1 = false, gotf1_1 = false, gotso1 = false, gotso2 = false;

            string f1FileName
                = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, InventoryArchiveWriteRequest.CreateArchiveFolderName(f1));
            string f1_1FileName
                = string.Format("{0}{1}", f1FileName, InventoryArchiveWriteRequest.CreateArchiveFolderName(f1_1));
            string so1FileName
                = string.Format("{0}{1}", f1FileName, InventoryArchiveWriteRequest.CreateArchiveItemName(i1));
            string so2FileName
                = string.Format("{0}{1}", f1_1FileName, InventoryArchiveWriteRequest.CreateArchiveItemName(i2));

            string filePath;

            TarArchiveReader.TarEntryType tarEntryType;

            while (tar.ReadEntry(out filePath, out tarEntryType) != null)
            {
//                Console.WriteLine("Got {0}", filePath);

                if (filePath == f1FileName)
                {
                    gotf1 = true;
                }
                else if (filePath == f1_1FileName)
                {
                    gotf1_1 = true;
                }
                else if (filePath == so1FileName)
                {
                    gotso1 = true;
                }
                else if (filePath == so2FileName)
                {
                    gotso2 = true;
                }
            }

//            Assert.That(gotControlFile, Is.True, "No control file in archive");
            Assert.That(gotf1, Is.True);
            Assert.That(gotf1_1, Is.True);
            Assert.That(gotso1, Is.True);
            Assert.That(gotso2, Is.True);

            // TODO: Test presence of more files and contents of files.
        }
        public void TestAcceptGivenFolder()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID initialSessionId = TestHelpers.ParseTail(0x10);
            UUID folderId         = TestHelpers.ParseTail(0x100);

            UserAccount ua1
                = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
            UserAccount ua2
                = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");

            ScenePresence giverSp     = SceneHelpers.AddScenePresence(m_scene, ua1);
            TestClient    giverClient = (TestClient)giverSp.ControllingClient;

            ScenePresence receiverSp     = SceneHelpers.AddScenePresence(m_scene, ua2);
            TestClient    receiverClient = (TestClient)receiverSp.ControllingClient;

            InventoryFolderBase originalFolder
                = UserInventoryHelpers.CreateInventoryFolder(
                      m_scene.InventoryService, giverSp.UUID, folderId, "f1", true);

            byte[] giveImBinaryBucket = new byte[17];
            giveImBinaryBucket[0] = (byte)AssetType.Folder;
            byte[] itemIdBytes = folderId.GetBytes();
            Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);

            GridInstantMessage giveIm
                = new GridInstantMessage(
                      m_scene,
                      giverSp.UUID,
                      giverSp.Name,
                      receiverSp.UUID,
                      (byte)InstantMessageDialog.InventoryOffered,
                      false,
                      "inventory offered msg",
                      initialSessionId,
                      false,
                      Vector3.Zero,
                      giveImBinaryBucket,
                      true);

            giverClient.HandleImprovedInstantMessage(giveIm);

            // These details might not all be correct.
            GridInstantMessage acceptIm
                = new GridInstantMessage(
                      m_scene,
                      receiverSp.UUID,
                      receiverSp.Name,
                      giverSp.UUID,
                      (byte)InstantMessageDialog.InventoryAccepted,
                      false,
                      "inventory accepted msg",
                      initialSessionId,
                      false,
                      Vector3.Zero,
                      null,
                      true);

            receiverClient.HandleImprovedInstantMessage(acceptIm);

            // Test for item remaining in the giver's inventory (here we assume a copy item)
            // TODO: Test no-copy items.
            InventoryFolderBase originalFolderAfterGive
                = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");

            Assert.That(originalFolderAfterGive, Is.Not.Null);
            Assert.That(originalFolderAfterGive.ID, Is.EqualTo(originalFolder.ID));

            // Test for item successfully making it into the receiver's inventory
            InventoryFolderBase receivedFolder
                = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, receiverSp.UUID, "f1");

            Assert.That(receivedFolder, Is.Not.Null);
            Assert.That(receivedFolder.ID, Is.Not.EqualTo(originalFolder.ID));

            // Test that on a delete, item still exists and is accessible for the giver.
            m_scene.InventoryService.DeleteFolders(receiverSp.UUID, new List <UUID>()
            {
                receivedFolder.ID
            });

            InventoryFolderBase originalFolderAfterDelete
                = UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");

            Assert.That(originalFolderAfterDelete, Is.Not.Null);

            // TODO: Test scenario where giver deletes their item first.
        }
Пример #18
0
        public void TestInventoryDescendentsFetch()
        {
            TestHelpers.InMethod();
            TestHelpers.EnableLogging();

            BaseHttpServer httpServer = MainServer.Instance;
            Scene          scene      = new SceneHelpers().SetupScene();

            CapabilitiesModule    capsModule = new CapabilitiesModule();
            WebFetchInvDescModule wfidModule = new WebFetchInvDescModule(false);

            IConfigSource config = new IniConfigSource();

            config.AddConfig("ClientStack.LindenCaps");
            config.Configs["ClientStack.LindenCaps"].Set("Cap_FetchInventoryDescendents2", "localhost");

            SceneHelpers.SetupSceneModules(scene, config, capsModule, wfidModule);

            UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, TestHelpers.ParseTail(0x1));

            // We need a user present to have any capabilities set up
            SceneHelpers.AddScenePresence(scene, ua.PrincipalID);

            TestHttpRequest req = new TestHttpRequest();

            OpenSim.Framework.Capabilities.Caps userCaps = capsModule.GetCapsForUser(ua.PrincipalID);
            PollServiceEventArgs pseArgs;

            userCaps.TryGetPollHandler("FetchInventoryDescendents2", out pseArgs);
            req.UriPath = pseArgs.Url;
            req.Uri     = new Uri(req.UriPath);

            // Retrieve root folder details directly so that we can request
            InventoryFolderBase folder = scene.InventoryService.GetRootFolder(ua.PrincipalID);

            OSDMap osdFolder = new OSDMap();

            osdFolder["folder_id"]     = folder.ID;
            osdFolder["owner_id"]      = ua.PrincipalID;
            osdFolder["fetch_folders"] = true;
            osdFolder["fetch_items"]   = true;
            osdFolder["sort_order"]    = 0;

            OSDArray osdFoldersArray = new OSDArray();

            osdFoldersArray.Add(osdFolder);

            OSDMap osdReqMap = new OSDMap();

            osdReqMap["folders"] = osdFoldersArray;

            req.Body = new MemoryStream(OSDParser.SerializeLLSDXmlBytes(osdReqMap));

            TestHttpClientContext context = new TestHttpClientContext(false);

            MainServer.Instance.OnRequest(context, new RequestEventArgs(req));

            // Drive processing of the queued inventory request synchronously.
            wfidModule.WaitProcessQueuedInventoryRequest();
            MainServer.Instance.PollServiceRequestManager.WaitPerformResponse();

            //            System.Threading.Thread.Sleep(10000);

            OSDMap   responseOsd = (OSDMap)OSDParser.DeserializeLLSDXml(context.ResponseBody);
            OSDArray foldersOsd  = (OSDArray)responseOsd["folders"];
            OSDMap   folderOsd   = (OSDMap)foldersOsd[0];

            // A sanity check that the response has the expected number of descendents for a default inventory
            // TODO: Need a more thorough check.
            Assert.That((int)folderOsd["descendents"], Is.EqualTo(14));
        }
Пример #19
0
        public void TestRejectGivenItem()
        {
            //            TestHelpers.EnableLogging();

            UUID initialSessionId = TestHelpers.ParseTail(0x10);
            UUID itemId           = TestHelpers.ParseTail(0x100);
            UUID assetId          = TestHelpers.ParseTail(0x200);

            UserAccount ua1
                = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
            UserAccount ua2
                = UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");

            ScenePresence giverSp     = SceneHelpers.AddScenePresence(m_scene, ua1);
            TestClient    giverClient = (TestClient)giverSp.ControllingClient;

            ScenePresence receiverSp     = SceneHelpers.AddScenePresence(m_scene, ua2);
            TestClient    receiverClient = (TestClient)receiverSp.ControllingClient;

            // Create the object to test give
            InventoryItemBase originalItem
                = UserInventoryHelpers.CreateInventoryItem(
                      m_scene, "givenObj", itemId, assetId, giverSp.UUID, InventoryType.Object);

            GridInstantMessage receivedIm = null;

            receiverClient.OnReceivedInstantMessage += im => receivedIm = im;

            byte[] giveImBinaryBucket = new byte[17];
            byte[] itemIdBytes        = itemId.GetBytes();
            Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);

            GridInstantMessage giveIm
                = new GridInstantMessage(
                      m_scene,
                      giverSp.UUID,
                      giverSp.Name,
                      receiverSp.UUID,
                      (byte)InstantMessageDialog.InventoryOffered,
                      false,
                      "inventory offered msg",
                      initialSessionId,
                      false,
                      Vector3.Zero,
                      giveImBinaryBucket,
                      true);

            giverClient.HandleImprovedInstantMessage(giveIm);

            // These details might not all be correct.
            // Session ID is now the created item ID (!)
            GridInstantMessage rejectIm
                = new GridInstantMessage(
                      m_scene,
                      receiverSp.UUID,
                      receiverSp.Name,
                      giverSp.UUID,
                      (byte)InstantMessageDialog.InventoryDeclined,
                      false,
                      "inventory declined msg",
                      new UUID(receivedIm.imSessionID),
                      false,
                      Vector3.Zero,
                      null,
                      true);

            receiverClient.HandleImprovedInstantMessage(rejectIm);

            // Test for item remaining in the giver's inventory (here we assume a copy item)
            // TODO: Test no-copy items.
            InventoryItemBase originalItemAfterGive
                = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");

            Assert.That(originalItemAfterGive, Is.Not.Null);
            Assert.That(originalItemAfterGive.ID, Is.EqualTo(originalItem.ID));

            // Test for item successfully making it into the receiver's inventory
            InventoryItemBase receivedItem
                = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, receiverSp.UUID, "Trash/givenObj");

            InventoryFolderBase trashFolder
                = m_scene.InventoryService.GetFolderForType(receiverSp.UUID, FolderType.Trash);

            Assert.That(receivedItem, Is.Not.Null);
            Assert.That(receivedItem.ID, Is.Not.EqualTo(originalItem.ID));
            Assert.That(receivedItem.Folder, Is.EqualTo(trashFolder.ID));

            // Test that on a delete, item still exists and is accessible for the giver.
            m_scene.InventoryService.PurgeFolder(trashFolder);

            InventoryItemBase originalItemAfterDelete
                = UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");

            Assert.That(originalItemAfterDelete, Is.Not.Null);
        }
Пример #20
0
        public void TestSavePathToIarV0_1()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            InventoryArchiverModule archiverModule = new InventoryArchiverModule();

            Scene scene = new SceneHelpers().SetupScene();

            SceneHelpers.SetupSceneModules(scene, archiverModule);

            // Create user
            string userFirstName = "Jock";
            string userLastName  = "Stirrup";
            string userPassword  = "******";
            UUID   userId        = UUID.Parse("00000000-0000-0000-0000-000000000020");

            UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);

            // Create asset
            SceneObjectGroup object1;
            SceneObjectPart  part1;
            {
                string             partName       = "My Little Dog Object";
                UUID               ownerId        = UUID.Parse("00000000-0000-0000-0000-000000000040");
                PrimitiveBaseShape shape          = PrimitiveBaseShape.CreateSphere();
                Vector3            groupPosition  = new Vector3(10, 20, 30);
                Quaternion         rotationOffset = new Quaternion(20, 30, 40, 50);
                Vector3            offsetPosition = new Vector3(5, 10, 15);

                part1      = new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition);
                part1.Name = partName;

                object1 = new SceneObjectGroup(part1);
                scene.AddNewSceneObject(object1, false);
            }

            UUID      asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
            AssetBase asset1   = AssetHelpers.CreateAsset(asset1Id, object1);

            scene.AssetService.Store(asset1);

            // Create item
            UUID item1Id            = UUID.Parse("00000000-0000-0000-0000-000000000080");
            InventoryItemBase item1 = new InventoryItemBase();

            item1.Name    = "My Little Dog";
            item1.AssetID = asset1.FullID;
            item1.ID      = item1Id;
            InventoryFolderBase objsFolder
                = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0];

            item1.Folder = objsFolder.ID;
            scene.AddInventoryItem(item1);

            MemoryStream archiveWriteStream = new MemoryStream();

            archiverModule.OnInventoryArchiveSaved += SaveCompleted;

            // Test saving a particular path
            mre.Reset();
            archiverModule.ArchiveInventory(
                Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream);
            mre.WaitOne(60000, false);

            byte[]           archive           = archiveWriteStream.ToArray();
            MemoryStream     archiveReadStream = new MemoryStream(archive);
            TarArchiveReader tar = new TarArchiveReader(archiveReadStream);

            //bool gotControlFile = false;
            bool gotObject1File = false;
            //bool gotObject2File = false;
            string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1);
            string expectedObject1FilePath = string.Format(
                "{0}{1}{2}",
                ArchiveConstants.INVENTORY_PATH,
                InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder),
                expectedObject1FileName);

            string filePath;

            TarArchiveReader.TarEntryType tarEntryType;

//            Console.WriteLine("Reading archive");

            while (tar.ReadEntry(out filePath, out tarEntryType) != null)
            {
//                Console.WriteLine("Got {0}", filePath);

//                if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
//                {
//                    gotControlFile = true;
//                }

                if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
                {
//                    string fileName = filePath.Remove(0, "Objects/".Length);
//
//                    if (fileName.StartsWith(part1.Name))
//                    {
                    Assert.That(expectedObject1FilePath, Is.EqualTo(filePath));
                    gotObject1File = true;
//                    }
//                    else if (fileName.StartsWith(part2.Name))
//                    {
//                        Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
//                        gotObject2File = true;
//                    }
                }
            }

//            Assert.That(gotControlFile, Is.True, "No control file in archive");
            Assert.That(gotObject1File, Is.True, "No item1 file in archive");
//            Assert.That(gotObject2File, Is.True, "No object2 file in archive");

            // TODO: Test presence of more files and contents of files.
        }