In Test/System.Net:
authorGeoff Norton <grompf@sublimeintervention.com>
Sun, 6 Apr 2008 15:02:40 +0000 (15:02 -0000)
committerGeoff Norton <grompf@sublimeintervention.com>
Sun, 6 Apr 2008 15:02:40 +0000 (15:02 -0000)
2008-04-06  Geoff Norton  <gnorton@novell.com>

* HttpListener2Test.cs:
* HttpListenerRequestTest.cs: HttpListener Basic authenticationt test
from Maciej Paszta <paszczi@go2.pl>

svn path=/trunk/mcs/; revision=99957

mcs/class/System/Test/System.Net/ChangeLog
mcs/class/System/Test/System.Net/HttpListener2Test.cs
mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs

index 9813440ff3313a9041bbe8b98baa8f04277d2673..df50ef92de0bab825b3871dc5c155d679d631164 100644 (file)
@@ -1,3 +1,9 @@
+2008-04-06  Geoff Norton  <gnorton@novell.com>
+
+       * HttpListener2Test.cs:
+       * HttpListenerRequestTest.cs: HttpListener Basic authenticationt test
+       from Maciej Paszta <paszczi@go2.pl>
+
 2008-02-09  Daniel Nauck  <dna@mono-project.de>
 
        * CookieContainerTest.cs: added some not working Add/Expired tests
index 09681d6345cc215f2b8a90b23eef09ec3aab5078..0e05673fe04f314cb0a20e3f72abe0aa3f731b9b 100644 (file)
@@ -65,6 +65,15 @@ namespace MonoTests.System.Net {
                        return listener;
                }
 
+               public static HttpListener CreateAndStartListener (string prefix, AuthenticationSchemes authSchemes)
+               {
+                       HttpListener listener = new HttpListener ();
+                       listener.AuthenticationSchemes = authSchemes;
+                       listener.Prefixes.Add (prefix);
+                       listener.Start ();
+                       return listener;
+               }
+
                public static MyNetworkStream CreateNS (int port)
                {
                        Socket sock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
index 4b287e470119513becfd8e92b3529a66ee221954..6d3f16f522580f7192514cbbb56298e6883335c6 100644 (file)
@@ -161,6 +161,20 @@ namespace MonoTests.System.Net
                        HttpListener2Test.Send (ctx.Response.OutputStream, "%%%OK%%%");
                        listener.Close ();
                }
+               
+               [Test]
+               public void HttpBasicAuthScheme()
+               {
+                       HttpListener listener = HttpListener2Test.CreateAndStartListener("http://*:9000/authTest/", AuthenticationSchemes.Basic);
+                       //dummy-wait for context
+                       listener.BeginGetContext(null, listener);
+                       NetworkStream ns = HttpListener2Test.CreateNS(9000);
+                       HttpListener2Test.Send(ns, "GET /authTest/ HTTP/1.0\r\n\r\n");
+                       String response = HttpListener2Test.Receive(ns, 512);
+                       Assert.IsTrue(response.Contains("WWW-Authenticate: Basic realm"), "#A");
+                       ns.Close();
+                       listener.Close();
+               }
        }
 }