diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-02 18:13:14 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2021-11-02 18:13:14 -0700 |
commit | cdfd6b85b386b7bbf9d5a5179ef26970b6e5a4e7 (patch) | |
tree | 5e4034027b51f3ee4d2a488bb2cbb7a75c3bd0d8 /python/tests/web_auth.py | |
parent | 78f08280edea4ff65ca613ad30005c45cc48dea6 (diff) | |
download | fatcat-cdfd6b85b386b7bbf9d5a5179ef26970b6e5a4e7.tar.gz fatcat-cdfd6b85b386b7bbf9d5a5179ef26970b6e5a4e7.zip |
fmt (black): tests/
Diffstat (limited to 'python/tests/web_auth.py')
-rw-r--r-- | python/tests/web_auth.py | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/python/tests/web_auth.py b/python/tests/web_auth.py index 643d806e..1238275e 100644 --- a/python/tests/web_auth.py +++ b/python/tests/web_auth.py @@ -1,4 +1,3 @@ - import responses from fixtures import * @@ -9,53 +8,74 @@ def test_ia_xauth_fail(full_app): # failed login with full_app.test_client() as app: - rv = app.get('/auth/ia/login') + 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")) + 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 - rv = app.get('/auth/account', follow_redirects=False) + rv = app.get("/auth/account", follow_redirects=False) assert rv.status_code == 302 + @responses.activate def test_ia_xauth(full_app): # successful login with full_app.test_client() as app: - rv = app.get('/auth/token_login') + rv = app.get("/auth/token_login") assert rv.status_code == 200 - 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")) + 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 - rv = app.get('/auth/account', follow_redirects=False) + rv = app.get("/auth/account", follow_redirects=False) assert rv.status_code == 200 + def test_basic_auth_views(app): - rv = app.get('/auth/login') + rv = app.get("/auth/login") assert rv.status_code == 200 - rv = app.get('/auth/logout') + rv = app.get("/auth/logout") assert rv.status_code == 200 + def test_auth_token(app_admin): - rv = app_admin.get('/auth/account', follow_redirects=False) + rv = app_admin.get("/auth/account", follow_redirects=False) assert rv.status_code == 200 - rv = app_admin.post('/auth/create_token', follow_redirects=False) + rv = app_admin.post("/auth/create_token", follow_redirects=False) assert rv.status_code == 200 |