Modified:
branches/5.2/MySql.Web/Providers/Properties/Resources.resx
branches/5.2/MySql.Web/Providers/Source/MembershipProvider.cs
branches/5.2/MySql.Web/Tests/App.config
branches/5.2/MySql.Web/Tests/UserManagement.cs
Log:
Added test case and fixed issue with throwing an exception if you attempt to create a user when QA is required and you didn't give one or the other
Modified: branches/5.2/MySql.Web/Providers/Properties/Resources.resx
===================================================================
--- branches/5.2/MySql.Web/Providers/Properties/Resources.resx 2008-02-28 19:53:13 UTC (rev 1196)
+++ branches/5.2/MySql.Web/Providers/Properties/Resources.resx 2008-02-28 20:16:35 UTC (rev 1197)
@@ -223,4 +223,10 @@
<data name="ValidatePasswordCanceled" xml:space="preserve">
<value>The validate password operation was canceled.</value>
</data>
+ <data name="PasswordAnswerInvalid" xml:space="preserve">
+ <value>Password answer supplied is invalid.</value>
+ </data>
+ <data name="PasswordQuestionInvalid" xml:space="preserve">
+ <value>Password question supplied is invalid.</value>
+ </data>
</root>
\ No newline at end of file
Modified: branches/5.2/MySql.Web/Providers/Source/MembershipProvider.cs
===================================================================
--- branches/5.2/MySql.Web/Providers/Source/MembershipProvider.cs 2008-02-28 19:53:13 UTC (rev 1196)
+++ branches/5.2/MySql.Web/Providers/Source/MembershipProvider.cs 2008-02-28 20:16:35 UTC (rev 1197)
@@ -516,6 +516,8 @@
return null;
}
+ ValidateQA(passwordQuestion, passwordAnswer);
+
// now try to validate the password
if (!ValidatePassword(password, "password", false))
{
@@ -1427,6 +1429,14 @@
}
}
+ private void ValidateQA(string question, string answer)
+ {
+ if (RequiresQuestionAndAnswer && String.IsNullOrEmpty(question))
+ throw new ArgumentException(Resources.PasswordQuestionInvalid);
+ if (RequiresQuestionAndAnswer && String.IsNullOrEmpty(answer))
+ throw new ArgumentException(Resources.PasswordAnswerInvalid);
+ }
+
private bool ValidatePassword(string password, string argumentName, bool throwExceptions)
{
string exceptionString = null;
Modified: branches/5.2/MySql.Web/Tests/App.config
===================================================================
--- branches/5.2/MySql.Web/Tests/App.config 2008-02-28 19:53:13 UTC (rev 1196)
+++ branches/5.2/MySql.Web/Tests/App.config 2008-02-28 20:16:35 UTC (rev 1197)
@@ -5,7 +5,7 @@
<providers>
<clear/>
<add name="MySqlProfileProvider" connectionStringName="LocalMySqlServer"
- applicationName="/" type="MySql.Web.Profile.MySQLProfileProvider, mysql.web, Version=5.2.1.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
+ applicationName="/" type="MySql.Web.Profile.MySQLProfileProvider, mysql.web, Version=5.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</providers>
<properties>
<add name="Name"/>
Modified: branches/5.2/MySql.Web/Tests/UserManagement.cs
===================================================================
--- branches/5.2/MySql.Web/Tests/UserManagement.cs 2008-02-28 19:53:13 UTC (rev 1196)
+++ branches/5.2/MySql.Web/Tests/UserManagement.cs 2008-02-28 20:16:35 UTC (rev 1197)
@@ -463,5 +463,37 @@
Assert.AreEqual(String.Format("foo2{0}", index++), user.UserName);
}
+
+ [Test]
+ public void CreateUserWithNoQA()
+ {
+ MembershipCreateStatus status;
+ provider = new MySQLMembershipProvider();
+ NameValueCollection config = new NameValueCollection();
+ config.Add("connectionStringName", "LocalMySqlServer");
+ config.Add("requiresQuestionAndAnswer", "true");
+ config.Add("passwordFormat", "clear");
+ config.Add("applicationName", "/");
+ provider.Initialize(null, config);
+
+ try
+ {
+ provider.CreateUser("foo", "barbar!", "foo@stripped", "color", null, true, null, out status);
+ Assert.Fail();
+ }
+ catch (Exception ex)
+ {
+ Assert.IsTrue(ex.Message.StartsWith("Password answer supplied is invalid"));
+ }
+ try
+ {
+ provider.CreateUser("foo", "barbar!", "foo@stripped", "", "blue", true, null, out status);
+ Assert.Fail();
+ }
+ catch (Exception ex)
+ {
+ Assert.IsTrue(ex.Message.StartsWith("Password question supplied is invalid"));
+ }
+ }
}
}
| Thread |
|---|
| • Connector/NET commit: r1197 - in branches/5.2/MySql.Web: Providers/Properties Providers/Source Tests | rburnett | 28 Feb |