Ejemplo n.º 1
0
def test_login_no_event_when_validation_fails(loginevent,
                                              authn_policy,
                                              notify):
    request = DummyRequest()
    authn_policy.authenticated_userid.return_value = None  # Logged out
    controller = AuthController(request)
    controller.form = invalid_form()

    controller.login()

    assert not loginevent.called
    assert not notify.called
Ejemplo n.º 2
0
def test_login_no_event_when_validation_fails(loginevent,
                                              authn_policy,
                                              notify):
    request = DummyRequest()
    authn_policy.authenticated_userid.return_value = None  # Logged out
    controller = AuthController(request)
    controller.form = invalid_form()

    controller.login()

    assert not loginevent.called
    assert not notify.called
Ejemplo n.º 3
0
def test_login_event_when_validation_succeeds(loginevent,
                                              authn_policy,
                                              notify):
    request = DummyRequest(auth_domain='hypothes.is')
    authn_policy.authenticated_userid.return_value = None  # Logged out
    elephant = FakeUser(username='******')
    controller = AuthController(request)
    controller.form = form_validating_to({"user": elephant})

    controller.login()

    loginevent.assert_called_with(request, elephant)
    notify.assert_called_with(loginevent.return_value)
Ejemplo n.º 4
0
def test_login_event_when_validation_succeeds(loginevent,
                                              authn_policy,
                                              notify):
    request = DummyRequest(auth_domain='hypothes.is')
    authn_policy.authenticated_userid.return_value = None  # Logged out
    elephant = FakeUser(username='******')
    controller = AuthController(request)
    controller.form = form_validating_to({"user": elephant})

    controller.login()

    loginevent.assert_called_with(request, elephant)
    notify.assert_called_with(loginevent.return_value)
Ejemplo n.º 5
0
def test_login_redirects_when_validation_succeeds(authn_policy):
    request = DummyRequest(auth_domain='hypothes.is')
    authn_policy.authenticated_userid.return_value = None  # Logged out
    controller = AuthController(request)
    controller.form = form_validating_to({"user": FakeUser(username='******')})

    result = controller.login()

    assert isinstance(result, httpexceptions.HTTPFound)
Ejemplo n.º 6
0
def test_login_returns_form_when_validation_fails(authn_policy):
    request = DummyRequest()
    authn_policy.authenticated_userid.return_value = None  # Logged out
    controller = AuthController(request)
    controller.form = invalid_form()

    result = controller.login()

    assert result == {'form': 'invalid form'}
Ejemplo n.º 7
0
def test_login_returns_form_when_validation_fails(authn_policy):
    request = DummyRequest()
    authn_policy.authenticated_userid.return_value = None  # Logged out
    controller = AuthController(request)
    controller.form = invalid_form()

    result = controller.login()

    assert result == {'form': 'invalid form'}
Ejemplo n.º 8
0
def test_login_redirects_when_validation_succeeds(authn_policy):
    request = DummyRequest(auth_domain='hypothes.is')
    authn_policy.authenticated_userid.return_value = None  # Logged out
    controller = AuthController(request)
    controller.form = form_validating_to({"user": FakeUser(username='******')})

    result = controller.login()

    assert isinstance(result, httpexceptions.HTTPFound)