Author: gert
Date: 2007-12-07 08:17:58 -0500 (Fri, 07 Dec 2007)
New Revision: 90926

Added:
   trunk/gert/standalone/bug342533/
   trunk/gert/standalone/bug342533/default.build
   trunk/gert/standalone/bug342533/test.cs
Modified:
   trunk/gert/standalone/known-issues
Log:
Added test for bug #342533.


Added: trunk/gert/standalone/bug342533/default.build
===================================================================
--- trunk/gert/standalone/bug342533/default.build       2007-12-07 12:47:19 UTC 
(rev 90925)
+++ trunk/gert/standalone/bug342533/default.build       2007-12-07 13:17:58 UTC 
(rev 90926)
@@ -0,0 +1,28 @@
+<project name="bug342533" default="rebuild">
+       <include buildfile="../../build/common.build" />
+       
+       <property name="frameworks" value="mono-1.0,mono-2.0,net-1.1,net-2.0" />
+
+       <target name="clean">
+               <delete>
+                       <fileset>
+                               <include name="out" />
+                               <include name="test.exe" />
+                       </fileset>
+               </delete>
+       </target>
+
+       <target name="compile" depends="init">
+               <csc target="exe" define="${csc.defines}" output="test.exe" 
warnaserror="true" warninglevel="4">
+                       <sources>
+                               <include name="../../build/common/Assert.cs" />
+                               <include name="test.cs" />
+                       </sources>
+               </csc>
+       </target>
+
+       <target name="run-test" depends="compile">
+               <exec program="test.exe" managed="true" output="out" />
+               <fail if="${file::exists('out')}" />
+       </target>
+</project>


Property changes on: trunk/gert/standalone/bug342533/default.build
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/gert/standalone/bug342533/test.cs
===================================================================
--- trunk/gert/standalone/bug342533/test.cs     2007-12-07 12:47:19 UTC (rev 
90925)
+++ trunk/gert/standalone/bug342533/test.cs     2007-12-07 13:17:58 UTC (rev 
90926)
@@ -0,0 +1,114 @@
+using System;
+using System.IO;
+using System.Net;
+#if NET_2_0
+using System.Net.Security;
+#endif
+using System.Security.Cryptography.X509Certificates;
+using System.Text;
+
+namespace test
+{
+       class MainClass
+       {
+               public static void Main (string [] args)
+               {
+#if NET_2_0
+                       ServicePointManager.ServerCertificateValidationCallback 
=
+                               new RemoteCertificateValidationCallback 
(ValidateServerCertificate);
+#else
+                       ServicePointManager.CertificatePolicy = new 
AllowAllCertificatePolicy ();
+#endif
+
+                       HttpWebRequest hwRequest = null;
+                       HttpWebResponse hwResponse = null;
+                       CookieContainer ccCookies = null;
+                       ccCookies = new CookieContainer ();
+                       String strPostData = 
"ltmpl=yj_blanco&ltmplcache=2&continue=http%3A%2F%2Fmail.google.com%2Fmail%3Fui%3Dhtml%26zy%3Dl&service=mail&rm=false&ltmpl=yj_blanco&Email=my0test&Passwd=testtest&rmShown=1&null=Zaloguj+si%C4%99";
+                       String strAccept = 
"application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1";
+                       String strBrowserMozzila = "Mozilla/5.0 (Windows; U; 
Windows NT 5.1; pl; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2";
+                       Stream streamRequest = null;
+                       StreamReader streamrResponse = null;
+                       hwRequest = (HttpWebRequest) HttpWebRequest.Create 
("https://www.google.com/accounts/ServiceLoginAuth";);
+                       hwRequest.AllowAutoRedirect = true;
+                       hwRequest.Method = "POST";
+                       hwRequest.Referer = hwRequest.Address.AbsoluteUri;
+                       hwRequest.ContentType = 
"application/x-www-form-urlencoded";
+                       hwRequest.UserAgent = strBrowserMozzila;
+                       hwRequest.KeepAlive = true;
+                       hwRequest.AllowAutoRedirect = true;
+                       hwRequest.AllowWriteStreamBuffering = true;
+                       hwRequest.CookieContainer = ccCookies;
+                       hwRequest.Timeout = 30 * 1000;
+                       hwRequest.Accept = strAccept;
+                       ASCIIEncoding ascii = new ASCIIEncoding ();
+                       byte [] byData = ascii.GetBytes (strPostData);
+                       try {
+                               hwRequest.ContentLength = byData.Length;
+                               streamRequest = hwRequest.GetRequestStream ();
+                               streamRequest.Write (byData, 0, byData.Length);
+                       } finally {
+                               try {
+                                       streamRequest.Close ();
+                               } catch {
+                                       ;
+                               }
+                       }
+                       hwResponse = (HttpWebResponse) hwRequest.GetResponse ();
+                       Stream myResponse = hwResponse.GetResponseStream ();
+                       streamrResponse = new StreamReader (myResponse);
+                       string myout, mytmp = "";
+                       myout = "";
+                       while (mytmp != null) {
+                               myout += mytmp + "\r\n";
+                               mytmp = streamrResponse.ReadLine ();
+                       }
+                       streamrResponse.Close ();
+                       myResponse.Close ();
+                       myResponse.Close ();
+
+                       String strLink = myout.Substring (myout.IndexOf 
("http://www.google.";)).Replace ("&amp;", "&");
+
+                       int index = strLink.IndexOf ("'");
+                       strLink = strLink.Remove (index, strLink.Length - 
index);
+
+                       string referer = hwRequest.Address.AbsoluteUri;
+                       hwRequest = null;
+                       hwRequest = (HttpWebRequest) HttpWebRequest.Create 
(strLink);
+                       hwRequest.AllowAutoRedirect = true;
+                       hwRequest.Method = "GET";
+                       hwRequest.Referer = referer;
+                       hwRequest.ContentType = 
"application/x-www-form-urlencoded";
+                       hwRequest.UserAgent = strBrowserMozzila;
+                       hwRequest.KeepAlive = true;
+                       hwRequest.AllowAutoRedirect = true;
+                       hwRequest.AllowWriteStreamBuffering = true;
+                       hwRequest.CookieContainer = ccCookies;
+                       hwRequest.Timeout = 30 * 1000;
+                       hwRequest.Accept = strAccept;
+                       hwResponse = null;
+                       hwResponse = (HttpWebResponse) hwRequest.GetResponse ();
+                       using (StreamReader sr = new StreamReader 
(hwResponse.GetResponseStream ())) {
+                               string body = sr.ReadToEnd ();
+                               Assert.IsTrue (body.IndexOf ("<title>Gmail - 
Inbox</title>") != -1, body);
+                       }
+               }
+
+#if NET_2_0
+               public static bool ValidateServerCertificate (object sender, 
X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
+               {
+                       return true;
+               }
+#endif
+       }
+}
+
+#if ONLY_1_1
+internal class AllowAllCertificatePolicy : ICertificatePolicy
+{
+       public bool CheckValidationResult (ServicePoint point, X509Certificate 
certificate, WebRequest request, int certificateProblem)
+       {
+               return true;
+       }
+}
+#endif


Property changes on: trunk/gert/standalone/bug342533/test.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/gert/standalone/known-issues
===================================================================
--- trunk/gert/standalone/known-issues  2007-12-07 12:47:19 UTC (rev 90925)
+++ trunk/gert/standalone/known-issues  2007-12-07 13:17:58 UTC (rev 90926)
@@ -130,5 +130,6 @@
 bug341726/**
 bug341743/**
 bug342513/**
+bug342533/**
 bug343837/**
 bug345627/**

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to