Pytest Flask Request Referrer
The Flask test client does not appear to add the Referer
header when it follows redirects.
What you can do is implement your own version of following redirects. Maybe something like this:
def confirm_bpm_login(client, group_name, username, password): """ POST to /confirm """ response = client.post('/confirm', data=dict( group_name=group_name, username=username, password=password, submit=True ), follow_redirects=False) if 300 <= response.status_code < 400: response = client.get(response.headers['Location'], headers={ "Referer": 'http://localhost/confirm' }) return response
Please test this, I wrote it from memory and may need some minor adjustments.