Exemple #1
0
        public void Init()
        {
            TestHttpRequest threq0 = new TestHttpRequest("utf-8", "text/xml", "OpenSim Test Agent", "192.168.0.1", "4711", 
                                                       new string[] {"text/xml"}, 
                                                       ConnectionType.KeepAlive, 4711, 
                                                       new Uri("http://127.0.0.1/admin/inventory/Dr+Who/Tardis"));
            threq0.Method = "GET";
            threq0.HttpVersion = HttpHelper.HTTP10;

            TestHttpRequest threq1 = new TestHttpRequest("utf-8", "text/xml", "OpenSim Test Agent", "192.168.0.1", "4711", 
                                                       new string[] {"text/xml"}, 
                                                       ConnectionType.KeepAlive, 4711, 
                                                       new Uri("http://127.0.0.1/admin/inventory/Dr+Who/Tardis?a=0&b=1&c=2"));
            threq1.Method = "POST";
            threq1.HttpVersion = HttpHelper.HTTP11;
            threq1.Headers["x-wuff"] = "wuffwuff";
            threq1.Headers["www-authenticate"] = "go away";
            
            req0 = new OSHttpRequest(new TestHttpClientContext(false), threq0);
            req1 = new OSHttpRequest(new TestHttpClientContext(false), threq1);

            rsp0 = new OSHttpResponse(new TestHttpResponse());

            ipEP0 = new IPEndPoint(IPAddress.Parse("192.168.0.1"), 4711);

        }
        public object Clone()
        {
            TestHttpRequest clone = new TestHttpRequest();

            clone._acceptTypes   = _acceptTypes;
            clone._connection    = _connection;
            clone._contentLength = _contentLength;
            clone._uri           = _uri;
            clone._headers       = new NameValueCollection(_headers);

            return(clone);
        }
        public object Clone()
        {
            TestHttpRequest clone = new TestHttpRequest();
            clone._acceptTypes = _acceptTypes;
            clone._connection = _connection;
            clone._contentLength = _contentLength;
            clone._uri = _uri;
            clone._headers = new NameValueCollection(_headers);

            return clone;
        }
        public void TestInventoryDescendentsFetch()
        {
            TestHelpers.InMethod();
            TestHelpers.EnableLogging();

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

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

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

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

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

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

            TestHttpRequest req = new TestHttpRequest();
            OpenSim.Framework.Capabilities.Caps userCaps = capsModule.GetCapsForUser(ua.PrincipalID);
            PollServiceEventArgs pseArgs;
            userCaps.TryGetPollHandler("FetchInventoryDescendents2", out pseArgs);
            req.UriPath = pseArgs.Url;
            req.Uri = new Uri(req.UriPath);

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

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

            OSDArray osdFoldersArray = new OSDArray();
            osdFoldersArray.Add(osdFolder);

            OSDMap osdReqMap = new OSDMap();
            osdReqMap["folders"] = osdFoldersArray;

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

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

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

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

            OSDMap responseOsd = (OSDMap)OSDParser.DeserializeLLSDXml(context.ResponseBody);
            OSDArray foldersOsd = (OSDArray)responseOsd["folders"];
            OSDMap folderOsd = (OSDMap)foldersOsd[0];
           
            // A sanity check that the response has the expected number of descendents for a default inventory
            // TODO: Need a more thorough check.
            Assert.That((int)folderOsd["descendents"], Is.EqualTo(14));
        }