public void ShouldNotAcceptNullPasswordWhenHashingPassword()
        {
            var user         = GenericUserFaker.GenerateUser().Generate();
            var argon2Hasher = new Argon2Id <GenericUser>();

            argon2Hasher.Invoking(i => i.HashPassword(user, null))
            .Should().Throw <ArgumentNullException>();
        }
        public void ShouldNotAcceptNullHashedPasswordWhenVerifyingPassword()
        {
            var options = Options.Create(new ImprovedPasswordHasherOptions() { Strenght = PasswordHasherStrenght.Interactive });
            var password = _faker.Internet.Password();
            var user = GenericUserFaker.GenerateUser().Generate();
            var scryptHasher = new Scrypt<GenericUser>(options);

            scryptHasher.Invoking(i => i.VerifyHashedPassword(user, null, password))
                .Should().Throw<ArgumentNullException>();
        }
        public void ShouldBeTrueWhenPasswordWithCustomStrength()
        {
            var options      = Options.Create(ImprovedPasswordHasherOptionsFaker.GenerateRandomOptions().Generate());
            var password     = _faker.Internet.Password();
            var user         = GenericUserFaker.GenerateUser().Generate();
            var argon2Hasher = new Argon2Id <GenericUser>(options);

            var hashedPass = argon2Hasher.HashPassword(user, password);

            argon2Hasher.VerifyHashedPassword(user, hashedPass, password).Should().Be(PasswordVerificationResult.Success);
        }
        public void ShouldBeTrueWhenPasswordWithCustomWorkload()
        {
            var options      = Options.Create(ImprovedPasswordHasherOptionsFaker.GenerateRandomOptions().Generate());
            var password     = _faker.Internet.Password();
            var user         = GenericUserFaker.GenerateUser().Generate();
            var scryptHasher = new BCrypt <GenericUser>(options);

            var hashedPass = scryptHasher.HashPassword(user, password);

            scryptHasher.VerifyHashedPassword(user, hashedPass, password).Should().Be(PasswordVerificationResult.Success);
        }
        public void ShouldBeTrueWhenPasswordStrengthModerate()
        {
            var options = Options.Create(new ImprovedPasswordHasherOptions() { Strenght = PasswordHasherStrenght.Moderate });
            var password = _faker.Internet.Password();
            var user = GenericUserFaker.GenerateUser().Generate();
            var scryptHasher = new Scrypt<GenericUser>(options);

            var hashedPass = scryptHasher.HashPassword(user, password);

            scryptHasher.VerifyHashedPassword(user, hashedPass, password).Should().Be(PasswordVerificationResult.Success);
        }
        public void ShouldBeTrueWhenPasswordStrengthSensitive()
        {
            var options = Options.Create(new ImprovedPasswordHasherOptions()
            {
                Strenght = PasswordHasherStrenght.Sensitive
            });

            var password     = _faker.Internet.Password();
            var user         = GenericUserFaker.GenerateUser().Generate();
            var argon2Hasher = new Argon2Id <GenericUser>(options);

            var hashedPass = argon2Hasher.HashPassword(user, password);

            argon2Hasher.VerifyHashedPassword(user, hashedPass, password).Should().Be(PasswordVerificationResult.Success);
        }
        public void ShouldNotAcceptNullUserWhenVerifyingPassword()
        {
            var options = Options.Create(new ImprovedPasswordHasherOptions()
            {
                Strenght = PasswordHasherStrenght.Interactive
            });
            var password     = _faker.Internet.Password();
            var user         = GenericUserFaker.GenerateUser().Generate();
            var argon2Hasher = new Argon2Id <GenericUser>(options);

            var hashedPass = argon2Hasher.HashPassword(user, password);

            argon2Hasher.Invoking(i => i.VerifyHashedPassword(null, hashedPass, password))
            .Should().Throw <ArgumentNullException>();
        }
        public void ShouldBeTrueWhenSaltRevision2Y()
        {
            var options = Options.Create(new ImprovedPasswordHasherOptions()
            {
                SaltRevision = BcryptSaltRevision.Revision2Y
            });

            var password     = _faker.Internet.Password();
            var user         = GenericUserFaker.GenerateUser().Generate();
            var scryptHasher = new BCrypt <GenericUser>(options);

            var hashedPass = scryptHasher.HashPassword(user, password);

            scryptHasher.VerifyHashedPassword(user, hashedPass, password).Should().Be(PasswordVerificationResult.Success);
        }