Exemplo n.º 1
0
        public void Test_VerifyHashedPassword_ShouldReturnFailed_FromBcryptIntermediateWithoutVersion_ValidPassword()
        {
            var password = "******";
            var hashed   = HashHelpers.CreateHashWithVersion(HashHelpers.CreateSHA256Hash(password), HashVersionEnum.Intermediate_SHA256_Bcrypt, addVersion: false);

            var verified = passwordHasher.VerifyHashedPassword(user, hashed, password);

            verified.Should().Be(PasswordVerificationResult.Failed);
        }
Exemplo n.º 2
0
        public void Test_VerifyHashedPassword_ShouldReturnFailed_FromSHA256WithVersion_InvalidPassword()
        {
            var password = "******";
            var hashed   = HashHelpers.CreateHashWithVersion(password, HashVersionEnum.SHA256);

            var verified = passwordHasher.VerifyHashedPassword(user, hashed, "test12345");

            verified.Should().Be(PasswordVerificationResult.Failed);
        }
Exemplo n.º 3
0
        public void Test_VerifyHashedPassword_ShouldReturnSuccessRehashNeeded_FromSHA256WithoutVersion_ValidPassword()
        {
            var password = "******";
            var hashed   = HashHelpers.CreateHashWithVersion(password, HashVersionEnum.SHA256, addVersion: false);

            var verified = passwordHasher.VerifyHashedPassword(user, hashed, password);

            verified.Should().Be(PasswordVerificationResult.SuccessRehashNeeded);
        }
Exemplo n.º 4
0
        public void Test_VerifyHashedPassword_ShouldReturnFailed_FromSHA256WithWrongVersion_ValidPassword()
        {
            var password = "******";
            var hashed   = HashHelpers.CreateHashWithVersion(password, HashVersionEnum.SHA256, addVersion: false);

            // Wrong version for hash
            hashed = hashed + "$3";

            var verified = passwordHasher.VerifyHashedPassword(user, hashed, password);

            verified.Should().Be(PasswordVerificationResult.Failed);
        }