added test for editing tokens
This commit is contained in:
parent
a621b6bb78
commit
c941d383c1
|
@ -336,3 +336,41 @@ def test_register_token(client_authenticated, mocker):
|
||||||
assert 'Elves' in page_src
|
assert 'Elves' in page_src
|
||||||
assert 'legolas@mirkwood.me' in page_src
|
assert 'legolas@mirkwood.me' in page_src
|
||||||
|
|
||||||
|
|
||||||
|
def test_edit_token(client_authenticated):
|
||||||
|
# test with invalid token
|
||||||
|
response = client_authenticated.get(f"/edit-token/nosuchtoken",
|
||||||
|
follow_redirects=True)
|
||||||
|
page_src = response.data.decode()
|
||||||
|
assert 'Ungültiger Token' in page_src
|
||||||
|
|
||||||
|
response = client_authenticated.post(f"/edit-token/nosuchtoken",
|
||||||
|
follow_redirects=True)
|
||||||
|
page_src = response.data.decode()
|
||||||
|
assert 'Token konnte nicht editiert werden' in page_src
|
||||||
|
|
||||||
|
# test using a valid token from the token file
|
||||||
|
response = client_authenticated.get(f"/edit-token/04538cfa186280",
|
||||||
|
follow_redirects=True)
|
||||||
|
csrf_token = extract_csrf_token(response)
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
'name': 'Balin',
|
||||||
|
'organization': 'Dwarves',
|
||||||
|
'email': 'balin@erebor.me',
|
||||||
|
'active': True,
|
||||||
|
'limit_validity': False,
|
||||||
|
'valid_thru': datetime.date.today(),
|
||||||
|
'csrf_token': csrf_token
|
||||||
|
}
|
||||||
|
response = client_authenticated.post(f"/edit-token/04538cfa186280",
|
||||||
|
data=payload,
|
||||||
|
follow_redirects=True)
|
||||||
|
page_src = response.data.decode()
|
||||||
|
# make sure the new user info for the token is displayed
|
||||||
|
assert '04538cfa186280' in page_src
|
||||||
|
assert 'Balin' in page_src
|
||||||
|
assert 'Dwarves' in page_src
|
||||||
|
assert 'balin@erebor.me' in page_src
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in New Issue
Block a user