Exemple #1
0
def test_google_auth_user(get_user):
    # good local api auth result
    res = AuthForm(data=dict(user_id='google_auth', api_token='correct'))
    assert res.is_valid(), 'form errors: %s' % res.errors

    # assert save returned valid object for saving
    owner = UserFactory.create()
    instance = res.save(commit=False)
    instance.owner = owner
    instance.save()
Exemple #2
0
def test_facebook_auth_user(get_user):
    # good local api auth result
    res = AuthForm(data=dict(user_id='facebook_auth', api_token='correct'))
    assert res.is_valid(), 'form errors: %s' % res.errors
    assert res.instance.name == 'tester'
    assert res.instance.email == '*****@*****.**'

    # assert save returned valid object for saving
    owner = UserFactory.create()
    instance = res.save(commit=False)
    instance.owner = owner
    instance.save()
Exemple #3
0
def test_local_auth_user(get_user):
    # good local api auth result
    res = AuthForm(data=dict(user_id='local_auth', api_token='correct'))
    assert res.is_valid(), 'form errors: %s' % res.errors
    assert res.instance.name == utils.LOCAL_NAME
    assert res.instance.email == utils.USER_EMAIL

    # assert save returned valid object for saving
    owner = UserFactory.create()
    instance = res.save(commit=False)
    instance.owner = owner
    instance.save()
Exemple #4
0
def test_other_api_error(api_error):
    # all good on our end, server returned error
    res = AuthForm(data=dict(user_id='raise_error', api_token='raise_error'))
    assert not res.is_valid()
    assert res.errors == {'__all__': [AuthForm.AUTH_ERROR]}
Exemple #5
0
def test_unsupported_field_change(get_user):
    # all good on our end, but server now also supports twitter users
    res = AuthForm(data=dict(user_id='facebook_fail?', api_token='correct'))
    assert not res.is_valid()
    assert res.errors == {'__all__': [AuthForm.HABITICA_ERROR]}
Exemple #6
0
def test_auth_error(get_user):
    # bad api auth result
    res = AuthForm(data=dict(user_id='foo', api_token='baz'))
    assert not res.is_valid()
    assert res.errors == {'__all__': [AuthForm.AUTH_ERROR]}
Exemple #7
0
def test_no_user_details(get_user):
    # We still want to accept users which do not expose further user details
    res = AuthForm(data=dict(user_id='auth_provider_fail?', api_token='correct'))
    assert res.is_valid()