clockwerk-opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ |
||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
||
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions are met: |
||
7 | * * Redistributions of source code must retain the above copyright |
||
8 | * notice, this list of conditions and the following disclaimer. |
||
9 | * * Redistributions in binary form must reproduce the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer in the |
||
11 | * documentation and/or other materials provided with the distribution. |
||
12 | * * Neither the name of the OpenSimulator Project nor the |
||
13 | * names of its contributors may be used to endorse or promote products |
||
14 | * derived from this software without specific prior written permission. |
||
15 | * |
||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
26 | */ |
||
27 | |||
28 | using System; |
||
29 | using System.Collections.Specialized; |
||
30 | using System.IO; |
||
31 | using System.Net; |
||
32 | using System.Net.Sockets; |
||
33 | using System.Text; |
||
34 | using HttpServer; |
||
35 | using HttpServer.FormDecoders; |
||
36 | using NUnit.Framework; |
||
37 | using OpenSim.Framework.Servers.HttpServer; |
||
38 | using OpenSim.Tests.Common; |
||
39 | |||
40 | namespace OpenSim.Framework.Servers.Tests |
||
41 | { |
||
42 | [TestFixture] |
||
43 | public class OSHttpTests : OpenSimTestCase |
||
44 | { |
||
45 | public OSHttpRequest req0; |
||
46 | public OSHttpRequest req1; |
||
47 | |||
48 | public OSHttpResponse rsp0; |
||
49 | |||
50 | public IPEndPoint ipEP0; |
||
51 | |||
52 | [TestFixtureSetUp] |
||
53 | public void Init() |
||
54 | { |
||
55 | TestHttpRequest threq0 = new TestHttpRequest("utf-8", "text/xml", "OpenSim Test Agent", "192.168.0.1", "4711", |
||
56 | new string[] {"text/xml"}, |
||
57 | ConnectionType.KeepAlive, 4711, |
||
58 | new Uri("http://127.0.0.1/admin/inventory/Dr+Who/Tardis")); |
||
59 | threq0.Method = "GET"; |
||
60 | threq0.HttpVersion = HttpHelper.HTTP10; |
||
61 | |||
62 | TestHttpRequest threq1 = new TestHttpRequest("utf-8", "text/xml", "OpenSim Test Agent", "192.168.0.1", "4711", |
||
63 | new string[] {"text/xml"}, |
||
64 | ConnectionType.KeepAlive, 4711, |
||
65 | new Uri("http://127.0.0.1/admin/inventory/Dr+Who/Tardis?a=0&b=1&c=2")); |
||
66 | threq1.Method = "POST"; |
||
67 | threq1.HttpVersion = HttpHelper.HTTP11; |
||
68 | threq1.Headers["x-wuff"] = "wuffwuff"; |
||
69 | threq1.Headers["www-authenticate"] = "go away"; |
||
70 | |||
71 | req0 = new OSHttpRequest(new TestHttpClientContext(false), threq0); |
||
72 | req1 = new OSHttpRequest(new TestHttpClientContext(false), threq1); |
||
73 | |||
74 | rsp0 = new OSHttpResponse(new TestHttpResponse()); |
||
75 | |||
76 | ipEP0 = new IPEndPoint(IPAddress.Parse("192.168.0.1"), 4711); |
||
77 | |||
78 | } |
||
79 | |||
80 | [Test] |
||
81 | public void T000_OSHttpRequest() |
||
82 | { |
||
83 | Assert.That(req0.HttpMethod, Is.EqualTo("GET")); |
||
84 | Assert.That(req0.ContentType, Is.EqualTo("text/xml")); |
||
85 | Assert.That(req0.ContentLength, Is.EqualTo(4711)); |
||
86 | |||
87 | Assert.That(req1.HttpMethod, Is.EqualTo("POST")); |
||
88 | } |
||
89 | |||
90 | [Test] |
||
91 | public void T001_OSHttpRequestHeaderAccess() |
||
92 | { |
||
93 | Assert.That(req1.Headers["x-wuff"], Is.EqualTo("wuffwuff")); |
||
94 | Assert.That(req1.Headers.Get("x-wuff"), Is.EqualTo("wuffwuff")); |
||
95 | |||
96 | Assert.That(req1.Headers["www-authenticate"], Is.EqualTo("go away")); |
||
97 | Assert.That(req1.Headers.Get("www-authenticate"), Is.EqualTo("go away")); |
||
98 | |||
99 | Assert.That(req0.RemoteIPEndPoint, Is.EqualTo(ipEP0)); |
||
100 | } |
||
101 | |||
102 | [Test] |
||
103 | public void T002_OSHttpRequestUriParsing() |
||
104 | { |
||
105 | Assert.That(req0.RawUrl, Is.EqualTo("/admin/inventory/Dr+Who/Tardis")); |
||
106 | Assert.That(req1.Url.ToString(), Is.EqualTo("http://127.0.0.1/admin/inventory/Dr+Who/Tardis?a=0&b=1&c=2")); |
||
107 | } |
||
108 | |||
109 | [Test] |
||
110 | public void T100_OSHttpResponse() |
||
111 | { |
||
112 | rsp0.ContentType = "text/xml"; |
||
113 | Assert.That(rsp0.ContentType, Is.EqualTo("text/xml")); |
||
114 | } |
||
115 | } |
||
116 | } |