コード例 #1
0
ファイル: views_test.py プロジェクト: jasdeep/h
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
コード例 #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
コード例 #3
0
ファイル: views_test.py プロジェクト: jasdeep/h
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)
コード例 #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)
コード例 #5
0
ファイル: views_test.py プロジェクト: jasdeep/h
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)
コード例 #6
0
ファイル: views_test.py プロジェクト: jasdeep/h
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'}
コード例 #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'}
コード例 #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)