public void ValidateUser_EmptyPassword()
 {
     Assert.Throws <UnprocessableEntityException>(
         () => JwtAuthenticationService.ValidateUser(new User {
         EMail = "test"
     }, ""));
 }
        public void ValidateUser_Success()
        {
            var usr       = new User();
            var password  = "******";
            var hashTuple = password.HashPassword();

            usr.Password = hashTuple.Item1;
            usr.Salt     = hashTuple.Item2;
            usr.EMail    = "Username";
            usr.Claims.Add(UserClaim.FromClaim(new UsernameClaim(usr.EMail)));

            JwtAuthenticationService.ValidateUser(usr, password);
        }
        public void ValidateUser_WrongPassword()
        {
            var usr       = new User();
            var password  = "******";
            var hashTuple = password.HashPassword();

            usr.Password = hashTuple.Item1;
            usr.Salt     = hashTuple.Item2;
            usr.EMail    = "Username";
            usr.Claims.Add(UserClaim.FromClaim(new UsernameClaim(usr.EMail)));

            Assert.Throws <UnauthorizedException>(() => JwtAuthenticationService.ValidateUser(usr, "wrong password"));
        }
 public void ValidateUser_NoUser()
 {
     Assert.Throws <UnauthorizedException>(() => JwtAuthenticationService.ValidateUser(null, "bla"));
 }