Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3959 for branches


Ignore:
Timestamp:
06/26/10 11:39:42 (14 years ago)
Author:
hmayr
Message:

minor changes (#1046)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabUserTest.cs

    r3956 r3959  
    229229      target.ChangePassword(target.Password, "pwd1");
    230230      Assert.AreEqual<String>("pwd1", target.GetPassword());
    231       target.ResetPassword("wrongAnswer");
     231      Assert.AreEqual<String>("", target.ResetPassword("wrongAnswer"));
    232232      Assert.AreEqual<String>("pwd1", target.GetPassword());
     233      Assert.AreEqual<String>("INIT", target.ResetPassword(""));
     234      Assert.AreEqual<String>("INIT", target.GetPassword());
    233235    }
    234236
     
    269271      Assert.AreEqual<String>("testquestion", target.PasswordQuestion);
    270272      Assert.AreEqual<String>("", target.PasswordAnswer);
    271       target.ChangePasswordQuestionAndAnswer("INIT", "newquestion", "newanswer");
     273
     274      // check all exceptions
     275      try {
     276        target.ChangePasswordQuestionAndAnswer(null, null, null);
     277        Assert.Fail();
     278      }
     279      catch {
     280      }
     281      try {
     282        target.ChangePasswordQuestionAndAnswer("", null, null);
     283        Assert.Fail();
     284      }
     285      catch {
     286      }
     287      try {
     288        target.ChangePasswordQuestionAndAnswer("", "", null);
     289        Assert.Fail();
     290      }
     291      catch {
     292      }
     293      try {
     294        target.ChangePasswordQuestionAndAnswer("", "x", "x");
     295        Assert.Fail();
     296      }
     297      catch {
     298      }
     299      try {
     300        target.ChangePasswordQuestionAndAnswer("x", "", "x");
     301        Assert.Fail();
     302      }
     303      catch {
     304      }
     305      try {
     306        target.ChangePasswordQuestionAndAnswer("x", "x", "");
     307        Assert.Fail();
     308      }
     309      catch {
     310      }
     311
     312      // wrong old password
     313      Assert.IsFalse(target.ChangePasswordQuestionAndAnswer("wrong", "newquestion", "newanswer"));
     314      Assert.AreEqual<String>("testquestion", target.PasswordQuestion);
     315      Assert.AreEqual<String>("", target.PasswordAnswer);
     316
     317      // should work
     318      Assert.IsTrue(target.ChangePasswordQuestionAndAnswer("INIT", "newquestion", "newanswer"));
    272319      Assert.AreEqual<String>("newquestion", target.PasswordQuestion);
    273320      Assert.AreEqual<String>("newanswer", target.PasswordAnswer);
     
    281328      HeuristicLabUser target = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment");
    282329      Assert.AreEqual<String>("INIT", target.Password);
     330
     331      // check all exceptions
     332      try {
     333        target.ChangePassword(null, null);
     334        Assert.Fail();
     335      }
     336      catch {
     337      }
     338      try {
     339        target.ChangePassword("", "abc");
     340        Assert.Fail();
     341      }
     342      catch {
     343      }
     344      try {
     345        target.ChangePassword("INIT", null);
     346        Assert.Fail();
     347      }
     348      catch {
     349      }
     350      try {
     351        target.ChangePassword("INIT", "");
     352        Assert.Fail();
     353      }
     354      catch {
     355      }
     356
    283357      target.ChangePassword(target.Password, "pwd1");
    284358      Assert.AreEqual<String>("pwd1", target.Password);
Note: See TracChangeset for help on using the changeset viewer.