- Timestamp:
- 07/07/10 03:26:15 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabMembershipProviderTest.cs
r4008 r4009 81 81 bool actual; 82 82 actual = target.RequiresQuestionAndAnswer; 83 Assert.I nconclusive("Verify the correctness of this test method.");83 Assert.IsFalse(actual); 84 84 } 85 85 … … 141 141 int actual; 142 142 actual = target.MinRequiredNonAlphanumericCharacters; 143 Assert. Inconclusive("Verify the correctness of this test method.");143 Assert.AreEqual(actual, 0); 144 144 } 145 145 … … 150 150 public void MaxInvalidPasswordAttemptsTest() { 151 151 MembershipProvider target = Membership.Provider; 152 int actual; 153 actual = target.MaxInvalidPasswordAttempts; 154 Assert.Inconclusive("Verify the correctness of this test method."); 152 MembershipCreateStatus status; 153 target.CreateUser("testUser", "MySuperPassword", "mail", "question", "answer", true, null, out status); 154 Assert.AreEqual(MembershipCreateStatus.Success, status); 155 156 target.ValidateUser("testUser", "MySuperPassword"); 157 Assert.IsFalse(target.GetUser("testUser", true).IsLockedOut); 158 159 for (int i = 0; i < target.MaxInvalidPasswordAttempts - 1; i++) { 160 target.ValidateUser("testUser", "foo"); 161 Assert.IsFalse(target.GetUser("testUser", true).IsLockedOut); 162 } 163 164 target.ValidateUser("testUser", "MySuperPassword"); 165 Assert.IsFalse(target.GetUser("testUser", true).IsLockedOut); 166 167 168 for (int i = 0; i < target.MaxInvalidPasswordAttempts; i++) { 169 target.ValidateUser("testUser", "foo"); 170 Assert.IsFalse(target.GetUser("testUser", true).IsLockedOut); 171 } 172 173 target.ValidateUser("testUser", "foo"); 174 Assert.IsTrue(target.GetUser("testUser", true).IsLockedOut); 175 176 target.ValidateUser("testUser", "MySuperPassword"); 177 Assert.IsTrue(target.GetUser("testUser", true).IsLockedOut); 178 155 179 } 156 180 … … 248 272 HeuristicLabUser dbUser = db.HeuristicLabUsers.Single(u => u.UserName == "testname"); 249 273 Assert.IsFalse(dbUser.Locked); 250 Assert.IsTrue(dbUser.Locked);251 274 252 275 } … … 283 306 } 284 307 285 /// <summary>286 ///A test for GetUser287 ///</summary>288 [TestMethod()]289 public void GetUserTest1() {290 MembershipProvider target = Membership.Provider; // TODO: Initialize to an appropriate value291 object providerUserKey = null; // TODO: Initialize to an appropriate value292 bool userIsOnline = false; // TODO: Initialize to an appropriate value293 MembershipUser expected = null; // TODO: Initialize to an appropriate value294 MembershipUser actual;295 actual = target.GetUser(providerUserKey, userIsOnline);296 Assert.AreEqual(expected, actual);297 Assert.Inconclusive("Verify the correctness of this test method.");298 }299 308 300 309 /// <summary> … … 304 313 public void GetUserTest() { 305 314 MembershipProvider target = Membership.Provider; // TODO: Initialize to an appropriate value 306 string username = string.Empty; // TODO: Initialize to an appropriate value 307 bool userIsOnline = false; // TODO: Initialize to an appropriate value 308 MembershipUser expected = null; // TODO: Initialize to an appropriate value 309 MembershipUser actual; 310 actual = target.GetUser(username, userIsOnline); 311 Assert.AreEqual(expected, actual); 312 Assert.Inconclusive("Verify the correctness of this test method."); 315 MembershipCreateStatus status; 316 target.CreateUser("testUser","myPersonalSecret", "root@nowhere.com","myQuestion", "myAnswer", true, null, out status); 317 Assert.AreEqual(MembershipCreateStatus.Success, status); 318 MembershipUser user = target.GetUser("testUser", true); 319 Assert.AreEqual(user.UserName, "testUser"); 320 Assert.AreEqual(user.Email, "root@nowhere.com"); 321 Assert.AreEqual(user.PasswordQuestion, "myQuestion"); 322 Assert.IsTrue(target.ValidateUser("testUser", "myPersonalSecret")); 323 313 324 } 314 325 … … 511 522 // gibt zwar true zurück, was schon mal gut ist 512 523 Assert.IsTrue(target.ChangePasswordQuestionAndAnswer("testname", "INIT", "newquestion", "newanswer")); 513 // aber hier ist die änderung noch nicht da!! es ist immer noch die alte frage + alte antwort524 db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, u); 514 525 u = db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == "testname"); 515 526 Assert.AreEqual<String>("newquestion", u.PasswordQuestion); … … 522 533 [TestMethod()] 523 534 public void ChangePasswordTest() { 535 MembershipProvider target = Membership.Provider; 536 524 537 // create user 525 538 HeuristicLabUser u = new HeuristicLabUser("testname", "testemail", "testquestion", "testcomment"); 539 u.Password = ((HeuristicLabMembershipProvider)target).EncodePassword("INIT"); 526 540 db.HeuristicLabUsers.InsertOnSubmit(u); 527 541 db.SubmitChanges(); … … 529 543 // check if user is stored 530 544 u = db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == "testname"); 531 Assert.AreEqual<String>( "INIT", u.Password);545 Assert.AreEqual<String>(((HeuristicLabMembershipProvider)target).EncodePassword("INIT"), u.Password); 532 546 533 547 // change data and check again 534 MembershipProvider target = Membership.Provider;535 548 Assert.IsTrue(target.ChangePassword("testname", "INIT", "newPassword")); 536 // hat nix gemacht!! :(549 db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, u); 537 550 u = db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.UserName == "testname"); 538 Assert.AreEqual<String>( "newPassword", u.Password);551 Assert.AreEqual<String>(((HeuristicLabMembershipProvider)target).EncodePassword("newPassword"), u.Password); 539 552 } 540 553
Note: See TracChangeset
for help on using the changeset viewer.