public void AdminDefaultPasswordIsSaltedSha512Hash()
 {
     Action<string, string> updateHook = (username, password) =>
     {
         Assert.Fail("Generating password hash should not update the related db entry.");
     };
     var passwordService = new PasswordService(updateHook);
     var saltedHash = passwordService.GetSaltedHash(DefaultAdminPassword, DefaultAdminUserName);
     Assert.AreEqual(DefaultAdminHash, saltedHash);
 }
 public void WrongSha512PasswordsWontBeUpgraded()
 {
     Action<string, string> updateHook = (username, password) =>
     {
         Assert.Fail("Wrong sha512 password must not be upgraded.");
     };
     var passwordService = new PasswordService(updateHook);
     bool isCorrect = passwordService
         .ComparePassword("1" + DefaultAdminPassword, DefaultAdminUserName, DefaultAdminUserName, DefaultAdminHash);
     Assert.IsFalse(isCorrect);
 }
 public void CorrectSha512PasswordsWontBeUpgraded()
 {
     Action<string, string> updateHook = (username, password) =>
     {
         Assert.Fail("Sha512 password does not need to be upgraded.");
     };
     var passwordService = new PasswordService(updateHook);
     bool isCorrect = passwordService
         .ComparePassword(DefaultAdminPassword, DefaultAdminUserName, DefaultAdminUserName, DefaultAdminHash);
     Assert.IsTrue(isCorrect);
 }
 public void CorrectMd5PasswordsWillBeUpgraded()
 {
     int correctUpgradeHookCalls = 0;
     var username = DefaultAdminUserName;
     var password = DefaultAdminPassword;
     Action<string, string> updateHook = (updateUsername, updatePassword) =>
     {
         Assert.AreEqual(username, updateUsername);
         Assert.AreEqual(password, updatePassword);
         ++correctUpgradeHookCalls;
     };
     var passwordService = new PasswordService(updateHook);
     bool isCorrect = passwordService
         .ComparePassword(password, username, username, Md5DefaultAdminHash);
     Assert.IsTrue(isCorrect);
     Assert.AreEqual(1, correctUpgradeHookCalls, "Correct md5 password should be upgraded exactly once.");
 }