Ejemplo n.º 1
0
def check_username_and_password(username, password):
    if (validator.validate_username(username)
            and validator.validate_password(password)):
        pending_user = repositories.pending_register.find_one_by_username(
            username)
        if (pending_user):
            raise MustConfirmEmailException()
        user = repositories.user.find_one_by_username(username)
        if (not user):
            raise UserNotFoundException()
        if (not user.is_active):
            services.user.handle_in_active(user)
        if not verify_password(user.password, password):
            services.wrong_password.handle_wrong_password(user)
        return user
    else:
        raise BadRequestException(message.INVALID_USERNAME_OR_PASSWORD)
Ejemplo n.º 2
0
 def test_random_password_generator(self):
     for i in range(100):
         random_password = password.gen_new_password()
         self.assertTrue(validator.validate_password(random_password))
Ejemplo n.º 3
0
 def test_valid_password(self):
     for valid_password in VALID_PASSWORD:
         self.assertTrue(validator.validate_password(valid_password))
Ejemplo n.º 4
0
 def test_invalid_password(self):
     for invalid_password in INVALID_PASSWORDS:
         self.assertFalse(validator.validate_password(invalid_password))