def test_auth_user_should_return_user_if_password_is_ok(database):
    user_repository = UserRepository(None, database, lambda: "admin-1")
    interactor = UserInteractor(None, user_repository)

    user = interactor.auth_user("admin1", "admin1111")
    assert user.user_id == "admin-1"
    assert user.username == "admin1"
    assert user.user_rol == "superadmin"
Beispiel #2
0
def test_auth_user_should_return_user_if_password_is_ok(database):
    user_repository = UserRepository(None, database, lambda: "user-1")
    interactor = UserInteractor(None, user_repository)

    user = interactor.auth_user("*****@*****.**", "user-1-password")
    assert user.id == "user-1"
    assert user.username == "*****@*****.**"
    assert user.name == "User 1"
    assert user.is_admin is False
def test_auth_user_should_raises_unauthorized_if_password_not_ok(database):
    user_repository = UserRepository(None, database, lambda: "user-1")
    interactor = UserInteractor(None, user_repository)

    with pytest.raises(NotAuthorizedError):
        interactor.auth_user("*****@*****.**", "user-1-bad-password")