Exemplo n.º 1
0
        public void Should_Cryptograph_Password_And_Generate_Salt()
        {
            var user = new User();
            user.Password = "******";
            user.CryptographPasswordAndGenerateSalt();

            Assert.IsTrue(!string.IsNullOrEmpty(user.Password));
            Assert.IsTrue(!string.IsNullOrEmpty(user.Salt));
        }
Exemplo n.º 2
0
        public void Should_Macth_Valid_Password()
        {
            string valid_password = "******";
            string salt = string.Empty;

            var user = new User();
            user.Password = CryptographyHelper.EncryptPassword(valid_password, out salt);
            user.Salt = salt;

            var match = user.VerifyPasswordMatch(valid_password);

            Assert.IsTrue(match);
        }
Exemplo n.º 3
0
        public void Should_Not_Macth_Wrong_Password()
        {
            string not_valid_password = "******";
            string valid_password = "******";
            string salt = string.Empty;

            var user = new User();
            user.Password = CryptographyHelper.EncryptPassword(valid_password, out salt);
            user.Salt = salt;

            var match = user.VerifyPasswordMatch(not_valid_password);

            Assert.IsFalse(match);
        }
Exemplo n.º 4
0
 public void Should_Thows_Exception_When_Try_Cryptograph_Password_And_Generate_Salt_With_Empty_Password()
 {
     var user = new User();
     user.Password = string.Empty;
     user.CryptographPasswordAndGenerateSalt();
 }