add error handler that catches invalid tokens, and returns 404

This commit is contained in:
Leo Hemsted
2017-11-01 15:47:05 +00:00
parent aff9d47323
commit 19f731ec07
2 changed files with 26 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import pytest
from bs4 import BeautifulSoup
@@ -6,3 +7,19 @@ def test_bad_url_returns_page_not_found(client):
assert response.status_code == 404
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert page.h1.string.strip() == 'Page could not be found'
@pytest.mark.parametrize('url', [
'/invitation/MALFORMED_TOKEN',
'/new-password/MALFORMED_TOKEN',
'/user-profile/email/confirm/MALFORMED_TOKEN',
'/verify-email/MALFORMED_TOKEN'
])
def test_malformed_token_returns_page_not_found(client, url):
response = client.get(url)
assert response.status_code == 404
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert page.h1.string.strip() == 'Page could not be found'
flash_banner = page.find('div', class_='banner-dangerous').string.strip()
assert flash_banner == "Theres something wrong with the link youve used."