- Timestamp:
- 07/08/10 15:29:38 (14 years ago)
- Location:
- branches/HeuristicLab.Services.Authentication Prototype
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabMembershipProvider.cs
r4014 r4018 37 37 38 38 public override bool EnablePasswordReset { 39 get { return pEnablePasswordReset; }39 get { return false; } 40 40 } 41 41 42 42 public override bool EnablePasswordRetrieval { 43 get { return pEnablePasswordRetrieval; }43 get { return false; } 44 44 } 45 45 … … 199 199 u.PasswordAnswer = newPasswordAnswer; 200 200 u.PasswordQuestion = newPasswordQuestion; 201 201 202 202 db.SubmitChanges(); 203 203 204 204 return true; 205 205 } … … 327 327 return PagedCollection(users, pageIndex, pageSize, out totalRecords); 328 328 } 329 329 330 330 } 331 331 … … 345 345 return PagedCollection(users, pageIndex, pageSize, out totalRecords); 346 346 } 347 347 348 348 } 349 349 … … 415 415 public override string GetUserNameByEmail(string email) { 416 416 using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) { 417 HeuristicLabUser u = 418 db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.Email == email); 419 if (u != null) 417 418 if (db.HeuristicLabUsers.Count(x => x.Email == email) > 0) { 419 420 HeuristicLabUser u = 421 db.HeuristicLabUsers.Single<HeuristicLabUser>(x => x.Email == email); 422 420 423 return u.UserName; 421 else422 424 } 425 return null; 423 426 } 424 427 } … … 473 476 474 477 public override void UpdateUser(MembershipUser user) { 475 throw new NotImplementedException(); 478 using (DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext()) { 479 if (user != null && user.ProviderUserKey != null && db.HeuristicLabUsers.Count(x => x.ID == (long)user.ProviderUserKey) > 0) { 480 HeuristicLabUser u = db.HeuristicLabUsers.Single(x => x.ID == (long)user.ProviderUserKey); 481 u.UserName = user.UserName; 482 u.Comment = user.Comment; 483 u.Email = user.Email; 484 u.Locked = user.IsLockedOut; 485 db.SubmitChanges(); 486 487 } 488 } 476 489 } 477 490 /// <summary> -
branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabMembershipProviderTest.cs
r4009 r4018 70 70 bool actual; 71 71 actual = target.RequiresUniqueEmail; 72 Assert.I nconclusive("Verify the correctness of this test method.");72 Assert.IsTrue(actual); 73 73 } 74 74 … … 92 92 string actual; 93 93 actual = target.PasswordStrengthRegularExpression; 94 Assert.Inconclusive("Verify the correctness of this test method."); 95 } 96 97 /// <summary> 98 ///A test for PasswordFormat 99 ///</summary> 100 [TestMethod()] 101 public void PasswordFormatTest() { 102 MembershipProvider target = Membership.Provider; 103 MembershipPasswordFormat actual; 104 actual = target.PasswordFormat; 105 Assert.Inconclusive("Verify the correctness of this test method."); 106 } 107 108 /// <summary> 109 ///A test for PasswordAttemptWindow 110 ///</summary> 111 [TestMethod()] 112 public void PasswordAttemptWindowTest() { 113 MembershipProvider target = Membership.Provider; // TODO: Initialize to an appropriate value 114 int actual; 115 actual = target.PasswordAttemptWindow; 116 Assert.Inconclusive("Verify the correctness of this test method."); 117 } 94 Assert.AreEqual(actual, String.Empty); 95 } 96 97 98 99 118 100 119 101 /// <summary> … … 187 169 bool actual; 188 170 actual = target.EnablePasswordRetrieval; 189 Assert.I nconclusive("Verify the correctness of this test method.");171 Assert.IsFalse(actual); 190 172 } 191 173 … … 198 180 bool actual; 199 181 actual = target.EnablePasswordReset; 200 Assert.Inconclusive("Verify the correctness of this test method."); 201 } 202 203 /// <summary> 204 ///A test for ApplicationName 205 ///</summary> 206 [TestMethod()] 207 public void ApplicationNameTest() { 208 MembershipProvider target = Membership.Provider; 209 string expected = string.Empty; // TODO: Initialize to an appropriate value 210 string actual; 211 target.ApplicationName = expected; 212 actual = target.ApplicationName; 213 Assert.AreEqual(expected, actual); 214 Assert.Inconclusive("Verify the correctness of this test method."); 182 Assert.IsFalse(actual); 215 183 } 216 184 … … 255 223 [TestMethod()] 256 224 public void UpdateUserTest() { 257 MembershipProvider target = Membership.Provider; // TODO: Initialize to an appropriate value 258 MembershipUser user = null; // TODO: Initialize to an appropriate value 225 MembershipProvider target = Membership.Provider; 226 MembershipCreateStatus status; 227 MembershipUser user = null; 228 target.CreateUser("testUser", "myPassword", "mail", "question", "answer", true, null, out status); 229 Assert.AreEqual(MembershipCreateStatus.Success, status); 230 user =target.GetUser("testUser", true); 231 Assert.IsNotNull(user); 232 user.Email = "newMail"; 259 233 target.UpdateUser(user); 260 Assert.Inconclusive("A method that does not return a value cannot be verified."); 234 user = target.GetUser("testUser", true); 235 Assert.AreEqual(user.Email, "newMail"); 261 236 } 262 237 … … 282 257 [TestMethod()] 283 258 public void ResetPasswordTest() { 284 MembershipProvider target = Membership.Provider; // TODO: Initialize to an appropriate value285 string username = string.Empty; // TODO: Initialize to an appropriate value286 string answer = string.Empty; // TODO: Initialize to an appropriate value287 string expected = string.Empty; // TODO: Initialize to an appropriate value259 MembershipProvider target = Membership.Provider; 260 string username = string.Empty; 261 string answer = string.Empty; 262 string expected = string.Empty; 288 263 string actual; 289 actual = target.ResetPassword(username, answer); 290 Assert.AreEqual(expected, actual); 291 Assert.Inconclusive("Verify the correctness of this test method."); 264 try { 265 target.ResetPassword("foo", "foo"); 266 } 267 catch (NotSupportedException) { 268 //should be thrown 269 } 270 292 271 } 293 272 … … 302 281 string actual; 303 282 actual = target.GetUserNameByEmail(email); 304 Assert.AreEqual(expected, actual); 305 Assert.Inconclusive("Verify the correctness of this test method."); 283 Assert.IsNull(actual); 284 MembershipCreateStatus status; 285 target.CreateUser("testuser", "mySecret", "testmail", "question", "answer", true, null, out status); 286 Assert.AreEqual(status, MembershipCreateStatus.Success); 287 Assert.AreEqual(target.GetUserNameByEmail("testmail"), "testuser"); 306 288 } 307 289 … … 334 316 string expected = string.Empty; // TODO: Initialize to an appropriate value 335 317 string actual; 336 actual = target.GetPassword(username, answer); 337 Assert.AreEqual(expected, actual); 338 Assert.Inconclusive("Verify the correctness of this test method."); 318 try { 319 actual = target.GetPassword(username, answer); 320 Assert.Fail(); 321 } 322 catch (NotSupportedException) { 323 //swallow because expected 324 } 325 339 326 } 340 327
Note: See TracChangeset
for help on using the changeset viewer.