From 9dfb5f3f83f715cdb16e68c4dedb12ca87bb93b3 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 4 Apr 2019 16:48:02 -0700 Subject: many web test improvements --- python/tests/web_auth.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 python/tests/web_auth.py (limited to 'python/tests/web_auth.py') diff --git a/python/tests/web_auth.py b/python/tests/web_auth.py new file mode 100644 index 00000000..81986eec --- /dev/null +++ b/python/tests/web_auth.py @@ -0,0 +1,46 @@ + +import json +import pytest +import responses +from fatcat_client.rest import ApiException +from fixtures import * + + +@responses.activate +def test_ia_xauth_fail(full_app): + + # failed login + with full_app.test_client() as app: + + rv = app.get('/auth/ia/login') + assert rv.status_code == 200 + + responses.add(responses.POST, full_app.config['IA_XAUTH_URI'] + "?op=authenticate", + status=401, json=dict(success=False)) + rv = app.post('/auth/ia/login', follow_redirects=True, + data=dict(email="abcd@example.com", password="god")) + assert rv.status_code == 401 + +@responses.activate +def test_ia_xauth(full_app): + + # successful login + with full_app.test_client() as app: + responses.add(responses.POST, full_app.config['IA_XAUTH_URI'] + "?op=authenticate", + status=200, json={'success': True}) + responses.add(responses.POST, full_app.config['IA_XAUTH_URI'] + "?op=info", + status=200, json={ + 'success': True, + 'values': {'screenname': "user123", + 'itemname': "user_item123"}}) + rv = app.post('/auth/ia/login', follow_redirects=True, + data=dict(email="abcd@example.com", password="god")) + assert rv.status_code == 200 + +def test_basic_auth_views(app): + + rv = app.get('/auth/login') + assert rv.status_code == 200 + + rv = app.get('/auth/logout') + assert rv.status_code == 200 -- cgit v1.2.3