protected override void Given()
 {
     var approvedEntitiesCache = new ApprovedEntitiesCache();
     var eventProcessorCache = PreProcessorHelper.CreateEventProcessorCache();
     _testClient1 = new DomainRepository(new AggregateRootFactory(eventProcessorCache, approvedEntitiesCache)).CreateNew<TestClient>();
     _testClient2 = new DomainRepository(new AggregateRootFactory(eventProcessorCache, approvedEntitiesCache)).CreateNew<TestClient>();
 }
Пример #2
0
        public void ValidHelloMessage ()
        {
            var responseStream = new MemoryStream ();
            var stream = new TestStream (new MemoryStream (helloMessage), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock<IServer<byte,byte>> ();
            var byteServer = mockByteServer.Object;
            var byteClient = new TestClient (stream);

            var server = new RPCServer (byteServer);
            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow ();
            server.Start ();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionEventArgs<byte,byte> (byteClient);
            mockByteServer.Raise (m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsTrue (eventArgs.Request.ShouldAllow);
            Assert.IsFalse (eventArgs.Request.ShouldDeny);

            server.Update ();
            Assert.AreEqual (1, server.Clients.Count ());
            Assert.AreEqual ("Jebediah Kerman!!!", server.Clients.First ().Name);

            byte[] bytes = responseStream.ToArray ();
            byte[] responseBytes = byteClient.Guid.ToByteArray ();
            Assert.IsTrue (responseBytes.SequenceEqual (bytes));
        }
 public void DisposeDoesNothingWhenNotLoggedIn()
 {
     var client = new TestClient();
     Assert.IsFalse(client.LoggedOut);
     client.Dispose();
     Assert.IsFalse(client.LoggedOut);
 }
Пример #4
0
        public void BadDownload()
        {
            var res = new MockResponse()
            {
                ContentType = "application/json",
                Code = System.Net.HttpStatusCode.Gone,
                Body = @"{ ""message"": ""Export no longer available."" }"
            };

            using (var c = new TestClient(res))
            {
                try
                {
                    c.Client.Export.Download(123);
                    Assert.Fail("should throw an exception");
                }
                catch (SlideRoom.API.SlideRoomAPIException e)
                {
                    Assert.AreEqual("Export no longer available.", e.Message);
                    Assert.AreEqual(System.Net.HttpStatusCode.Gone, e.StatusCode);
                }
                catch
                {
                    Assert.Fail("should throw a SlideRoomAPIException");
                }
            }
        }
        /// <summary>
        /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the
        /// viewer to setup a connection with the destination region.
        /// </summary>
        /// <param name='tc'></param>
        /// <param name='neighbourTcs'>
        /// A list that will be populated with any TestClients set up in response to 
        /// being informed about a destination region.
        /// </param>
        public static void SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
            TestClient tc, List<TestClient> neighbourTcs)
        {
            // XXX: Confusingly, this is also used for non-neighbour notification (as in teleports that do not use the
            // event queue).

            tc.OnTestClientInformClientOfNeighbour += (neighbourHandle, neighbourExternalEndPoint) =>
            {
                uint x, y;
                Utils.LongToUInts(neighbourHandle, out x, out y);
                x /= Constants.RegionSize;
                y /= Constants.RegionSize;

                m_log.DebugFormat(
                    "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}", 
                    x, y, neighbourExternalEndPoint);

                AgentCircuitData newAgent = tc.RequestClientInfo();

                Scene neighbourScene;
                SceneManager.Instance.TryGetScene(x, y, out neighbourScene);

                TestClient neighbourTc = new TestClient(newAgent, neighbourScene);
                neighbourTcs.Add(neighbourTc);
                neighbourScene.AddNewAgent(neighbourTc, PresenceType.User);
            };
        }
Пример #6
0
        public void GoodDownload()
        {
            var res = new MockResponse()
            {
                ContentType = "text/plain",
                Code = System.Net.HttpStatusCode.OK,
                Body = "test,report"
            };

            using (var c = new TestClient(res))
            {
                var actualResult = c.Client.Export.Download(123);

                // test the request
                var queryString = c.Request.QueryString;
                GeneralClient.TestRequiredParameters(queryString);

                queryString.ContainsAndEquals("token", "123");

                Assert.IsFalse(actualResult.Pending);
                Assert.IsNotNull(actualResult.ExportStream);

                var actualReport = String.Empty;
                using (StreamReader reader = new StreamReader(actualResult.ExportStream, Encoding.UTF8))
                {
                    actualReport = reader.ReadToEnd();
                }

                Assert.AreEqual("test,report", actualReport);
            }
        }
Пример #7
0
 public FlyToCommand(TestClient Client)
 {
     Name = "FlyTo";
     Description = "Fly the avatar toward the specified position for a maximum of seconds. Usage: FlyTo x y z [seconds]";
     Category = CommandCategory.Movement;
     Client.Objects.TerseObjectUpdate += Objects_OnObjectUpdated;            
 }
Пример #8
0
        /// <summary>
        /// More a placeholder, really
        /// </summary>        
        public void InPacketTest()
        {
            TestHelper.InMethod();

            AgentCircuitData agent = new AgentCircuitData();
            agent.AgentID = UUID.Random();
            agent.firstname = "testfirstname";
            agent.lastname = "testlastname";
            agent.SessionID = UUID.Zero;
            agent.SecureSessionID = UUID.Zero;
            agent.circuitcode = 123;
            agent.BaseFolder = UUID.Zero;
            agent.InventoryFolder = UUID.Zero;
            agent.startpos = Vector3.Zero;
            agent.CapsPath = "http://wibble.com";
            
            TestLLUDPServer testLLUDPServer;
            TestLLPacketServer testLLPacketServer;
            AgentCircuitManager acm;
            IScene scene = new MockScene();
            SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm);
            
            TestClient testClient = new TestClient(agent, scene);
            
            ILLPacketHandler packetHandler 
                = new LLPacketHandler(testClient, testLLPacketServer, new ClientStackUserSettings());
            
            packetHandler.InPacket(new AgentAnimationPacket());
            LLQueItem receivedPacket = packetHandler.PacketQueue.Dequeue();
            
            Assert.That(receivedPacket, Is.Not.Null);
            Assert.That(receivedPacket.Incoming, Is.True);
            Assert.That(receivedPacket.Packet, Is.TypeOf(typeof(AgentAnimationPacket)));
        }
Пример #9
0
        public void GoodRequest()
        {
            var res = new MockResponse()
            {
                ContentType = "application/json",
                Code = System.Net.HttpStatusCode.OK,
                Body = @"{ ""token"": 123, ""submissions"": 456, ""message"": ""test""}"
            };

            using (var c = new TestClient(res))
            {
                var actualResult = c.Client.Export.Request("test", SlideRoom.API.Resources.RequestFormat.Csv);

                // test the request
                var queryString = c.Request.QueryString;
                GeneralClient.TestRequiredParameters(queryString);

                queryString.ContainsAndEquals("export", "test");
                queryString.ContainsAndEquals("format", "csv");
                queryString.NotContains("ss");
                queryString.NotContains("since");

                var expectedResult = new SlideRoom.API.Resources.RequestResult()
                {
                    Message = "test",
                    Submissions = 456,
                    Token = 123
                };

                Assert.AreEqual(expectedResult.Message, actualResult.Message);
                Assert.AreEqual(expectedResult.Submissions, actualResult.Submissions);
                Assert.AreEqual(expectedResult.Token, actualResult.Token);
            }
        }
Пример #10
0
        public void BadRequest()
        {
            var res = new MockResponse()
            {
                ContentType = "application/json",
                Code = System.Net.HttpStatusCode.NotFound,
                Body = @"{ ""message"": ""Invalid Format"" }"
            };

            using (var c = new TestClient(res))
            {
                try
                {
                    c.Client.Export.Request("test", SlideRoom.API.Resources.RequestFormat.Csv);
                    Assert.Fail("should throw an exception");
                }
                catch (SlideRoom.API.SlideRoomAPIException e)
                {
                    Assert.AreEqual("Invalid Format", e.Message);
                    Assert.AreEqual(System.Net.HttpStatusCode.NotFound, e.StatusCode);
                }
                catch
                {
                    Assert.Fail("should throw a SlideRoomAPIException");
                }
            }
        }
Пример #11
0
        /// <summary>
        /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the
        /// viewer to setup a connection with the destination region.
        /// </summary>
        /// <param name='tc'></param>
        /// <param name='neighbourTcs'>
        /// A list that will be populated with any TestClients set up in response to 
        /// being informed about a destination region.
        /// </param>
        public static void SetUpInformClientOfNeighbour(TestClient tc, List<TestClient> neighbourTcs)
        {
            // XXX: Confusingly, this is also used for non-neighbour notification (as in teleports that do not use the
            // event queue).

            tc.OnTestClientInformClientOfNeighbour += (neighbourHandle, neighbourExternalEndPoint) =>
            {
                uint x, y;
                Utils.LongToUInts(neighbourHandle, out x, out y);
                x /= Constants.RegionSize;
                y /= Constants.RegionSize;

                m_log.DebugFormat(
                    "[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}", 
                    x, y, neighbourExternalEndPoint);

                // In response to this message, we are going to make a teleport to the scene we've previous been told
                // about by test code (this needs to be improved).
                AgentCircuitData newAgent = tc.RequestClientInfo();

                Scene neighbourScene;
                SceneManager.Instance.TryGetScene(x, y, out neighbourScene);

                TestClient neighbourTc = new TestClient(newAgent, neighbourScene);
                neighbourTcs.Add(neighbourTc);
                neighbourScene.AddNewClient(neighbourTc, PresenceType.User);
            };
        }
Пример #12
0
        public FlyToCommand(TestClient client)
        {
            Name = "FlyTo";
            Description = "Fly the avatar toward the specified position for a maximum of seconds. Usage: FlyTo x y z [seconds]";
            Category = CommandCategory.Movement;

            client.Objects.OnObjectUpdated += new ObjectManager.ObjectUpdatedCallback(Objects_OnObjectUpdated);
        }
 public void DisposeLogsOutWhenLoggedIn()
 {
     var client = new TestClient();
     Assert.IsFalse(client.LoggedOut);
     client.Login(new { });
     client.Dispose();
     Assert.IsTrue(client.LoggedOut);
 }
Пример #14
0
        public void T01_Successful2()
        {
            TestConnector c = new TestConnector();
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetConnectableIP(), GetConnectablePort()));
            t.WaitAndClose();

            Assert.IsTrue(c.Succeeded);
        }
Пример #15
0
        public void T05_NotConnectable3()
        {
            TestConnector c = new TestConnector();
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetConnectableDNSName(), GetClosedPort())); //ホストはあるがポートが開いてない
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NotConnectable3 [{0}]", c.ErrorMessage));
        }
Пример #16
0
        public void T04_NotConnectable2()
        {
            TestConnector c = new TestConnector();
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetUnknownDNSName(), GetConnectablePort())); //DNSエラー
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NotConnectable2 [{0}]", c.ErrorMessage));
        }
Пример #17
0
        public void T03_NotConnectable1()
        {
            TestConnector c = new TestConnector();
            TestClient t= new TestClient();
            c.AsyncConnect(t, new TelnetParameter(GetUnreachableIP(), GetConnectablePort())); //存在しないホスト
            t.WaitAndClose();

            Assert.IsFalse(c.Succeeded);
            Debug.WriteLine(String.Format("NotConnectable1 [{0}]", c.ErrorMessage));
        }
Пример #18
0
        public void SetUp()
        {
            UUID userId = TestHelpers.ParseTail(0x3);

            J2KDecoderModule j2kdm = new J2KDecoderModule();

            SceneHelpers sceneHelpers = new SceneHelpers();
            scene = sceneHelpers.SetupScene();
            SceneHelpers.SetupSceneModules(scene, j2kdm);

            tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene);
            llim = new LLImageManager(tc, scene.AssetService, j2kdm);
        }
 public void LoginConvertsObjectToCredentials()
 {
     var client = new TestClient();
     var credentials = new
     {
         UserName = "******",
         Password = (string)null
     };
     client.Login(credentials);
     Assert.AreEqual(2, client.Credentials.Count);
     Assert.AreEqual("UserName", client.Credentials[0].Name);
     Assert.AreEqual(credentials.UserName, client.Credentials[0].Value);
     Assert.AreEqual("Password", client.Credentials[1].Name);
     Assert.AreEqual(credentials.Password, client.Credentials[1].Value);
 }
Пример #20
0
        public void SetUp()
        {
            m_iam = new BasicInventoryAccessModule();

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
            
            m_scene = SceneHelpers.SetupScene();
            SceneHelpers.SetupSceneModules(m_scene, config, m_iam);
            
            // Create user
            string userFirstName = "Jock";
            string userLastName = "Stirrup";
            string userPassword = "******";
            UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword);                        
            
            AgentCircuitData acd = new AgentCircuitData();
            acd.AgentID = m_userId;
            m_tc = new TestClient(acd, m_scene);            
        }
Пример #21
0
 public void LoadTestMethod()
 {
     int[] questions = new int[] {1, 2, 3, 4, 5, 6, 7, 98, 100, 169, 239017};
     bool[] answers = new bool[] {false, true, true, false, true, false, true, false, false, false, true};
     int testClients = 300;
     Server.ServerProgram server = new Server.ServerProgram();
     try
     {
         server.Start(4);
         List<TestClient> clients = new List<TestClient>(testClients);
         for (int i = 0; i < testClients; ++i)
         {
             int idx = _random.Next(questions.Length - 1);
             var client = new TestClient(questions[idx], answers[idx]);
             clients.Add(client);
             client.Request();
         }
         foreach (var client in clients)
         {
             client.Join();
         }
         foreach (var client in clients)
         {
             Assert.IsTrue(client.GetResult());
         }
     }
     finally
     {
         server.Stop();
     }
     Trace.Write("finished = " + _ok);
     if (_exception != null)
     {
         throw new AssertFailedException("Exception in one of client threads", _exception);
     }
 }
Пример #22
0
        public async Task InvokeUserSendsToAllConnectionsForUser()
        {
            var backplane = CreateBackplane();
            var manager   = CreateNewHubLifetimeManager(backplane);

            using (var client1 = new TestClient())
                using (var client2 = new TestClient())
                    using (var client3 = new TestClient())
                    {
                        var connection1 = HubConnectionContextUtils.Create(client1.Connection, userIdentifier: "userA");
                        var connection2 = HubConnectionContextUtils.Create(client2.Connection, userIdentifier: "userA");
                        var connection3 = HubConnectionContextUtils.Create(client3.Connection, userIdentifier: "userB");

                        await manager.OnConnectedAsync(connection1).OrTimeout();

                        await manager.OnConnectedAsync(connection2).OrTimeout();

                        await manager.OnConnectedAsync(connection3).OrTimeout();

                        await manager.SendUserAsync("userA", "Hello", new object[] { "World" }).OrTimeout();
                        await AssertMessageAsync(client1);
                        await AssertMessageAsync(client2);
                    }
        }
Пример #23
0
        public void TestDeRezSceneObject()
        {
            TestHelper.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");

            TestScene     scene        = SceneSetupHelpers.SetupScene();
            IConfigSource configSource = new IniConfigSource();
            IConfig       config       = configSource.AddConfig("Startup");

            config.Set("serverside_object_permissions", true);
            SceneSetupHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
            TestClient client = SceneSetupHelpers.AddRootAgent(scene, userId);

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

            SceneObjectPart part
                = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);

            part.Name = "obj1";
            scene.AddNewSceneObject(new SceneObjectGroup(part), false);
            List <uint> localIds = new List <uint>();

            localIds.Add(part.LocalId);

            scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
            sogd.InventoryDeQueueAndDelete();

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

            Assert.That(retrievedPart, Is.Null);
        }
        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();
        }
Пример #25
0
        public void T010_TestAddRootAgent()
        {
            TestHelper.InMethod();

            string firstName = "testfirstname";

            AgentCircuitData agent = new AgentCircuitData();
            agent.AgentID = agent1;
            agent.firstname = firstName;
            agent.lastname = "testlastname";
            agent.SessionID = UUID.Random();
            agent.SecureSessionID = UUID.Random();
            agent.circuitcode = 123;
            agent.BaseFolder = UUID.Zero;
            agent.InventoryFolder = UUID.Zero;
            agent.startpos = Vector3.Zero;
            agent.CapsPath = GetRandomCapsObjectPath();
            agent.ChildrenCapSeeds = new Dictionary<ulong, string>();
            agent.child = true;

            scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID);

            string reason;
            scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
            testclient = new TestClient(agent, scene);
            scene.AddNewClient(testclient);

            ScenePresence presence = scene.GetScenePresence(agent1);

            Assert.That(presence, Is.Not.Null, "presence is null");
            Assert.That(presence.Firstname, Is.EqualTo(firstName), "First name not same");
            acd1 = agent;
        }
Пример #26
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);
        }
Пример #27
0
        public void TestInterRegionChatDistanceNorthSouth()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

            UUID sp1Uuid = TestHelpers.ParseTail(0x11);
            UUID sp2Uuid = TestHelpers.ParseTail(0x12);

            Vector3 sp1Position = new Vector3(128, 250, 20);
            Vector3 sp2Position = new Vector3(128, 6, 20);

            SceneHelpers sh         = new SceneHelpers();
            TestScene    sceneNorth = sh.SetupScene("sceneNorth", TestHelpers.ParseTail(0x1), 1000, 1000);
            TestScene    sceneSouth = sh.SetupScene("sceneSouth", TestHelpers.ParseTail(0x2), 1000, 1001);

            SetupNeighbourRegions(sceneNorth, sceneSouth);

            ScenePresence sp1       = SceneHelpers.AddScenePresence(sceneNorth, sp1Uuid);
            TestClient    sp1Client = (TestClient)sp1.ControllingClient;

            // If we don't set agents to flying, test will go wrong as they instantly fall to z = 0.
            // TODO: May need to create special complete no-op test physics module rather than basic physics, since
            // physics is irrelevant to this test.
            sp1.Flying = true;

            // When sp1 logs in to sceneEast, it sets up a child agent in sceneNorth and informs the sp2 client to
            // make the connection.  For this test, will simplify this chain by making the connection directly.
            ScenePresence sp1Child       = SceneHelpers.AddChildScenePresence(sceneSouth, sp1Uuid);
            TestClient    sp1ChildClient = (TestClient)sp1Child.ControllingClient;

            sp1.AbsolutePosition = sp1Position;

            ScenePresence sp2       = SceneHelpers.AddScenePresence(sceneSouth, sp2Uuid);
            TestClient    sp2Client = (TestClient)sp2.ControllingClient;

            sp2.Flying = true;

            ScenePresence sp2Child       = SceneHelpers.AddChildScenePresence(sceneNorth, sp2Uuid);
            TestClient    sp2ChildClient = (TestClient)sp2Child.ControllingClient;

            sp2.AbsolutePosition = sp2Position;

            // We must update the scenes in order to make the root new root agents trigger position updates in their
            // children.
            sceneNorth.Update(4);
            sceneSouth.Update(4);
            sp1.DrawDistance += 64;
            sp2.DrawDistance += 64;
            sceneNorth.Update(4);
            sceneSouth.Update(4);

            // Check child positions are correct.
            Assert.AreEqual(
                new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z),
                sp1ChildClient.SceneAgent.AbsolutePosition);

            Assert.AreEqual(
                new Vector3(sp2Position.X, sp2Position.Y + sceneSouth.RegionInfo.RegionSizeY, sp2Position.Z),
                sp2ChildClient.SceneAgent.AbsolutePosition);

            string receivedSp1ChatMessage = "";
            string receivedSp2ChatMessage = "";

            sp1ChildClient.OnReceivedChatMessage
                += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message;
            sp2ChildClient.OnReceivedChatMessage
                += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message;

            TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage);
            TestUserInRange(sp2Client, "fantastic cats", ref receivedSp1ChatMessage);

            sp1Position          = new Vector3(30, 128, 20);
            sp1.AbsolutePosition = sp1Position;
            sceneNorth.Update(1);
            sceneSouth.Update(1);
            Thread.Sleep(12000); // child updates are now time limited
            sceneNorth.Update(5);
            sceneSouth.Update(5);

            // Check child position is correct.
            Assert.AreEqual(
                new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z),
                sp1ChildClient.SceneAgent.AbsolutePosition);

            TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage);
            TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage);
        }
Пример #28
0
        public void PingPing()
        {
            this.testNr = 2;
            Console.WriteLine("Sending ping for {0} clients {1} times ...", ClientCount, LoopCount);

            // join all clients to a game (ping only works if peer has joined a game)
            for (int i = 0; i < this.clients.Length; i++)
            {
                var request = new OperationRequest {
                    OperationCode = (byte)OperationCode.Join, Parameters = new Dictionary <byte, object>()
                };
                request.Parameters.Add((byte)ParameterKey.GameId, "TestGame" + i);
                this.clients[i].SendOperationRequest(request);
                this.WaitForEvent();
            }

            Console.WriteLine("Join sent for {0} clients...", ClientCount);

            Thread.Sleep(1000);
            Interlocked.Exchange(ref this.operationResponseCount, 0);

            Stopwatch stopWatch = Stopwatch.StartNew();

            this.AutoResetEventOperation.Reset();
            var requests = new OperationRequest[LoopCount];
            var @params  = new Dictionary <byte, object> {
                { 10, new byte[4096] }
            };
            var operation = new OperationRequest {
                OperationCode = (byte)OperationCode.Ping, Parameters = @params
            };

            for (int l = 0; l < LoopCount; l++)
            {
                requests[l] = operation;
            }

            foreach (TestClient t in this.clients)
            {
                // var client = this.clients[0];
                TestClient client = t;
                client.SendOperationRequests(requests);
            }

            ////    Console.WriteLine("Ping sent for {0} clients {1} times...", ClientCount, l + 1);

            ////    if ((l + 1) % this.waitSteps == 0)
            ////    {
            ////        Console.WriteLine("wait: " + (l + 1));
            ////        this.WaitForOperationResponse();
            ////    }
            ////}
            if (LoopCount % WaitSteps != 0)
            {
                Console.WriteLine("wait final");
                this.WaitForOperationResponse();
            }

            stopWatch.Stop();

            this.LogElapsedTime(log, "Receive took: ", stopWatch.Elapsed, ClientCount * LoopCount);
        }
Пример #29
0
 /// <summary>
 /// Construct a new instance of the SearchLandCommand
 /// </summary>
 /// <param name="testClient"></param>
 public SearchLandCommand(TestClient testClient)
 {
     Name = "searchland";
     Description = "Searches for land for sale. for usage information type: searchland";
     Category = CommandCategory.Search;
 }
        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>
        /// Set up correct handling of the InformClientOfNeighbour call from the source region that triggers the
        /// viewer to setup a connection with the destination region.
        /// </summary>
        /// <param name='tc'></param>
        /// <param name='neighbourTcs'>
        /// A list that will be populated with any TestClients set up in response to 
        /// being informed about a destination region.
        /// </param>
        public static void SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement(
            TestClient client, List<TestClient> destinationClients)
        {
            client.OnTestClientSendRegionTeleport 
                += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) =>
            {
                uint x, y;
                Utils.LongToUInts(regionHandle, out x, out y);
                x /= Constants.RegionSize;
                y /= Constants.RegionSize;

                m_log.DebugFormat(
                    "[TEST CLIENT]: Processing send region teleport for destination at {0},{1} at {2}", 
                    x, y, regionExternalEndPoint);

                AgentCircuitData newAgent = client.RequestClientInfo();

                Scene destinationScene;
                SceneManager.Instance.TryGetScene(x, y, out destinationScene);

                TestClient destinationClient = new TestClient(newAgent, destinationScene);
                destinationClients.Add(destinationClient);
                destinationScene.AddNewAgent(destinationClient, PresenceType.User);

                ThreadPool.UnsafeQueueUserWorkItem(o => destinationClient.CompleteMovement(), null);
            };
        }
 public SearchGroupsCommand(TestClient testClient)
 {
     Name        = "searchgroups";
     Description = "Searches groups. Usage: searchgroups [search text]";
     Category    = CommandCategory.Groups;
 }
Пример #33
0
 public void ResolveExceptionBubblesOut()
 {
     var client = TestClient.GetInMemoryClient(s => new ConnectionSettings());
     var e      = Assert.Throws <ResolveException>(() => client.Search <Project>());
 }
        public async Task TestLogin()
        {
            Utilisateur utilisateur = new Utilisateur {
                Nom         = "Luzolo",
                Postnom     = "Makiese",
                Prenom      = "Patricia",
                Sexe        = Sexe.Feminin,
                Photosrc    = "",
                Email       = "*****@*****.**",
                Username    = "******",
                Password    = "******",
                NiveauAcces = NiveauAcces.Utilisateur
            };

            HttpResponseMessage response = await TestClient.PostAsJsonAsync(route + "create", utilisateur);

            response.StatusCode.Should().Be(HttpStatusCode.OK);
            Utilisateur utilisateur1 = await response.Content.ReadAsAsync <Utilisateur>();

            HttpResponseMessage response1 = await TestClient.GetAsync(route + "getbyid?id=" + utilisateur1.Id);

            response1.StatusCode.Should().Be(HttpStatusCode.OK);
            Utilisateur u = await response1.Content.ReadAsAsync <Utilisateur>();

            u.Equals(utilisateur1).Should().BeTrue();

            HttpResponseMessage response2 = await TestClient.PostAsJsonAsync(route + "login", utilisateur1);

            response2.StatusCode.Should().Be(HttpStatusCode.OK);
            Utilisateur u1 = await response2.Content.ReadAsAsync <Utilisateur>();

            u1.Equals(utilisateur1).Should().BeTrue();

            Utilisateur utilisateur2 = new Utilisateur {
                Email    = "*****@*****.**",
                Password = "******"
            };

            HttpResponseMessage response3 = await TestClient.PostAsJsonAsync(route + "login", utilisateur2);

            response3.StatusCode.Should().Be(HttpStatusCode.OK);
            Utilisateur u2 = await response3.Content.ReadAsAsync <Utilisateur>();

            u2.Equals(utilisateur1).Should().BeTrue();

            Utilisateur utilisateur3 = new Utilisateur {
                Username = "******",
                Password = "******"
            };

            HttpResponseMessage response4 = await TestClient.PostAsJsonAsync(route + "login", utilisateur3);

            response4.StatusCode.Should().Be(HttpStatusCode.OK);
            Utilisateur u3 = await response4.Content.ReadAsAsync <Utilisateur>();

            u3.Equals(utilisateur1).Should().BeTrue();

            utilisateur2.Email = "*****@*****.**";

            HttpResponseMessage response5 = await TestClient.PostAsJsonAsync(route + "login", utilisateur2);

            response5.StatusCode.Should().Be(HttpStatusCode.NoContent);
            Utilisateur u4 = await response4.Content.ReadAsAsync <Utilisateur>();

            u4.Should().BeNull();

            utilisateur3.Username = "******";

            HttpResponseMessage response6 = await TestClient.PostAsJsonAsync(route + "login", utilisateur3);

            response6.StatusCode.Should().Be(HttpStatusCode.NoContent);
            Utilisateur u5 = await response6.Content.ReadAsAsync <Utilisateur>();

            u5.Should().BeNull();

            utilisateur2.Email    = "*****@*****.**";
            utilisateur2.Password = "******";

            HttpResponseMessage response7 = await TestClient.PostAsJsonAsync(route + "login", utilisateur2);

            response7.StatusCode.Should().Be(HttpStatusCode.NoContent);
            Utilisateur u6 = await response7.Content.ReadAsAsync <Utilisateur>();

            u6.Should().BeNull();

            HttpResponseMessage response8 = await TestClient.DeleteAsync(route + "delete?id=" + utilisateur1.Id);

            response8.StatusCode.Should().Be(HttpStatusCode.OK);

            HttpResponseMessage response9 = await TestClient.PostAsJsonAsync(route + "login", utilisateur1);

            response9.StatusCode.Should().Be(HttpStatusCode.NoContent);
            (await response9.Content.ReadAsAsync <Utilisateur>()).Should().BeNull();
        }
        public async Task GetAll_AsAnonymousUser_ReturnsUnauthorized()
        {
            var response = await TestClient.GetAsync(ApiRoutes.Categories.GetAll);

            Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
        }
        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();
        }
Пример #37
0
 //hide
 [U] public void ArgumentExceptionBubblesOut()
 {
     var client = TestClient.GetClient(s => new ConnectionSettings());
     var e      = Assert.Throws <ArgumentException>(() => client.Search <Project>());
 }
Пример #38
0
        public async Task TestGraphsEndpoint_ShouldReturnOk(string endpoint)
        {
            var response = await TestClient.GetAsync(ApiRoutes.EndpointGraphs.Replace("{endpoint}", endpoint));

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Пример #39
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));
        }
Пример #40
0
        public async Task TestNamespaceEndpoint_ShouldReturnNotFound(string endpoint)
        {
            var response = await TestClient.GetAsync(ApiRoutes.EndpointNamespacePrefix.Replace("{prefix}", endpoint));

            Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
        }
Пример #41
0
        public async Task ExecuteStateTransactionAsync_CanSaveState()
        {
            await using var client = TestClient.CreateForDaprClient();

            var stateValue1 = new Widget() { Size = "small", Color = "yellow", };
            var metadata1 = new Dictionary<string, string>()
            {
                {"a", "b" }
            };
            var options1 = new StateOptions
            {
                Concurrency = ConcurrencyMode.LastWrite
            };

            var state1 = new StateTransactionRequest("stateKey1", JsonSerializer.SerializeToUtf8Bytes(stateValue1), StateOperationType.Upsert, "testEtag", metadata1, options1);
            var stateValue2 = 100;
            var state2 = new StateTransactionRequest("stateKey2", JsonSerializer.SerializeToUtf8Bytes(stateValue2), StateOperationType.Delete);

            var stateValue3 = "teststring";
            var state3 = new StateTransactionRequest("stateKey3", JsonSerializer.SerializeToUtf8Bytes(stateValue3), StateOperationType.Upsert);

            var states = new List<StateTransactionRequest>
            {
                state1,
                state2,
                state3
            };

            var request = await client.CaptureGrpcRequestAsync(async daprClient =>
            {
                await daprClient.ExecuteStateTransactionAsync("testStore", states);
            });

            request.Dismiss();

            // Get Request and validate
            var envelope = await request.GetRequestEnvelopeAsync<Autogenerated.ExecuteStateTransactionRequest>();

            envelope.StoreName.Should().Be("testStore");
            envelope.Operations.Count.Should().Be(3);

            var req1 = envelope.Operations[0];
            req1.Request.Key.Should().Be("stateKey1");
            req1.OperationType.Should().Be(StateOperationType.Upsert.ToString().ToLower());
            var valueJson1 = req1.Request.Value.ToStringUtf8();
            var value1 = JsonSerializer.Deserialize<Widget>(valueJson1, client.InnerClient.JsonSerializerOptions);
            value1.Size.Should().Be(stateValue1.Size);
            value1.Color.Should().Be(stateValue1.Color);
            req1.Request.Etag.Value.Should().Be("testEtag");
            req1.Request.Metadata.Count.Should().Be(1);
            req1.Request.Metadata["a"].Should().Be("b");
            req1.Request.Options.Concurrency.Should().Be(2);

            var req2 = envelope.Operations[1];
            req2.Request.Key.Should().Be("stateKey2");
            req2.OperationType.Should().Be(StateOperationType.Delete.ToString().ToLower());
            var valueJson2 = req2.Request.Value.ToStringUtf8();
            var value2 = JsonSerializer.Deserialize<int>(valueJson2, client.InnerClient.JsonSerializerOptions);
            value2.Should().Be(100);

            var req3 = envelope.Operations[2];
            req3.Request.Key.Should().Be("stateKey3");
            req3.OperationType.Should().Be(StateOperationType.Upsert.ToString().ToLower());
            var valueJson3 = req3.Request.Value.ToStringUtf8();
            var value3 = JsonSerializer.Deserialize<string>(valueJson3, client.InnerClient.JsonSerializerOptions);
            value3.Should().Be("teststring");
        }
Пример #42
0
        public async Task GetAll_FromEmptyDB()
        {
            var response = await TestClient.GetAsync(ApiRoutes.Users.GetAll);

            (await response.Content.ReadAsAsync <List <Branch> >()).Count.Should().Be(0);
        }
Пример #43
0
        public void TestDeRezSceneObjectToAgents()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

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

            // We need this so that the creation of the root client for userB in sceneB can trigger the creation of a child client in sceneA
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
            EntityTransferModule etmB = new EntityTransferModule();
            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmB.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);
            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneB, config, etmB);

            // We need this for derez
            SceneHelpers.SetupSceneModules(sceneA, new PermissionsModule());

            UserAccount uaA = UserAccountHelpers.CreateUserWithInventory(sceneA, "Andy", "AAA", 0x1, "");
            UserAccount uaB = UserAccountHelpers.CreateUserWithInventory(sceneA, "Brian", "BBB", 0x2, "");

            TestClient clientA = (TestClient)SceneHelpers.AddScenePresence(sceneA, uaA).ControllingClient;

            // This is the more long-winded route we have to take to get a child client created for userB in sceneA
            // rather than just calling AddScenePresence() as for userA
            AgentCircuitData acd = SceneHelpers.GenerateAgentData(uaB);
            TestClient clientB = new TestClient(acd, sceneB);
            List<TestClient> childClientsB = new List<TestClient>();
            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(clientB, childClientsB);

            SceneHelpers.AddScenePresence(sceneB, clientB, acd);

            SceneObjectGroup so = SceneHelpers.AddSceneObject(sceneA);
            uint soLocalId = so.LocalId;

            sceneA.DeleteSceneObject(so, false);

            Assert.That(clientA.ReceivedKills.Count, Is.EqualTo(1));
            Assert.That(clientA.ReceivedKills[0], Is.EqualTo(soLocalId));

            Assert.That(childClientsB[0].ReceivedKills.Count, Is.EqualTo(1));
            Assert.That(childClientsB[0].ReceivedKills[0], Is.EqualTo(soLocalId));
        }
Пример #44
0
        /// <inheritdoc cref="IPostsTestsMethods"/>
        public async Task <CreatedResponse <int> > CreatePostAsync(CreatePostRequest request)
        {
            var response = await TestClient.PostAsJsonAsync(ApiRoutes.PostsController.Posts, request);

            return(await response.Content.ReadAsAsync <CreatedResponse <int> >());
        }
Пример #45
0
 /// <summary>
 ///   The on event received.
 /// </summary>
 /// <param name = "arg1">
 ///   The arg 1.
 /// </param>
 /// <param name = "arg2">
 ///   The arg 2.
 /// </param>
 protected void OnEventReceived(TestClient arg1, EventData arg2)
 {
     this.AutoResetEventEvent.Set();
 }
Пример #46
0
        public void TestRejectGivenFolder()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

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

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

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

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

            // Create the folder to test give
            InventoryFolderBase originalFolder
                = UserInventoryHelpers.CreateInventoryFolder(
                      m_scene.InventoryService, giverSp.UUID, folderId, "f1", true);

            GridInstantMessage receivedIm = null;

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

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

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

            giverClient.HandleImprovedInstantMessage(giveIm);

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

            receiverClient.HandleImprovedInstantMessage(rejectIm);

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

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

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

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

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

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

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

            Assert.That(originalFolderAfterDelete, Is.Not.Null);
        }
Пример #47
0
 public ChangeDirectoryCommand(TestClient client)
 {
     Name        = "cd";
     Description = "Changes the current working inventory folder.";
     Category    = CommandCategory.Inventory;
 }
Пример #48
0
        public void TestAcceptGivenItem()
        {
            //            TestHelpers.EnableLogging();

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

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

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

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

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

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

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

            giverClient.HandleImprovedInstantMessage(giveIm);

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

            receiverClient.HandleImprovedInstantMessage(acceptIm);

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

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

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

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

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

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

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

            // TODO: Test scenario where giver deletes their item first.
        }
Пример #49
0
        public void T012_TestAddNeighbourRegion()
        {
            TestHelper.InMethod();

            string reason;

            if (acd1 == null)
                fixNullPresence();

            scene.NewUserConnection(acd1, 0, out reason);
            if (testclient == null)
                testclient = new TestClient(acd1, scene);
            scene.AddNewClient(testclient);

            ScenePresence presence = scene.GetScenePresence(agent1);
            presence.MakeRootAgent(new Vector3(90,90,90),false);

            string cap = presence.ControllingClient.RequestClientInfo().CapsPath;

            presence.AddNeighbourRegion(region2, cap);
            presence.AddNeighbourRegion(region3, cap);

            List<ulong> neighbours = presence.GetKnownRegionList();

            Assert.That(neighbours.Count, Is.EqualTo(2));
        }
Пример #50
0
 public void Setup()
 {
     _client = _apiFixture.GetClient();
 }
Пример #51
0
 public BacketService(IClusterClient clusterClient, TestClient testClient)
 {
     this.clusterClient = clusterClient;
     this.testClient    = testClient;
 }
Пример #52
0
 public TurnToCommand(TestClient client)
 {
     Name = "turnto";
     Description = "Turns the avatar looking to a specified point. Usage: turnto x y z";
     Category = CommandCategory.Movement;
 }
Пример #53
0
        public void run(object o)
        {
            //results.Result = true;
            log4net.Config.XmlConfigurator.Configure();

            UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100");
            UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200");

            // shared module
            ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();


            Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, "grid");

            SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
            sceneB.RegisterRegionWithGrid();

            Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, "grid");

            SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
            sceneA.RegisterRegionWithGrid();

            UUID       agentId = UUID.Parse("00000000-0000-0000-0000-000000000041");
            TestClient client  = SceneSetupHelpers.AddRootAgent(sceneA, agentId);

            ICapabilitiesModule sceneACapsModule = sceneA.RequestModuleInterface <ICapabilitiesModule>();

            results.Result = (sceneACapsModule.GetCapsPath(agentId) == client.CapsSeedUrl);

            if (!results.Result)
            {
                results.Message = "Incorrect caps object path set up in sceneA";
                return;
            }

            /*
             * Assert.That(
             *  sceneACapsModule.GetCapsPath(agentId),
             *  Is.EqualTo(client.CapsSeedUrl),
             *  "Incorrect caps object path set up in sceneA");
             */
            // FIXME: This is a hack to get the test working - really the normal OpenSim mechanisms should be used.


            client.TeleportTargetScene = sceneB;
            client.Teleport(sceneB.RegionInfo.RegionHandle, new Vector3(100, 100, 100), new Vector3(40, 40, 40));

            results.Result = (sceneB.GetScenePresence(agentId) != null);
            if (!results.Result)
            {
                results.Message = "Client does not have an agent in sceneB";
                return;
            }

            //Assert.That(sceneB.GetScenePresence(agentId), Is.Not.Null, "Client does not have an agent in sceneB");

            //Assert.That(sceneA.GetScenePresence(agentId), Is.Null, "Client still had an agent in sceneA");

            results.Result = (sceneA.GetScenePresence(agentId) == null);
            if (!results.Result)
            {
                results.Message = "Client still had an agent in sceneA";
                return;
            }

            ICapabilitiesModule sceneBCapsModule = sceneB.RequestModuleInterface <ICapabilitiesModule>();


            results.Result = ("http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort +
                              "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/" == client.CapsSeedUrl);
            if (!results.Result)
            {
                results.Message = "Incorrect caps object path set up in sceneB";
                return;
            }

            // Temporary assertion - caps url construction should at least be doable through a method.

            /*
             * Assert.That(
             *  "http://" + sceneB.RegionInfo.ExternalHostName + ":" + sceneB.RegionInfo.HttpPort + "/CAPS/" + sceneBCapsModule.GetCapsPath(agentId) + "0000/",
             *  Is.EqualTo(client.CapsSeedUrl),
             *  "Incorrect caps object path set up in sceneB");
             */
            // This assertion will currently fail since we don't remove the caps paths when no longer needed
            //Assert.That(sceneACapsModule.GetCapsPath(agentId), Is.Null, "sceneA still had a caps object path");

            // TODO: Check that more of everything is as it should be

            // TODO: test what happens if we try to teleport to a region that doesn't exist
        }
Пример #54
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 PermissionsModule(), 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 also still be root
            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);
        }
Пример #55
0
 public AccountingApiTests()
 {
     client = new TestClient("AccountingServer");
 }
Пример #56
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);
        }
Пример #57
0
 public CrouchCommand(TestClient testClient)
 {
     Name        = "crouch";
     Description = "Starts or stops crouching. Usage: crouch [start/stop]";
     Category    = CommandCategory.Movement;
 }
Пример #58
0
 public key2nameCommand(TestClient testClient)
 {
     Name        = "key2name";
     Description = "resolve a UUID to an avatar or group name. Usage: key2name UUID";
     Category    = CommandCategory.Search;
 }
        public void ShouldDeserialize()
        {
            const string indexName = ".monitoring-es-6-2017.07.21";

            var fixedResponse = new
            {
                cluster_settings = new[]
                {
                    new
                    {
                        level   = "info",
                        message = "Network settings changes",
                        url     = "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal",
                        details = "templates using <literal>template</literal> field: watches,.monitoring-alerts,.watch-history-6,.ml-notifications,security-index-template,triggered_watches,.monitoring-es,.ml-meta,.ml-state,.monitoring-logstash,.ml-anomalies-,.monitoring-kibana"
                    }
                },
                node_settings  = new object[0],
                index_settings = new Dictionary <string, object>
                {
                    {
                        indexName, new object[]
                        {
                            new {
                                level   = "info",
                                message = "Coercion of boolean fields",
                                url     = "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields",
                                details = "<anchor id=\"type: doc\" xreflabel=\"field: spins]\"/>"
                            }
                        }
                    }
                }
            };

            var client = TestClient.GetFixedReturnClient(fixedResponse);

            //warmup
            var response = client.DeprecationInfo();

            response.ShouldBeValid();

            response.ClusterSettings.Should().NotBeNull();
            response.ClusterSettings.Should().HaveCount(1);
            response.ClusterSettings.First().Level.Should().Be(DeprecationWarningLevel.Information);
            response.ClusterSettings.First().Message.Should().Be("Network settings changes");
            response.ClusterSettings.First().Url.Should().Be("https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal");
            response.ClusterSettings.First().Details.Should().Be("templates using <literal>template</literal> field: watches,.monitoring-alerts,.watch-history-6,.ml-notifications,security-index-template,triggered_watches,.monitoring-es,.ml-meta,.ml-state,.monitoring-logstash,.ml-anomalies-,.monitoring-kibana");

            response.NodeSettings.Should().NotBeNull();
            response.NodeSettings.Should().BeEmpty();

            response.IndexSettings.Should().NotBeNull();
            response.IndexSettings.Should().HaveCount(1);
            response.IndexSettings.Should().ContainKey(indexName);
            response.IndexSettings[indexName].Count.Should().Be(1);

            var deprecationInfo = response.IndexSettings[indexName].First();

            deprecationInfo.Details.Should().Be("<anchor id=\"type: doc\" xreflabel=\"field: spins]\"/>");
            deprecationInfo.Url.Should().Be("https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields");
            deprecationInfo.Message.Should().Be("Coercion of boolean fields");
            deprecationInfo.Level.Should().Be(DeprecationWarningLevel.Information);
        }
Пример #60
0
        public async Task TestConfigurationInfoEndpoint_ShouldReturnNotFound(string endpoint)
        {
            var response = await TestClient.GetAsync(ApiRoutes.EndpointConfiguration.Replace("{endpoint}", endpoint));

            Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
        }