In Test/System.Web.Security:
authorSebastien Pouliot <sebastien@ximian.com>
Sun, 22 May 2005 00:34:04 +0000 (00:34 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Sun, 22 May 2005 00:34:04 +0000 (00:34 -0000)
2005-05-21  Sebastien Pouliot  <sebastien@ximian.com>

* FormsAuthenticationTest.cs: New. Unit tests for FormsAuthentication.
In .:
2005-05-21  Sebastien Pouliot  <sebastien@ximian.com>

* System.Web_test.dll.sources: Added tests for FormsAuthentication.

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

mcs/class/System.Web/ChangeLog
mcs/class/System.Web/System.Web_test.dll.sources
mcs/class/System.Web/Test/System.Web.Security/ChangeLog [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationTest.cs [new file with mode: 0644]

index 45ff241abd950baf3116fc21b41dac1ffc58d9fd..85cddbcc6f1c8c15da21ffd80c913f75e3966e0a 100644 (file)
@@ -1,3 +1,7 @@
+2005-05-21  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * System.Web_test.dll.sources: Added tests for FormsAuthentication.
+
 2005-05-13  Lluis Sanchez Gual <lluis@novell.com>
 
        * System.Web.dll.sources: Added new file:
index 5d78bf30ceb767b083416b93ffadf39d0b31cca8..c297d5054b39ea14743e229595743d75bd766564 100644 (file)
@@ -1,5 +1,6 @@
 System.Web/HttpRequestTest.cs
 System.Web/HttpServerUtilityTest.cs
 System.Web/HttpUtilityTest.cs
+System.Web.Security/FormsAuthenticationTest.cs
 System.Web.UI/TestUrlPropertyAttribute.cs
 System.Web.UI.WebControls/TestControlIDConverter.cs
diff --git a/mcs/class/System.Web/Test/System.Web.Security/ChangeLog b/mcs/class/System.Web/Test/System.Web.Security/ChangeLog
new file mode 100644 (file)
index 0000000..8a82400
--- /dev/null
@@ -0,0 +1,3 @@
+2005-05-21  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * FormsAuthenticationTest.cs: New. Unit tests for FormsAuthentication.
diff --git a/mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationTest.cs b/mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationTest.cs
new file mode 100644 (file)
index 0000000..0b353db
--- /dev/null
@@ -0,0 +1,67 @@
+//\r
+// FormsAuthenticationTest.cs - NUnit Test Cases for FormsAuthentication\r
+//\r
+// Author:\r
+//     Sebastien Pouliot (sebastien@ximian.com)\r
+//\r
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//\r
+\r
+using System;
+using System.Security.Cryptography;
+using System.Text;\r
+using System.Web.Security;
+\r
+using NUnit.Framework;\r
+\r
+namespace MonoTests.System.Web.Security {\r
+\r
+       [TestFixture]\r
+       public class FormsAuthenticationTest {\r
+\r
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]\r
+               public void HashPasswordForStoringInConfigFile_NullPassword ()
+               {
+                       FormsAuthentication.HashPasswordForStoringInConfigFile (null, "MD5");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]\r
+               public void HashPasswordForStoringInConfigFile_NullPasswordFormat ()
+               {
+                       FormsAuthentication.HashPasswordForStoringInConfigFile ("Mono", null);
+               }
+
+               [Test]
+               public void HashPasswordForStoringInConfigFile_MD5 ()
+               {
+                       // § (C2-A7)
+                       string s = Encoding.UTF8.GetString (new byte [2] { 0xC2, 0xA7 });
+                       Assert.AreEqual ("BD9A4C255DEEC8944D99E01A64C1E322", FormsAuthentication.HashPasswordForStoringInConfigFile (s, "MD5"));
+
+                       // ä (C3-A4)
+                       s = Encoding.UTF8.GetString (new byte [2] { 0xC3, 0xA4 });
+                       Assert.AreEqual ("8419B71C87A225A2C70B50486FBEE545", FormsAuthentication.HashPasswordForStoringInConfigFile (s, "MD5"));
+               }
+
+               [Test]
+               public void HashPasswordForStoringInConfigFile_SHA1 ()
+               {
+                       // § (C2-A7)
+                       string s = Encoding.UTF8.GetString (new byte [2] { 0xC2, 0xA7 });
+                       Assert.AreEqual ("EB2CB244889599F736B6CDD633C5E324F521D1BB", FormsAuthentication.HashPasswordForStoringInConfigFile (s, "SHA1"));
+
+                       // ä (C3-A4)
+                       s = Encoding.UTF8.GetString (new byte [2] { 0xC3, 0xA4 });
+                       Assert.AreEqual ("961FA22F61A56E19F3F5F8867901AC8CF5E6D11F", FormsAuthentication.HashPasswordForStoringInConfigFile (s, "SHA1"));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]\r
+               public void HashPasswordForStoringInConfigFile_SHA256 ()
+               {
+                       FormsAuthentication.HashPasswordForStoringInConfigFile ("mono", "SHA256");
+               }
+       }
+}