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("file://" + 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);

            // WARNING: This results in a caught exception, because queryString is null
            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(16));
        }
//        [Test]
        public void TestLifecycle()
        {
            TestHelpers.InMethod();
            TestHelpers.EnableLogging();

            UUID estateOwnerId = TestHelpers.ParseTail(0x1);
            UUID regionId      = TestHelpers.ParseTail(0x10);

            IConfigSource configSource = new IniConfigSource();

            configSource.AddConfig("Startup");
            configSource.AddConfig("Modules");

//            // We use this to skip estate questions
            // Turns out not to be needed is estate owner id is pre-set in region information.
//            IConfig estateConfig = configSource.AddConfig(OpenSimBase.ESTATE_SECTION_NAME);
//            estateConfig.Set("DefaultEstateOwnerName", "Zaphod Beeblebrox");
//            estateConfig.Set("DefaultEstateOwnerUUID", estateOwnerId);
//            estateConfig.Set("DefaultEstateOwnerEMail", "*****@*****.**");
//            estateConfig.Set("DefaultEstateOwnerPassword", "two heads");

            // For grid servic
            configSource.AddConfig("GridService");
            configSource.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector");
            configSource.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData");
            configSource.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService");
            configSource.Configs["GridService"].Set("ConnectionString", "!static");

            LocalGridServicesConnector gridService = new LocalGridServicesConnector();
//
            OpenSim sim = new OpenSim(configSource);

            sim.SuppressExit                    = true;
            sim.EnableInitialPluginLoad         = false;
            sim.LoadEstateDataService           = false;
            sim.NetServersInfo.HttpListenerPort = 0;

            IRegistryCore reg = sim.ApplicationRegistry;

            RegionInfo ri = new RegionInfo();

            ri.RegionID = regionId;
            ri.EstateSettings.EstateOwner = estateOwnerId;
            ri.InternalEndPoint           = new IPEndPoint(0, 0);

            MockRegionModulesControllerPlugin rmcp = new MockRegionModulesControllerPlugin();

            sim.m_plugins = new List <IApplicationPlugin>()
            {
                rmcp
            };
            reg.RegisterInterface <IRegionModulesController>(rmcp);

            // XXX: Have to initialize directly for now
            rmcp.Initialise(sim);

            rmcp.AddNode(gridService);

            TestSharedRegion tsr = new TestSharedRegion();

            rmcp.AddNode(tsr);

            // FIXME: Want to use the real one eventually but this is currently directly tied into Mono.Addins
            // which has been written in such a way that makes it impossible to use for regression tests.
//            RegionModulesControllerPlugin rmcp = new RegionModulesControllerPlugin();
//            rmcp.LoadModulesFromAddins = false;
////            reg.RegisterInterface<IRegionModulesController>(rmcp);
//            rmcp.Initialise(sim);
//            rmcp.PostInitialise();
//            TypeExtensionNode node = new TypeExtensionNode();
//            node.
//            rmcp.AddNode(node, configSource.Configs["Modules"], new Dictionary<RuntimeAddin, IList<int>>());

            sim.Startup();
            IScene scene;

            sim.CreateRegion(ri, out scene);

            sim.Shutdown();

            List <string> co = tsr.CallOrder;
            int           expectedEventCount = 6;

            Assert.AreEqual(
                expectedEventCount,
                co.Count,
                "Expected {0} events but only got {1} ({2})",
                expectedEventCount, co.Count, string.Join(",", co));
            Assert.AreEqual("Initialise", co[0]);
            Assert.AreEqual("PostInitialise", co[1]);
            Assert.AreEqual("AddRegion", co[2]);
            Assert.AreEqual("RegionLoaded", co[3]);
            Assert.AreEqual("RemoveRegion", co[4]);
            Assert.AreEqual("Close", co[5]);
        }
        public void TestCrossOnSameSimulatorWithSittingAvatar()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID    userId            = TestHelpers.ParseTail(0x1);
            int     sceneObjectIdTail = 0x2;
            Vector3 so1StartPos       = new Vector3(128, 10, 20);

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

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

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

            SceneObjectGroup so1   = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
            UUID             so1Id = so1.UUID;

            so1.AbsolutePosition = so1StartPos;

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

            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

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

            sp1SceneA.AbsolutePosition = so1StartPos;
            sp1SceneA.HandleAgentRequestSit(sp1SceneA.ControllingClient, sp1SceneA.UUID, so1.UUID, Vector3.Zero);

            sceneA.Update(4);
            sceneB.Update(4);
            // Cross
            sceneA.SceneGraph.UpdatePrimGroupPosition(
                so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), sp1SceneA.ControllingClient);

            // crossing is async
            sceneA.Update(4);
            sceneB.Update(4);
            Thread.Sleep(500);

            SceneObjectGroup so1PostCross;

            ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId);

            Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false");

            ScenePresence sp1SceneBPostCross = sceneB.GetScenePresence(userId);
            TestClient    sceneBTc           = ((TestClient)sp1SceneBPostCross.ControllingClient);

            sceneBTc.CompleteMovement();

            sceneA.Update(4);
            sceneB.Update(4);

            Assert.IsFalse(sp1SceneBPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
            Assert.IsTrue(sp1SceneBPostCross.IsSatOnObject);

            Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id), "uck");
            so1PostCross = sceneB.GetSceneObjectGroup(so1Id);
            Assert.NotNull(so1PostCross);
            Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount());


            Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition;

//            Console.WriteLine("CRISSCROSS");

            // Recross
            sceneB.SceneGraph.UpdatePrimGroupPosition(
                so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), sp1SceneBPostCross.ControllingClient);

            sceneA.Update(4);
            sceneB.Update(4);
            // crossing is async
            Thread.Sleep(500);

            {
                ScenePresence sp1SceneBPostReCross = sceneB.GetScenePresence(userId);
                Assert.IsTrue(sp1SceneBPostReCross.IsChildAgent, "sp1SceneBPostReCross.IsChildAgent unexpectedly false");

                ScenePresence sp1SceneAPostReCross = sceneA.GetScenePresence(userId);
                TestClient    sceneATc             = ((TestClient)sp1SceneAPostReCross.ControllingClient);
                sceneATc.CompleteMovement();

                Assert.IsFalse(sp1SceneAPostReCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
                Assert.IsTrue(sp1SceneAPostReCross.IsSatOnObject);

                Assert.IsNull(sceneB.GetSceneObjectGroup(so1Id), "uck2");
                SceneObjectGroup so1PostReCross = sceneA.GetSceneObjectGroup(so1Id);
                Assert.NotNull(so1PostReCross);
                Assert.AreEqual(1, so1PostReCross.GetSittingAvatarsCount());
            }
        }
        /// <summary>
        /// Setup a default config values in case they aren't present in the ini file
        /// </summary>
        /// <returns></returns>
        public static IConfigSource DefaultConfig()
        {
            IConfigSource defaultConfig = new IniConfigSource();

            {
                IConfig config = defaultConfig.Configs["Startup"];

                if (null == config)
                {
                    config = defaultConfig.AddConfig("Startup");
                }

                config.Set("region_info_source", "filesystem");

                config.Set("gridmode", false);
                config.Set("physics", "basicphysics");
                config.Set("meshing", "Meshmerizer");
                config.Set("physical_prim", true);
                config.Set("see_into_this_sim_from_neighbor", true);
                config.Set("serverside_object_permissions", false);
                config.Set("storage_plugin", "OpenSim.Data.SQLite.dll");
                config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3");
                config.Set("storage_prim_inventories", true);
                config.Set("startup_console_commands_file", String.Empty);
                config.Set("shutdown_console_commands_file", String.Empty);
                config.Set("DefaultScriptEngine", "XEngine");
                config.Set("asset_database", "default");
                config.Set("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
                // life doesn't really work without this
                config.Set("EventQueue", true);
            }

            {
                IConfig config = defaultConfig.Configs["StandAlone"];

                if (null == config)
                {
                    config = defaultConfig.AddConfig("StandAlone");
                }

                config.Set("accounts_authenticate", true);
                config.Set("welcome_message", "Welcome to Halcyon");
                config.Set("inventory_plugin", "OpenSim.Data.SQLite.dll");
                config.Set("inventory_connection_string", String.Empty);
                config.Set("userDatabase_plugin", "OpenSim.Data.SQLite.dll");
                config.Set("user_source", String.Empty);
                config.Set("asset_plugin", "OpenSim.Data.SQLite.dll");
                config.Set("asset_source", "URI=file:Asset.db,version=3");
                config.Set("LibraryName", "InWorldz Library");
                config.Set("LibrariesXMLFile", string.Format(".{0}inventory{0}Libraries.xml", Path.DirectorySeparatorChar));
                config.Set("AssetSetsXMLFile", string.Format(".{0}assets{0}AssetSets.xml", Path.DirectorySeparatorChar));
                config.Set("dump_assets_to_file", false);
            }

            {
                IConfig config = defaultConfig.Configs["Network"];

                if (null == config)
                {
                    config = defaultConfig.AddConfig("Network");
                }

                config.Set("default_location_x", 1000);
                config.Set("default_location_y", 1000);
                config.Set("http_listener_port", ConfigSettings.DefaultRegionHttpPort);
                config.Set("remoting_listener_port", ConfigSettings.DefaultRegionRemotingPort);
                config.Set("grid_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultGridServerHttpPort.ToString());
                config.Set("grid_send_key", "null");
                config.Set("grid_recv_key", "null");
                config.Set("user_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultUserServerHttpPort.ToString());
                config.Set("user_send_key", "null");
                config.Set("user_recv_key", "null");
                config.Set("asset_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultAssetServerHttpPort.ToString());
                config.Set("inventory_server_url", "http://127.0.0.1:" + ConfigSettings.DefaultInventoryServerHttpPort.ToString());
                config.Set("secure_inventory_server", "true");
            }

            return(defaultConfig);
        }
Beispiel #5
0
        public void TestCrossOnSameSimulatorNoRootDestPerm()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

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

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

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

            // We need to set up the permisions module on scene B so that our later use of agent limit to deny
            // QueryAccess won't succeed anyway because administrators are always allowed in and the default
            // IsAdministrator if no permissions module is present is true.
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new DefaultPermissionsModule(), etmB);

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

            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

            // Make sure sceneB will not accept this avatar.
            sceneB.RegionInfo.EstateSettings.PublicAccess = false;

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

            originalSp.AbsolutePosition = new Vector3(128, 32, 10);

            AgentUpdateArgs moveArgs = new AgentUpdateArgs();

            //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
            moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
            moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
            moveArgs.SessionID    = acd.SessionID;

            originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);

            sceneA.Update(1);

//            Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);

            // FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
            // But really we want to do this in a more robust way.
            for (int i = 0; i < 100; i++)
            {
                sceneA.Update(1);
//                Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
            }

            // sceneA agent should still be root
            ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);

            Assert.That(spAfterCrossSceneA.IsChildAgent, Is.False);

            ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);

            // sceneB agent should still be child
            Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);

            // sceneB should ignore unauthorized attempt to upgrade agent to root
            TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);

            int agentMovementCompleteReceived = 0;

            sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;

            sceneBTc.CompleteMovement();

            Assert.That(agentMovementCompleteReceived, Is.EqualTo(0));
            Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
        }
Beispiel #6
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));
        }
Beispiel #7
0
        public static void Configure(bool requested)
        {
            string WhiteCore_ConfigDir = Constants.DEFAULT_CONFIG_DIR;
            bool   isWhiteCoreExe      = AppDomain.CurrentDomain.FriendlyName == "WhiteCore.exe" ||
                                         AppDomain.CurrentDomain.FriendlyName == "WhiteCore.vshost.exe";

            bool existingConfig = (
                File.Exists(Path.Combine(WhiteCore_ConfigDir, "MyWorld.ini")) ||
                File.Exists(Path.Combine(WhiteCore_ConfigDir, "MyGrid.ini")) ||
                File.Exists(Path.Combine(WhiteCore_ConfigDir, "WhiteCore.ini")) ||
                File.Exists(Path.Combine(WhiteCore_ConfigDir, "WhiteCore.Server.ini"))
                );

            if (requested || !existingConfig)
            {
                string resp = "no";
                if (!requested)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n\n************* WhiteCore-Sim initial run. *************");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(
                        "\n\n   This appears to be your first time running WhiteCore-Sim.\n" +
                        "If you have already configured your *.ini files, please ignore this warning and press enter;\n" +
                        "Otherwise type 'yes' and WhiteCore-Sim will guide you through the configuration process.\n\n" +
                        "Remember, these file names are Case Sensitive in Linux and Proper Cased.\n" +
                        "1. " + WhiteCore_ConfigDir + "/WhiteCore.ini\nand\n" +
                        "2. " + WhiteCore_ConfigDir + "/Sim/Standalone/StandaloneCommon.ini \nor\n" +
                        "3. " + WhiteCore_ConfigDir + "/Grid/GridCommon.ini\n" +
                        "\nAlso, you will want to examine these files in great detail because only the basic system will " +
                        "load by default. WhiteCore-Sim can do a LOT more if you spend a little time going through these files.\n\n");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n\n************* WhiteCore-Sim Configuration *************");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(
                        "\n     WhiteCore interactive configuration.\n" +
                        "Enter 'yes' and WhiteCore-Sim will guide you through the configuration process.");
                }

                // Make sure...
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("");
                Console.WriteLine(" ## WARNING - WARNING - WARNING - WARNING - WARNING ##\n");
                Console.WriteLine("This will overwrite any existing configuration files!");
                Console.WriteLine("It is strongly recommended that you save a backup copy");
                Console.WriteLine("of your configuration files before proceeding!");
                Console.ResetColor();
                Console.WriteLine("");
                resp = ReadLine("Do you want to configure WhiteCore-Sim now?  (yes/no)", resp);

                if (resp == "yes")
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("\n     Just a moment... getting some details...\n");

                    string cfgFolder = WhiteCore_ConfigDir + "/";           // Main Config folder >> "../Config" (default)

                    string dbSource        = "localhost";
                    string dbPasswd        = "whitecore";
                    string dbSchema        = "whitecore";
                    string dbUser          = "******";
                    string dbPort          = "3306";
                    string gridIPAddress   = Utilities.GetExternalIp();
                    string regionIPAddress = gridIPAddress;
                    bool   isStandalone    = true;
                    string dbType          = "1";
                    string assetType       = "1";
                    string gridName        = "WhiteCore-Sim";
                    string welcomeMessage  = "";
                    string allowAnonLogin  = "******";
                    uint   port            = 8002;
                    uint   gridPort        = 8002;

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("====================================================================");
                    Console.WriteLine("======================= WhiteCore-Sim Configurator =================");
                    Console.WriteLine("====================================================================");
                    Console.ResetColor();

                    if (isWhiteCoreExe)
                    {
                        Console.WriteLine("This installation is going to run in");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("[1] Standalone Mode \n[2] Grid Mode");
                        Console.ResetColor();
                        isStandalone = ReadLine("Choose 1 or 2", "1") == "1";

                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("The domain name or IP address of this region server\nThe default is your external IP address");
                        Console.ResetColor();
                        regionIPAddress = ReadLine("Region server address: ", regionIPAddress);

                        Console.WriteLine("\nHttp Port for the region server");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("Default is 8002");
                        Console.ResetColor();
                        port = uint.Parse(ReadLine("Choose the port", "8002"));
                    }

                    if (isStandalone)
                    {
                        Console.WriteLine("Which database do you want to use?");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("[1] SQLite \n[2] MySQL");
                        Console.ResetColor();
                        dbType = ReadLine("Choose 1 or 2", dbType);
                        if (dbType == "2")
                        {
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.WriteLine(
                                "\nNote: this setup does not automatically create a MySQL installation for you.\n" +
                                " This will configure the WhiteCore setting but you must install MySQL as well");
                            Console.ResetColor();

                            dbSource = ReadLine("MySQL database IP", dbSource);
                            dbPort   = ReadLine("MySQL database port (if not default)", dbPort);
                            dbSchema = ReadLine("MySQL database name for your region", dbSchema);
                            dbUser   = ReadLine("MySQL database user account", dbUser);

                            Console.Write("MySQL database password for that account");
                            dbPasswd = Console.ReadLine();

                            Console.WriteLine("");
                        }
                    }

                    if (isStandalone)
                    {
                        gridName = ReadLine("Name of your WhiteCore-Sim server", gridName);

                        welcomeMessage          = "Welcome to " + gridName + ", <USERNAME>!";
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("\nEnter your 'Welcome Message' that each user will see during login\n" +
                                          "  (putting <USERNAME> into the welcome message will insert the user's name)");
                        Console.ResetColor();
                        welcomeMessage = ReadLine("Welcome Message", welcomeMessage);

                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine("\nAccounts can be created automatically when users log in for the first time.\n" +
                                          "  (This means you don't have to create all accounts manually using the console or web interface)");
                        Console.ResetColor();

                        allowAnonLogin = ReadLine("Create accounts automatically?", allowAnonLogin);
                    }

                    if (!isStandalone)
                    {
                        gridIPAddress =
                            ReadLine("The domain name or IP address of the grid server you wish to connect to",
                                     gridIPAddress);
                    }

                    //Data.ini setup
                    if (isStandalone)
                    {
                        string cfgDataFolder = isWhiteCoreExe ? "Sim/" : "Grid/ServerConfiguration/";

                        MakeSureExists(cfgFolder + cfgDataFolder + "Data/Data.ini");
                        var data_ini = new IniConfigSource(
                            cfgFolder + cfgDataFolder + "Data/Data.ini",
                            Nini.Ini.IniFileType.AuroraStyle);

                        IConfig conf = data_ini.AddConfig("DataFile");

                        // DB include
                        if (dbType == "1")
                        {
                            conf.Set("Include-SQLite", cfgDataFolder + "Data/SQLite.ini");
                        }
                        else
                        {
                            conf.Set("Include-MySQL", cfgDataFolder + "Data/MySQL.ini");
                        }

                        if (isWhiteCoreExe)
                        {
                            conf.Set("Include-FileBased", "Sim/Data/FileBased.ini");
                        }


                        // Asset services
                        conf = data_ini.AddConfig("Handlers");

                        Console.WriteLine("Which asset service do you want to use?");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("[1] File based\n[2] SQL");
                        Console.ResetColor();
                        assetType = ReadLine("Choose 1 or 2", assetType);
                        if (assetType == "2")
                        {
                            conf.Set("AssetHandler", "AssetService");
                        }
                        else
                        {
                            conf.Set("AssetHandler", "FileBasedAssetService");
                        }
                        conf.Set("AssetHandlerUseCache", false);

                        conf = data_ini.AddConfig("WhiteCoreConnectors");
                        conf.Set("ValidateTables", true);


                        data_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your Data.ini has been successfully configured");
                        Console.ResetColor();

                        // MySql setup
                        if (dbType == "2")
                        {
                            MakeSureExists(cfgFolder + cfgDataFolder + "Data/MySQL.ini");
                            var mysql_ini = new IniConfigSource(
                                cfgFolder + cfgDataFolder + "Data/MySQL.ini",
                                Nini.Ini.IniFileType.AuroraStyle);
                            var mysql_ini_example = new IniConfigSource(
                                cfgFolder + cfgDataFolder + "Data/MySQL.ini.example",
                                Nini.Ini.IniFileType.AuroraStyle);

                            foreach (IConfig config in mysql_ini_example.Configs)
                            {
                                IConfig newConfig = mysql_ini.AddConfig(config.Name);
                                foreach (string key in config.GetKeys())
                                {
                                    if (key == "ConnectionString")
                                    {
                                        newConfig.Set(key,
                                                      string.Format(
                                                          "\"Data Source={0};Port={1};Database={2};User ID={3};Password={4};Charset=utf8;\"",
                                                          dbSource, dbPort, dbSchema, dbUser, dbPasswd));
                                    }
                                    else
                                    {
                                        newConfig.Set(key, config.Get(key));
                                    }
                                }
                            }

                            mysql_ini.Save();
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("Your MySQL.ini has been successfully configured");
                            Console.ResetColor();
                        }
                    }

                    // Region server
                    if (isWhiteCoreExe)
                    {
                        MakeSureExists(cfgFolder + "WhiteCore.ini");
                        var whitecore_ini = new IniConfigSource(
                            cfgFolder + "WhiteCore.ini",
                            Nini.Ini.IniFileType.AuroraStyle);
                        var whitecore_ini_example = new IniConfigSource(
                            cfgFolder + "WhiteCore.ini.example",
                            Nini.Ini.IniFileType.AuroraStyle);

                        bool setIp = false;

                        foreach (IConfig config in whitecore_ini_example.Configs)
                        {
                            IConfig newConfig = whitecore_ini.AddConfig(config.Name);
                            foreach (string key in config.GetKeys())
                            {
                                if (key == "http_listener_port")
                                {
                                    newConfig.Set(key, port);
                                }
                                else if (key == "HostName")
                                {
                                    setIp = true;
                                    newConfig.Set(key, regionIPAddress);
                                }
                                else
                                {
                                    newConfig.Set(key, config.Get(key));
                                }
                            }

                            if ((config.Name == "Network") & !setIp)
                            {
                                setIp = true;
                                newConfig.Set("HostName", regionIPAddress);
                            }
                        }

                        whitecore_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your WhiteCore.ini has been successfully configured");
                        Console.ResetColor();

                        MakeSureExists(cfgFolder + "Sim/Main.ini");
                        var main_ini = new IniConfigSource(
                            cfgFolder + "Sim/Main.ini",
                            Nini.Ini.IniFileType.AuroraStyle);

                        IConfig conf = main_ini.AddConfig("Architecture");
                        if (isStandalone)
                        {
                            conf.Set("Include-Standalone", "Sim/Standalone/StandaloneCommon.ini");
                        }
                        else
                        {
                            conf.Set("Include-Grid", "Sim/Grid/GridCommon.ini");
                        }
                        conf.Set("Include-Includes", "Sim/Includes.ini");

                        main_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your Main.ini has been successfully configured");
                        Console.ResetColor();

                        if (isStandalone)
                        {
                            MakeSureExists(cfgFolder + "Sim/Standalone/StandaloneCommon.ini");
                            var standalone_ini = new IniConfigSource(
                                cfgFolder + "Sim/Standalone/StandaloneCommon.ini",
                                Nini.Ini.IniFileType.AuroraStyle);
                            var standalone_ini_example = new IniConfigSource(
                                cfgFolder + "Sim/Standalone/StandaloneCommon.ini.example",
                                Nini.Ini.IniFileType.AuroraStyle);

                            foreach (IConfig config in standalone_ini_example.Configs)
                            {
                                IConfig newConfig = standalone_ini.AddConfig(config.Name);
                                if (newConfig.Name == "GridInfoService")
                                {
                                    newConfig.Set("GridInfoInHandlerPort", 0);
                                    newConfig.Set("login", "http://" + gridIPAddress + ":" + port + "/");
                                    newConfig.Set("gridname", gridName);
                                    newConfig.Set("gridnick", gridName);
                                }
                                else
                                {
                                    foreach (string key in config.GetKeys())
                                    {
                                        if (key == "WelcomeMessage")
                                        {
                                            newConfig.Set(key, welcomeMessage);
                                        }
                                        else if (key == "AllowAnonymousLogin")
                                        {
                                            newConfig.Set(key, allowAnonLogin);
                                        }
                                        else
                                        {
                                            newConfig.Set(key, config.Get(key));
                                        }
                                    }
                                }
                            }

                            standalone_ini.Save();
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("Your StandaloneCommon.ini has been successfully configured");
                            Console.ResetColor();
                        }
                        else
                        {
                            MakeSureExists(cfgFolder + "Sim/Grid/GridCommon.ini");
                            var grid_ini = new IniConfigSource(
                                cfgFolder + "Sim/Grid/GridCommon.ini",
                                Nini.Ini.IniFileType.AuroraStyle);

                            conf = grid_ini.AddConfig("Includes");
                            conf.Set("Include-Grid", "Sim/Grid/Grid.ini");
                            conf = grid_ini.AddConfig("Configuration");
                            conf.Set("GridServerURI", "http://" + gridIPAddress + ":8012/grid/");
                            //Lets tell the Configurator to create the missing .ini entrys from the .example file
                            conf.Set("SendGridInfoToViewerOnLogin", "true");
                            conf.Set("CurrencySymbol", "\"WC$\"");
                            conf.Set(";;DISABLED BY DEFAULT GENERATED BY CONFIGURATOR", "");
                            conf.Set(";;welcome", "http://" + gridIPAddress + "/welcome");
                            conf.Set(";;economy", "http://" + gridIPAddress + ":8009/");
                            conf.Set(";;about", "http://" + gridIPAddress + "/about");
                            conf.Set(";;register", "http://" + gridIPAddress + "/register");
                            conf.Set(";;help", "http://" + gridIPAddress + "/help");
                            conf.Set(";;forgottenpassword", "http://" + gridIPAddress + "/password");
                            conf.Set(";;map", "");
                            conf.Set(";;webprofile", "");
                            conf.Set(";;search", "");
                            conf.Set(";;destination", "");
                            conf.Set(";;marketplace", "");
                            conf.Set(";;tutorial", "");
                            conf.Set(";;message", "\"this is a test message\"");
                            conf.Set(";;snapshotconfig", "");
                            conf.Set(";;RealCurrencySymbol", "\"$\"");
                            conf.Set(";;MaxGroups", "50");
                            grid_ini.Save();
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("Your Grid.ini has been successfully configured");
                            Console.ResetColor();
                            Console.WriteLine("");
                        }
                    }

                    // Grid server
                    if (!isWhiteCoreExe)
                    {
                        MakeSureExists(cfgFolder + "WhiteCore.Server.ini");
                        var whitecore_ini = new IniConfigSource(
                            cfgFolder + "WhiteCore.Server.ini",
                            Nini.Ini.IniFileType.AuroraStyle);
                        var whitecore_ini_example = new IniConfigSource(
                            cfgFolder + "WhiteCore.Server.ini.example",
                            Nini.Ini.IniFileType.AuroraStyle);

                        gridIPAddress =
                            ReadLine("\nThe domain name or IP address of the grid server", gridIPAddress);
                        bool ipSet = false;

                        foreach (IConfig config in whitecore_ini_example.Configs)
                        {
                            IConfig newConfig = whitecore_ini.AddConfig(config.Name);
                            foreach (string key in config.GetKeys())
                            {
                                if (key == "HostName")
                                {
                                    ipSet = true;
                                    newConfig.Set(key, gridIPAddress);
                                }
                                else
                                {
                                    newConfig.Set(key, config.Get(key));
                                }
                            }

                            if ((config.Name == "Network") & !ipSet)
                            {
                                ipSet = true;
                                newConfig.Set("HostName", gridIPAddress);
                            }
                        }

                        whitecore_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your WhiteCore.Server.ini has been successfully configured");
                        Console.ResetColor();

                        MakeSureExists(cfgFolder + "Grid/ServerConfiguration/Login.ini");
                        var login_ini = new IniConfigSource(
                            cfgFolder + "Grid/ServerConfiguration/Login.ini",
                            Nini.Ini.IniFileType.AuroraStyle);
                        var login_ini_example = new IniConfigSource(
                            cfgFolder + "Grid/ServerConfiguration/Login.ini.example",
                            Nini.Ini.IniFileType.AuroraStyle);

                        Console.WriteLine("\nHttp Port for the grid server");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("Default is 8002");
                        Console.ResetColor();
                        gridPort = uint.Parse(ReadLine("Choose the port", "8002"));

                        foreach (IConfig config in login_ini_example.Configs)
                        {
                            IConfig newConfig = login_ini.AddConfig(config.Name);
                            foreach (string key in config.GetKeys())
                            {
                                if (key == "WelcomeMessage")
                                {
                                    newConfig.Set(key, welcomeMessage);
                                }
                                else if (key == "AllowAnonymousLogin")
                                {
                                    newConfig.Set(key, allowAnonLogin);
                                }
                                else
                                {
                                    newConfig.Set(key, config.Get(key));
                                }
                            }
                        }

                        login_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your Login.ini has been successfully configured");
                        Console.ResetColor();

                        MakeSureExists(cfgFolder + "Grid/ServerConfiguration/GridInfoService.ini");
                        var grid_info_ini = new IniConfigSource(
                            cfgFolder + "Grid/ServerConfiguration/GridInfoService.ini",
                            Nini.Ini.IniFileType.AuroraStyle);

                        IConfig conf = grid_info_ini.AddConfig("GridInfoService");
                        conf.Set("GridInfoInHandlerPort", gridPort);
                        conf.Set("login", "http://" + gridIPAddress + ":" + gridPort + "/");
                        conf.Set("gridname", gridName);
                        conf.Set("gridnick", gridName);

                        grid_info_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your GridInfoService.ini has been successfully configured");
                        Console.ResetColor();
                        Console.WriteLine("");
                    }

                    Console.WriteLine("\n====================================================================\n");
                    Console.ResetColor();
                    Console.WriteLine("Your grid name is ");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine(gridName);
                    Console.ResetColor();
                    if (isStandalone)
                    {
                        Console.WriteLine("\nYour loginuri is ");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("http://" + (isWhiteCoreExe ? regionIPAddress : gridIPAddress) + ":" + (isWhiteCoreExe ? port : gridPort) + "/");
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.WriteLine("\nConnected Grid URL: ");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("http://" + gridIPAddress + ":" + gridPort + "/");
                        Console.ResetColor();
                    }
                    Console.WriteLine("\n====================================================================\n");
                    Console.WriteLine(
                        "To re-run this configurator, enter \"run configurator\" into the console.");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(" >> Please restart WhiteCore-Sim to use your new configuration. <<");
                    Console.ResetColor();
                    Console.WriteLine("");
                }
            }
        }
        public void TestSameSimulatorIsolatedRegionsV2()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

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

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

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

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

            ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);

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

            List <TestClient> destinationTestClients = new List <TestClient>();

            EntityTransferHelpers.SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement(
                (TestClient)sp.ControllingClient, destinationTestClients);

            sceneA.RequestTeleportLocation(
                sp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            Assert.That(sceneA.GetScenePresence(userId), Is.Null);

            ScenePresence sceneBSp = sceneB.GetScenePresence(userId);

            Assert.That(sceneBSp, Is.Not.Null);
            Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
            Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
        }
        public void TestSameSimulatorIsolatedRegions_DeniedOnCreateAgent()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID    userId = TestHelpers.ParseTail(0x1);
            Vector3 preTeleportPosition = new Vector3(30, 31, 32);

            EntityTransferModule           etmA = new EntityTransferModule();
            EntityTransferModule           etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();

            config.AddConfig("Modules");
            config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
            config.Configs["Modules"].Set("SimulationServices", lscm.Name);

            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.
            config.Configs["EntityTransfer"].Set("wait_for_callback", false);

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

            SceneHelpers.SetupSceneModules(sceneA, config, etmA);
            SceneHelpers.SetupSceneModules(sceneB, config, etmB);

            // Shared scene modules
            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);

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

            ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);

            sp.AbsolutePosition = preTeleportPosition;

            // Make sceneB refuse CreateAgent
            sceneB.LoginsEnabled = false;

            sceneA.RequestTeleportLocation(
                sp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

//            ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();

            Assert.That(sceneB.GetScenePresence(userId), Is.Null);

            ScenePresence sceneASp = sceneA.GetScenePresence(userId);

            Assert.That(sceneASp, Is.Not.Null);
            Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
            Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));

//            TestHelpers.DisableLogging();
        }
Beispiel #10
0
        public static void Configure(bool requested)
        {
            bool Aurora_log        = (File.Exists(Path.Combine(Util.configDir(), "Aurora.log")));
            bool Aurora_Server_log = (File.Exists(Path.Combine(Util.configDir(), "Aurora.Server.log")));
            bool isAuroraExe       = System.AppDomain.CurrentDomain.FriendlyName == "Aurora.exe" ||
                                     System.AppDomain.CurrentDomain.FriendlyName == "Aurora.vshost.exe";

            if (requested || !(isAuroraExe
                                   ? Aurora_log
                                   : Aurora_Server_log))
            {
                string resp = "no";
                if (!requested)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n\n*************Required Configuration files not found.*************");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine(
                        "\n\n   This is your first time running Aurora, if not and you already configured your " +
                        "*ini.example files, please ignore this warning and press enter; " +
                        "Otherwise type yes and Aurora will guide you trough configuration files.\n\nRemember, " +
                        "these file names are Case Sensitive in Linux and Proper Cased.\n1. ./Aurora.ini\nand\n2. " +
                        "./Configuration/Standalone/StandaloneCommon.ini \nor\n3. ./Configuration/Grid/GridCommon.ini\n" +
                        "\nAlso, you will want to examine these files in great detail because only the basic system will " +
                        "load by default. Aurora can do a LOT more if you spend a little time going through these files.\n\n");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("This will overwrite any existing configuration files for your sim");
                    Console.ResetColor();
                    resp = ReadLine("Do you want to configure Aurora now", resp);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("This will overwrite any existing configuration files for your sim");
                    Console.ResetColor();
                    resp = ReadLine("Do you want to configure Aurora now", resp);
                }
                if (resp == "yes")
                {
                    string dbSource       = "localhost";
                    string dbPasswd       = "aurora";
                    string dbSchema       = "aurora";
                    string dbUser         = "******";
                    string gridIPAddress  = Utilities.GetExternalIp();
                    bool   isStandalone   = true;
                    string dbType         = "1";
                    string gridName       = "Aurora-Sim Grid";
                    string welcomeMessage = "";
                    string allowAnonLogin = "******";
                    uint   port           = 9000;
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("====================================================================");
                    Console.WriteLine("========================= AURORA CONFIGURATOR ======================");
                    Console.WriteLine("====================================================================");
                    Console.ResetColor();

                    if (isAuroraExe)
                    {
                        Console.WriteLine("This installation is going to run in");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("[1] Standalone Mode \n[2] Grid Mode");
                        Console.ResetColor();
                        isStandalone = ReadLine("Choose 1 or 2", "1") == "1";


                        Console.WriteLine("Http Port for the server");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("Default is 9000");
                        Console.ResetColor();
                        port = uint.Parse(ReadLine("Choose the port", "9000"));
                    }

                    if (isStandalone)
                    {
                        Console.WriteLine("Which database do you want to use?");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("[1] SQLite \n[2] MySQL");
                        Console.ResetColor();
                        dbType = ReadLine("Choose 1 or 2", dbType);
                        if (dbType == "2")
                        {
                            Console.WriteLine(
                                "Note: this setup does not automatically create a MySQL installation for you.\n" +
                                "You must install MySQL on your own");

                            dbSchema = ReadLine("MySQL database name for your region", dbSchema);
                            dbSource = ReadLine("MySQL database IP", dbSource);
                            dbUser   = ReadLine("MySQL database user account", dbUser);

                            Console.Write("MySQL database password for that account: ");
                            dbPasswd = Console.ReadLine();
                        }
                    }

                    if (isStandalone)
                    {
                        gridName = ReadLine("Name of your Aurora-Sim Grid", gridName);

                        welcomeMessage = "Welcome to " + gridName + ", <USERNAME>!";
                        welcomeMessage = ReadLine("Welcome Message to show during login (putting <USERNAME> into the " +
                                                  "welcome message will insert the user's name)", welcomeMessage);

                        allowAnonLogin = ReadLine("Create accounts automatically when users log in " +
                                                  "(you don't have to create all accounts manually or have a web interface then)",
                                                  allowAnonLogin);
                    }

                    if (!isStandalone)
                    {
                        gridIPAddress =
                            ReadLine("The external domain name or IP address of the grid server you wish to connect to",
                                     gridIPAddress);
                    }

                    //Data.ini setup
                    if (isStandalone)
                    {
                        string folder = isAuroraExe ? "Configuration/" : "AuroraServerConfiguration/";
                        MakeSureExists(folder + "Data/Data.ini");
                        IniConfigSource data_ini = new IniConfigSource(folder + "Data/Data.ini",
                                                                       Nini.Ini.IniFileType.AuroraStyle);
                        IConfig conf = data_ini.AddConfig("DataFile");
                        if (dbType == "1")
                        {
                            conf.Set("Include-SQLite", folder + "Data/SQLite.ini");
                        }
                        else
                        {
                            conf.Set("Include-MySQL", folder + "Data/MySQL.ini");
                        }

                        if (isAuroraExe)
                        {
                            conf.Set("Include-FileBased", "Configuration/Data/FileBased.ini");
                        }

                        conf = data_ini.AddConfig("AuroraConnectors");
                        conf.Set("ValidateTables", true);

                        data_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your Data.ini has been successfully configured");
                        Console.ResetColor();

                        if (dbType == "2") //MySQL setup
                        {
                            MakeSureExists(folder + "Data/MySQL.ini");
                            IniConfigSource mysql_ini = new IniConfigSource(folder + "Data/MySQL.ini",
                                                                            Nini.Ini.IniFileType.AuroraStyle);
                            IniConfigSource mysql_ini_example = new IniConfigSource(folder + "Data/MySQL.ini.example",
                                                                                    Nini.Ini.IniFileType.AuroraStyle);
                            foreach (IConfig config in mysql_ini_example.Configs)
                            {
                                IConfig newConfig = mysql_ini.AddConfig(config.Name);
                                foreach (string key in config.GetKeys())
                                {
                                    if (key == "ConnectionString")
                                    {
                                        newConfig.Set(key,
                                                      string.Format(
                                                          "\"Data Source={0};Port=3306;Database={1};User ID={2};Password={3};\"",
                                                          dbSource, dbSchema, dbUser, dbPasswd));
                                    }
                                    else
                                    {
                                        newConfig.Set(key, config.Get(key));
                                    }
                                }
                            }
                            mysql_ini.Save();
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("Your MySQL.ini has been successfully configured");
                            Console.ResetColor();
                        }
                    }

                    if (isAuroraExe)
                    {
                        MakeSureExists("Aurora.ini");
                        IniConfigSource aurora_ini         = new IniConfigSource("Aurora.ini", Nini.Ini.IniFileType.AuroraStyle);
                        IniConfigSource aurora_ini_example = new IniConfigSource("Aurora.ini.example", Nini.Ini.IniFileType.AuroraStyle);

                        foreach (IConfig config in aurora_ini_example.Configs)
                        {
                            IConfig newConfig = aurora_ini.AddConfig(config.Name);
                            foreach (string key in config.GetKeys())
                            {
                                if (key == "http_listener_port")
                                {
                                    newConfig.Set(key, port);
                                }
                                else
                                {
                                    newConfig.Set(key, config.Get(key));
                                }
                            }
                        }

                        aurora_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your Aurora.ini has been successfully configured");
                        Console.ResetColor();

                        MakeSureExists("Configuration/Main.ini");
                        IniConfigSource main_ini = new IniConfigSource("Configuration/Main.ini",
                                                                       Nini.Ini.IniFileType.AuroraStyle);

                        IConfig conf = main_ini.AddConfig("Architecture");
                        if (isStandalone)
                        {
                            conf.Set("Include-Standalone", "Configuration/Standalone/StandaloneCommon.ini");
                        }
                        else
                        {
                            conf.Set("Include-Grid", "Configuration/Grid/AuroraGridCommon.ini");
                        }
                        conf.Set("Include-Includes", "Configuration/Includes.ini");

                        main_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your Main.ini has been successfully configured");
                        Console.ResetColor();

                        if (isStandalone)
                        {
                            MakeSureExists("Configuration/Standalone/StandaloneCommon.ini");
                            IniConfigSource standalone_ini =
                                new IniConfigSource("Configuration/Standalone/StandaloneCommon.ini",
                                                    Nini.Ini.IniFileType.AuroraStyle);
                            IniConfigSource standalone_ini_example =
                                new IniConfigSource("Configuration/Standalone/StandaloneCommon.ini.example",
                                                    Nini.Ini.IniFileType.AuroraStyle);
                            foreach (IConfig config in standalone_ini_example.Configs)
                            {
                                IConfig newConfig = standalone_ini.AddConfig(config.Name);
                                if (newConfig.Name == "GridInfoService")
                                {
                                    newConfig.Set("GridInfoInHandlerPort", 0);
                                    newConfig.Set("login", "http://" + gridIPAddress + ":9000/");
                                    newConfig.Set("gridname", gridName);
                                    newConfig.Set("gridnick", gridName);
                                }
                                else
                                {
                                    foreach (string key in config.GetKeys())
                                    {
                                        if (key == "WelcomeMessage")
                                        {
                                            newConfig.Set(key, welcomeMessage);
                                        }
                                        else if (key == "AllowAnonymousLogin")
                                        {
                                            newConfig.Set(key, allowAnonLogin);
                                        }
                                        else
                                        {
                                            newConfig.Set(key, config.Get(key));
                                        }
                                    }
                                }
                            }

                            standalone_ini.Save();
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("Your StandaloneCommon.ini has been successfully configured");
                            Console.ResetColor();
                        }
                        else
                        {
                            MakeSureExists("Configuration/Grid/AuroraGridCommon.ini");
                            IniConfigSource grid_ini = new IniConfigSource("Configuration/Grid/AuroraGridCommon.ini",
                                                                           Nini.Ini.IniFileType.AuroraStyle);

                            conf = grid_ini.AddConfig("Includes");
                            conf.Set("Include-Grid", "Configuration/Grid/Grid.ini");
                            conf = grid_ini.AddConfig("Configuration");
                            conf.Set("GridServerURI", "http://" + gridIPAddress + ":8012/grid/");

                            grid_ini.Save();
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine("Your Grid.ini has been successfully configured");
                            Console.ResetColor();
                        }
                    }
                    if (!isAuroraExe)
                    {
                        MakeSureExists("AuroraServerConfiguration/Login.ini");
                        IniConfigSource login_ini = new IniConfigSource("AuroraServerConfiguration/Login.ini",
                                                                        Nini.Ini.IniFileType.AuroraStyle);
                        IniConfigSource login_ini_example =
                            new IniConfigSource("AuroraServerConfiguration/Login.ini.example",
                                                Nini.Ini.IniFileType.AuroraStyle);
                        foreach (IConfig config in login_ini_example.Configs)
                        {
                            IConfig newConfig = login_ini.AddConfig(config.Name);
                            foreach (string key in config.GetKeys())
                            {
                                if (key == "WelcomeMessage")
                                {
                                    newConfig.Set(key, welcomeMessage);
                                }
                                else if (key == "AllowAnonymousLogin")
                                {
                                    newConfig.Set(key, allowAnonLogin);
                                }
                                else
                                {
                                    newConfig.Set(key, config.Get(key));
                                }
                            }
                        }
                        login_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your Login.ini has been successfully configured");
                        Console.ResetColor();

                        MakeSureExists("AuroraServerConfiguration/GridInfoService.ini");
                        IniConfigSource grid_info_ini =
                            new IniConfigSource("AuroraServerConfiguration/GridInfoService.ini",
                                                Nini.Ini.IniFileType.AuroraStyle);
                        IConfig conf = grid_info_ini.AddConfig("GridInfoService");
                        conf.Set("GridInfoInHandlerPort", 8002);
                        conf.Set("login", "http://" + gridIPAddress + ":8002");
                        conf.Set("gridname", gridName);
                        conf.Set("gridnick", gridName);

                        grid_info_ini.Save();
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Your GridInfoService.ini has been successfully configured");
                        Console.ResetColor();
                    }

                    Console.WriteLine("\n====================================================================\n");
                    Console.ResetColor();
                    Console.WriteLine("Your grid name is ");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine(gridName);
                    Console.ResetColor();
                    if (isStandalone)
                    {
                        Console.WriteLine("\nYour loginuri is ");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("http://" + gridIPAddress + (isAuroraExe ? ":9000/" : ":8002/"));
                        Console.ResetColor();
                    }
                    else
                    {
                        Console.WriteLine("\nConnected Grid URL: ");
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("http://" + gridIPAddress + ":8002/");
                        Console.ResetColor();
                    }
                    Console.WriteLine("\n====================================================================\n");
                    Console.WriteLine(
                        "If you ever want to rerun this configurator, you can type \"run configurator\" into the console to bring this prompt back up.");
                }
            }
        }
        public void TestSameSimulatorIsolatedRegionsV1()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

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

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

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

            // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
            lscm.ServiceVersion = "SIMULATION/0.1";

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

            ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);

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

            List <TestClient> destinationTestClients = new List <TestClient>();

            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
                (TestClient)sp.ControllingClient, destinationTestClients);

            sceneA.RequestTeleportLocation(
                sp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            // SetupInformClientOfNeighbour() will have handled the callback into the target scene to setup the child
            // agent.  This call will now complete the movement of the user into the destination and upgrade the agent
            // from child to root.
            destinationTestClients[0].CompleteMovement();

            Assert.That(sceneA.GetScenePresence(userId), Is.Null);

            ScenePresence sceneBSp = sceneB.GetScenePresence(userId);

            Assert.That(sceneBSp, Is.Not.Null);
            Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
            Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
        }
Beispiel #12
0
        private void HandleConfig(string module, string[] cmd)
        {
            List <string> args = new List <string>(cmd);

            args.RemoveAt(0);
            string[] cmdparams = args.ToArray();
            string   n         = "CONFIG";

            if (cmdparams.Length > 0)
            {
                switch (cmdparams[0].ToLower())
                {
                case "set":
                    if (cmdparams.Length < 4)
                    {
                        m_log.Error("SYNTAX: " + n + " SET SECTION KEY VALUE");
                        m_log.Error("EXAMPLE: " + n + " SET ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
                    }
                    else
                    {
                        IConfig       c;
                        IConfigSource source = new IniConfigSource();
                        c = source.AddConfig(cmdparams[1]);
                        if (c != null)
                        {
                            string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
                            c.Set(cmdparams[2], _value);
                            m_config.Source.Merge(source);

                            m_log.Error(n + " " + n + " " + cmdparams[1] + " " + cmdparams[2] + " " +
                                        _value);
                        }
                    }
                    break;

                case "get":
                    if (cmdparams.Length < 3)
                    {
                        m_log.Error("SYNTAX: " + n + " GET SECTION KEY");
                        m_log.Error("EXAMPLE: " + n + " GET ScriptEngine.DotNetEngine NumberOfScriptThreads");
                    }
                    else
                    {
                        IConfig c = m_config.Source.Configs[cmdparams[1]];
                        if (c == null)
                        {
                            m_log.Info("Section \"" + cmdparams[1] + "\" does not exist.");
                            break;
                        }
                        else
                        {
                            m_log.Info(n + " GET " + cmdparams[1] + " " + cmdparams[2] + ": " +
                                       c.GetString(cmdparams[2]));
                        }
                    }

                    break;

                case "save":
                    m_log.Info("Saving configuration file: " + Application.iniFilePath);
                    m_config.Save(Application.iniFilePath);
                    break;
                }
            }
        }
Beispiel #13
0
 static internal IConfig AddSection(string section)
 {
     return(Parser.AddConfig(section));
 }
        public void TestSameSimulatorNeighbouringRegionsTeleport()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

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

            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);
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);

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

            ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);

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

            ScenePresence beforeSceneASp = sceneA.GetScenePresence(userId);

            Assert.That(beforeSceneASp, Is.Not.Null);
            Assert.That(beforeSceneASp.IsChildAgent, Is.False);

            ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);

            Assert.That(beforeSceneBSp, Is.Not.Null);
            Assert.That(beforeSceneBSp.IsChildAgent, Is.True);

            // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole
            // UDP stack (?)
//            ((TestClient)beforeSceneASp.ControllingClient).TeleportTargetScene = sceneB;

            sceneA.RequestTeleportLocation(
                beforeSceneASp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            ((TestClient)beforeSceneASp.ControllingClient).CompleteTeleportClientSide();

            ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);

            Assert.That(afterSceneASp, Is.Not.Null);
            Assert.That(afterSceneASp.IsChildAgent, Is.True);

            ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);

            Assert.That(afterSceneBSp, Is.Not.Null);
            Assert.That(afterSceneBSp.IsChildAgent, Is.False);
            Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
            Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));

//            TestHelpers.DisableLogging();
        }
        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.
        }
        public void TestSameSimulatorIsolatedRegions_DestinationDidNotProcessViewerConnection()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID    userId = TestHelpers.ParseTail(0x1);
            Vector3 preTeleportPosition = new Vector3(30, 31, 32);

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();

            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();

            config.AddConfig("Modules");
            config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
            config.Configs["Modules"].Set("SimulationServices", lscm.Name);

            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.
            config.Configs["EntityTransfer"].Set("wait_for_callback", false);

//            config.AddConfig("Startup");
//            config.Configs["Startup"].Set("serverside_object_permissions", true);

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

            SceneHelpers.SetupSceneModules(sceneA, config, etmA);

            // We need to set up the permisions module on scene B so that our later use of agent limit to deny
            // QueryAccess won't succeed anyway because administrators are always allowed in and the default
            // IsAdministrator if no permissions module is present is true.
            SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB });

            // Shared scene modules
            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);

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

            ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);

            sp.AbsolutePosition = preTeleportPosition;

            sceneA.RequestTeleportLocation(
                sp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            // FIXME: Not setting up InformClientOfNeighbour on the TestClient means that it does not initiate
            // communication with the destination region.  But this is a very non-obvious way of doing it - really we
            // should be forced to expicitly set this up.

            Assert.That(sceneB.GetScenePresence(userId), Is.Null);

            ScenePresence sceneASp = sceneA.GetScenePresence(userId);

            Assert.That(sceneASp, Is.Not.Null);
            Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
            Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));

//            TestHelpers.DisableLogging();
        }
        public void TestSameSimulatorNeighbouringRegionsTeleportV1()
        {
            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);
            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());

            // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
            lscm.ServiceVersion = "SIMULATION/0.1";

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

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

            destinationTestClients[0].CompleteMovement();

            // 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));
        }
        public void TestSameSimulatorNeighbouringRegionsV1()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

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

            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);
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);

            // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
            lscm.ServiceVersion = "SIMULATION/0.1";

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

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

            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

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

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

            Assert.That(beforeSceneASp, Is.Not.Null);
            Assert.That(beforeSceneASp.IsChildAgent, Is.False);

            ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);

            Assert.That(beforeSceneBSp, Is.Not.Null);
            Assert.That(beforeSceneBSp.IsChildAgent, Is.True);

            // In this case, we will not receieve a second InformClientOfNeighbour since the viewer already knows
            // about the neighbour region it is teleporting to.
            sceneA.RequestTeleportLocation(
                beforeSceneASp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            destinationTestClients[0].CompleteMovement();

            ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);

            Assert.That(afterSceneASp, Is.Not.Null);
            Assert.That(afterSceneASp.IsChildAgent, Is.True);

            ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);

            Assert.That(afterSceneBSp, Is.Not.Null);
            Assert.That(afterSceneBSp.IsChildAgent, Is.False);
            Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
            Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));

//            TestHelpers.DisableLogging();
        }
        /// <summary>
        /// Change and load configuration file data.
        /// </summary>
        /// <param name="module"></param>
        /// <param name="cmd"></param>
        private void HandleConfig(string module, string[] cmd)
        {
            List <string> args = new List <string>(cmd);

            args.RemoveAt(0);
            string[] cmdparams = args.ToArray();

            if (cmdparams.Length > 0)
            {
                string firstParam = cmdparams[0].ToLower();

                switch (firstParam)
                {
                case "set":
                    if (cmdparams.Length < 4)
                    {
                        Notice("Syntax: config set <section> <key> <value>");
                        Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5");
                    }
                    else
                    {
                        IConfig       c;
                        IConfigSource source = new IniConfigSource();
                        c = source.AddConfig(cmdparams[1]);
                        if (c != null)
                        {
                            string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3);
                            c.Set(cmdparams[2], _value);
                            Config.Merge(source);

                            Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value);
                        }
                    }
                    break;

                case "get":
                case "show":
                    if (cmdparams.Length == 1)
                    {
                        foreach (IConfig config in Config.Configs)
                        {
                            Notice("[{0}]", config.Name);
                            string[] keys = config.GetKeys();
                            foreach (string key in keys)
                            {
                                Notice("  {0} = {1}", key, config.GetString(key));
                            }
                        }
                    }
                    else if (cmdparams.Length == 2 || cmdparams.Length == 3)
                    {
                        IConfig config = Config.Configs[cmdparams[1]];
                        if (config == null)
                        {
                            Notice("Section \"{0}\" does not exist.", cmdparams[1]);
                            break;
                        }
                        else
                        {
                            if (cmdparams.Length == 2)
                            {
                                Notice("[{0}]", config.Name);
                                foreach (string key in config.GetKeys())
                                {
                                    Notice("  {0} = {1}", key, config.GetString(key));
                                }
                            }
                            else
                            {
                                Notice(
                                    "config get {0} {1} : {2}",
                                    cmdparams[1], cmdparams[2], config.GetString(cmdparams[2]));
                            }
                        }
                    }
                    else
                    {
                        Notice("Syntax: config {0} [<section>] [<key>]", firstParam);
                        Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam);
                    }

                    break;

                case "save":
                    if (cmdparams.Length < 2)
                    {
                        Notice("Syntax: config save <path>");
                        return;
                    }

                    string path = cmdparams[1];
                    Notice("Saving configuration file: {0}", path);

                    if (Config is IniConfigSource)
                    {
                        IniConfigSource iniCon = (IniConfigSource)Config;
                        iniCon.Save(path);
                    }
                    else if (Config is XmlConfigSource)
                    {
                        XmlConfigSource xmlCon = (XmlConfigSource)Config;
                        xmlCon.Save(path);
                    }

                    break;
                }
            }
        }
        public void TestSameSimulatorNeighbouringRegionsV2()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

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

            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);
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);

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

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

            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

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

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

            Assert.That(beforeSceneASp, Is.Not.Null);
            Assert.That(beforeSceneASp.IsChildAgent, Is.False);

            ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);

            Assert.That(beforeSceneBSp, Is.Not.Null);
            Assert.That(beforeSceneBSp.IsChildAgent, Is.True);

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

            sceneA.RequestTeleportLocation(
                beforeSceneASp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);

            Assert.That(afterSceneASp, Is.Not.Null);
            Assert.That(afterSceneASp.IsChildAgent, Is.True);

            ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);

            Assert.That(afterSceneBSp, Is.Not.Null);
            Assert.That(afterSceneBSp.IsChildAgent, Is.False);
            Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
            Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));

//            TestHelpers.DisableLogging();
        }
Beispiel #21
0
        public void TestLoadOarDeededLand()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID landID = TestHelpers.ParseTail(0x10);

            MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector();

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

            config.Set("Enabled", true);
            config.Set("Module", "GroupsModule");
            config.Set("DebugEnabled", true);
            SceneHelpers.SetupSceneModules(
                m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() });

            // Create group in scene for loading
            // FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests.
            UUID groupID
                = groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero);

            // Construct OAR
            MemoryStream     oarStream = new MemoryStream();
            TarArchiveWriter tar       = new TarArchiveWriter(oarStream);

            tar.WriteDir(ArchiveConstants.LANDDATA_PATH);
            tar.WriteFile(
                ArchiveConstants.CONTROL_FILE_PATH,
                new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup()));

            LandObject lo = new LandObject(groupID, true, m_scene);

            lo.SetLandBitmap(lo.BasicFullRegionLandBitmap());
            LandData ld = lo.LandData;

            ld.GlobalID = landID;

            string ldPath = ArchiveConstants.CreateOarLandDataPath(ld);
            Dictionary <string, object> options = new Dictionary <string, object>();

            tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, options));
            tar.Close();

            oarStream = new MemoryStream(oarStream.ToArray());

            // Load OAR
            m_scene.EventManager.OnOarFileLoaded += LoadCompleted;
            m_oarEvent.Reset();
            m_archiverModule.DearchiveRegion(oarStream);

            m_oarEvent.WaitOne(60000);

            ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16);
            LandData    rLd = rLo.LandData;

            Assert.That(rLd.GlobalID, Is.EqualTo(landID));
            Assert.That(rLd.OwnerID, Is.EqualTo(groupID));
            Assert.That(rLd.GroupID, Is.EqualTo(groupID));
            Assert.That(rLd.IsGroupOwned, Is.EqualTo(true));
        }
Beispiel #22
0
        public void TestScriptCrossOnSameSimulator()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId            = TestHelpers.ParseTail(0x1);
            int  sceneObjectIdTail = 0x2;

            EntityTransferModule           etmA = new EntityTransferModule();
            EntityTransferModule           etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
            XEngine xEngineA = new XEngine();
            XEngine xEngineB = new XEngine();

            xEngineA.DebugLevel = 1;
            xEngineB.DebugLevel = 1;

            IConfigSource configSource = new IniConfigSource();

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

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

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

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

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            IConfig modulesConfig = configSource.AddConfig("Modules");

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

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

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, configSource, lscm);
            SceneHelpers.SetupSceneModules(sceneA, configSource, etmA, xEngineA);
            SceneHelpers.SetupSceneModules(sceneB, configSource, etmB, xEngineB);
            sceneA.StartScripts();
            sceneB.StartScripts();

            SceneObjectGroup soSceneA = SceneHelpers.AddSceneObject(sceneA, 1, userId, "so1-", sceneObjectIdTail);

            soSceneA.AbsolutePosition = new Vector3(128, 10, 20);

            string soSceneAName         = soSceneA.Name;
            string scriptItemSceneAName = "script1";

            // CREATE SCRIPT TODO
            InventoryItemBase scriptItemSceneA = new InventoryItemBase();

            //            itemTemplate.ID = itemId;
            scriptItemSceneA.Name    = scriptItemSceneAName;
            scriptItemSceneA.Folder  = soSceneA.UUID;
            scriptItemSceneA.InvType = (int)InventoryType.LSL;

            AutoResetEvent chatEvent       = new AutoResetEvent(false);
            OSChatMessage  messageReceived = null;

            sceneA.EventManager.OnChatFromWorld += (s, m) => { messageReceived = m; chatEvent.Set(); };

            sceneA.RezNewScript(userId, scriptItemSceneA,
                                @"integer c = 0;

default
{
    state_entry()
    {
        llSay(0, ""Script running"");
    }

    changed(integer change)
    {
        llSay(0, ""Changed"");
    }

    touch_start(integer n)
    {
        c = c + 1;
        llSay(0, (string)c);
    }
}");

            chatEvent.WaitOne(60000);

            Assert.That(messageReceived, Is.Not.Null, "No chat message received.");
            Assert.That(messageReceived.Message, Is.EqualTo("Script running"));

            {
                // XXX: Should not be doing this so directly.  Should call some variant of EventManager.touch() instead.
                DetectParams[] det = new DetectParams[1];
                det[0]     = new DetectParams();
                det[0].Key = userId;
                det[0].Populate(sceneA);

                EventParams ep = new EventParams("touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, det);

                messageReceived = null;
                chatEvent.Reset();
                xEngineA.PostObjectEvent(soSceneA.LocalId, ep);
                chatEvent.WaitOne(60000);

                Assert.That(messageReceived.Message, Is.EqualTo("1"));
            }

            AutoResetEvent chatEventB = new AutoResetEvent(false);

            sceneB.EventManager.OnChatFromWorld += (s, m) => { messageReceived = m; chatEventB.Set(); };

            messageReceived = null;
            chatEventB.Reset();
            // Cross with a negative value
            soSceneA.AbsolutePosition = new Vector3(128, -10, 20);

            chatEventB.WaitOne(60000);
            Assert.That(messageReceived, Is.Not.Null, "No Changed message received.");
            Assert.That(messageReceived.Message, Is.Not.Null, "Changed message without content");
            Assert.That(messageReceived.Message, Is.EqualTo("Changed"));

            // TEST sending event to moved prim and output
            {
                SceneObjectGroup  soSceneB         = sceneB.GetSceneObjectGroup(soSceneAName);
                TaskInventoryItem scriptItemSceneB = soSceneB.RootPart.Inventory.GetInventoryItem(scriptItemSceneAName);

                // XXX: Should not be doing this so directly.  Should call some variant of EventManager.touch() instead.
                DetectParams[] det = new DetectParams[1];
                det[0]     = new DetectParams();
                det[0].Key = userId;
                det[0].Populate(sceneB);

                EventParams ep = new EventParams("touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, det);

                Thread.Sleep(250); // wait for other change messages to pass
                messageReceived = null;
                chatEventB.Reset();
                xEngineB.PostObjectEvent(soSceneB.LocalId, ep);
                chatEventB.WaitOne(60000);

                Assert.That(messageReceived.Message, Is.EqualTo("2"));
            }
        }
Beispiel #23
0
 static internal IConfig AddSection(string section) // Adds a config section.
 {
     return(_mainConfigParser.AddConfig(section));
 }
        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);
            }
        }
Beispiel #25
0
        public void TestCrossOnSameSimulator()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

//            TestEventQueueGetModule eqmA = new TestEventQueueGetModule();
            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);

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

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

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

            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

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

            originalSp.AbsolutePosition = new Vector3(128, 32, 10);

//            originalSp.Flying = true;

//            Console.WriteLine("First pos {0}", originalSp.AbsolutePosition);

//            eqmA.ClearEvents();

            AgentUpdateArgs moveArgs = new AgentUpdateArgs();

            //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
            moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
            moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
            moveArgs.SessionID    = acd.SessionID;

            originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);

            sceneA.Update(1);

//            Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);

            // FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
            // But really we want to do this in a more robust way.
            for (int i = 0; i < 100; i++)
            {
                sceneA.Update(1);
//                Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
            }

            // Need to sort processing of EnableSimulator message on adding scene presences before we can test eqm
            // messages
//            Dictionary<UUID, List<TestEventQueueGetModule.Event>> eqmEvents = eqmA.Events;
//
//            Assert.That(eqmEvents.Count, Is.EqualTo(1));
//            Assert.That(eqmEvents.ContainsKey(originalSp.UUID), Is.True);
//
//            List<TestEventQueueGetModule.Event> spEqmEvents = eqmEvents[originalSp.UUID];
//
//            Assert.That(spEqmEvents.Count, Is.EqualTo(1));
//            Assert.That(spEqmEvents[0].Name, Is.EqualTo("CrossRegion"));

            // sceneA should now only have a child agent
            ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);

            Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True);

            ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);

            // Agent remains a child until the client triggers complete movement
            Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);

            TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);

            int agentMovementCompleteReceived = 0;

            sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;

            sceneBTc.CompleteMovement();

            Assert.That(agentMovementCompleteReceived, Is.EqualTo(1));
            Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False);
        }
        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);
        }
Beispiel #27
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);
        }
        public void IncludeTests()
        {
            const string mainIniFile = "OpenSimDefaults.ini";

            m_config = new IniConfigSource();

            // Create ini files in a directory structure
            IniConfigSource ini;
            IConfig         config;

            ini    = new IniConfigSource();
            config = ini.AddConfig("IncludeTest");
            config.Set("Include-absolute", "absolute/*/config/*.ini");
            config.Set("Include-relative", "../" + m_testSubdirectory + "/relative/*/config/*.ini");
            CreateIni(mainIniFile, ini);

            ini = new IniConfigSource();
            ini.AddConfig("Absolute1").Set("name1", "value1");
            CreateIni("absolute/one/config/setting.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Absolute2").Set("name2", 2.3);
            CreateIni("absolute/two/config/setting1.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Absolute2").Set("name3", "value3");
            CreateIni("absolute/two/config/setting2.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Relative1").Set("name4", "value4");
            CreateIni("relative/one/config/setting.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Relative2").Set("name5", true);
            CreateIni("relative/two/config/setting1.ini", ini);

            ini = new IniConfigSource();
            ini.AddConfig("Relative2").Set("name6", 6);
            CreateIni("relative/two/config/setting2.ini", ini);

            // Prepare call to ConfigurationLoader.LoadConfigSettings()
            ConfigurationLoader cl              = new ConfigurationLoader();
            IConfigSource       argvSource      = new IniConfigSource();
            EnvConfigSource     envConfigSource = new EnvConfigSource();

            argvSource.AddConfig("Startup").Set("inifile", mainIniFile);
            ConfigSettings     configSettings;
            NetworkServersInfo networkInfo;

            OpenSimConfigSource source = cl.LoadConfigSettings(argvSource, envConfigSource,
                                                               out configSettings, out networkInfo);

            // Remove default config
            config = source.Source.Configs["Startup"];
            source.Source.Configs.Remove(config);
            config = source.Source.Configs["Network"];
            source.Source.Configs.Remove(config);

            // Finally, we are able to check the result
            Assert.AreEqual(m_config.ToString(), source.Source.ToString(),
                            "Configuration with includes does not contain all settings.");
            // The following would be preferable but fails due to a type mismatch which I am not able to resolve
            //CollectionAssert.AreEquivalent(m_config.Configs, source.Source.Configs,
            //    String.Format("Configuration with includes does not contain all settings.\nAll settings:\n{0}\nSettings read:\n{1}", m_config, source.Source));
        }
        public void TestCrossOnSameSimulatorPrimLimitsOkay()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId            = TestHelpers.ParseTail(0x1);
            int  sceneObjectIdTail = 0x2;

            EntityTransferModule           etmA = new EntityTransferModule();
            EntityTransferModule           etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
            LandManagementModule           lmmA = new LandManagementModule();
            LandManagementModule           lmmB = new LandManagementModule();

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

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

            IConfig permissionsConfig = config.AddConfig("Permissions");

            permissionsConfig.Set("permissionmodules", "PrimLimitsModule");

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

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(
                sceneA, config, etmA, lmmA, new PrimLimitsModule(), new PrimCountModule());
            SceneHelpers.SetupSceneModules(
                sceneB, config, etmB, lmmB, new PrimLimitsModule(), new PrimCountModule());

            // We must set up the parcel for this to work.  Normally this is taken care of by OpenSimulator startup
            // code which is not yet easily invoked by tests.
            lmmA.EventManagerOnNoLandDataFromStorage();
            lmmB.EventManagerOnNoLandDataFromStorage();

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

            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
            ScenePresence sp1SceneA = SceneHelpers.AddScenePresence(sceneA, tc, acd);

            SceneObjectGroup so1   = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
            UUID             so1Id = so1.UUID;

            so1.AbsolutePosition = new Vector3(128, 10, 20);

            // Cross with a negative value.  We must make this call rather than setting AbsolutePosition directly
            // because only this will execute permission checks in the source region.
            sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), sp1SceneA.ControllingClient);

            // crossing is async
            Thread.Sleep(500);

            Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
            Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
        }
Beispiel #30
0
        public void TestSendGroupNoticeOnlineOnly()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

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

            MessageTransferModule mtm = new MessageTransferModule();
            GroupsModule          gm  = new GroupsModule();
            GroupsMessagingModule gmm = new GroupsMessagingModule();

            IConfigSource configSource = new IniConfigSource();

            {
                IConfig config = configSource.AddConfig("Messaging");
                config.Set("MessageTransferModule", mtm.Name);
            }

            {
                IConfig config = configSource.AddConfig("Groups");
                config.Set("Enabled", true);
                config.Set("Module", gm.Name);
                config.Set("DebugEnabled", true);
                config.Set("MessagingModule", gmm.Name);
                config.Set("MessagingEnabled", true);
                config.Set("MessageOnlineUsersOnly", true);
            }

            SceneHelpers.SetupSceneModules(scene, configSource, new MockGroupsServicesConnector(), mtm, gm, gmm);

            UUID   userId                 = TestHelpers.ParseTail(0x1);
            string subjectText            = "newman";
            string messageText            = "Hello";
            string combinedSubjectMessage = string.Format("{0}|{1}", subjectText, messageText);

            ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
            TestClient    tc = (TestClient)sp.ControllingClient;

            UUID groupID = gm.CreateGroup(tc, "group1", null, true, UUID.Zero, 0, true, true, true);

            gm.JoinGroupRequest(tc, groupID);

            // Create a second user who doesn't want to receive notices
            ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x2));
            TestClient    tc2 = (TestClient)sp2.ControllingClient;

            gm.JoinGroupRequest(tc2, groupID);
            gm.SetGroupAcceptNotices(tc2, groupID, false, true);

            List <GridInstantMessage> spReceivedMessages = new List <GridInstantMessage>();

            tc.OnReceivedInstantMessage += im => spReceivedMessages.Add(im);

            List <GridInstantMessage> sp2ReceivedMessages = new List <GridInstantMessage>();

            tc2.OnReceivedInstantMessage += im => sp2ReceivedMessages.Add(im);

            GridInstantMessage noticeIm = new GridInstantMessage();

            noticeIm.fromAgentID = userId.Guid;
            noticeIm.toAgentID   = groupID.Guid;
            noticeIm.message     = combinedSubjectMessage;
            noticeIm.dialog      = (byte)InstantMessageDialog.GroupNotice;

            tc.HandleImprovedInstantMessage(noticeIm);

            Assert.That(spReceivedMessages.Count, Is.EqualTo(1));
            Assert.That(spReceivedMessages[0].message, Is.EqualTo(combinedSubjectMessage));

            Assert.That(sp2ReceivedMessages.Count, Is.EqualTo(0));
        }