Skip to content

Commit

Permalink
tests/api: Add "POST /settings/password/check" tests
Browse files Browse the repository at this point in the history
Turbo87 committed Feb 11, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 368ac94 commit 58e885b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/api/views/settings/password_check_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from tests.api import auth_for
from tests.data import add_fixtures, users


def test_correct_password(db_session, client):
john = users.john()
add_fixtures(db_session, john)

res = client.post('/settings/password/check', headers=auth_for(john), json={
'password': john.original_password,
})
assert res.status_code == 200
assert res.json == {'result': True}


def test_incorrect_password(db_session, client):
john = users.john()
add_fixtures(db_session, john)

res = client.post('/settings/password/check', headers=auth_for(john), json={
'password': 'foobar',
})
assert res.status_code == 200
assert res.json == {'result': False}


def test_invalid_json(db_session, client):
john = users.john()
add_fixtures(db_session, john)

res = client.post('/settings/password/check', headers=auth_for(john), data='foobar?')
assert res.status_code == 400


def test_unauthenticated(db_session, client):
res = client.post('/settings/password/check')
assert res.status_code == 401

0 comments on commit 58e885b

Please sign in to comment.