Skip to content

Commit

Permalink
Merge pull request #198 from wasade/token_error_on_authrocket_callback
Browse files Browse the repository at this point in the history
Token error on authrocket callback
  • Loading branch information
wasade authored Oct 18, 2021
2 parents 6da3fa9 + 2657adf commit e3899db
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
7 changes: 5 additions & 2 deletions microsetta_interface/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,10 @@ def get_rootpath():
return redirect(HOME_URL)


def get_authrocket_callback(token, redirect_uri=None):
def get_authrocket_callback(token=None, redirect_uri=None):
if token is None:
return redirect('/home')

session[TOKEN_KEY_NAME] = token
email, _ = _parse_jwt(token)
session[LOGIN_INFO_KEY] = {
Expand Down Expand Up @@ -1480,7 +1483,7 @@ def post_address_verification(body):
req_csv_columns = ["Address 1","Address 2","City","State","Postal Code",\
"Country"]

csv_contents, upload_err = parse_request_csv(request, 'address_csv',
csv_contents, upload_err = parse_request_csv(request, 'address_csv',
req_csv_columns)

ar = None
Expand Down
19 changes: 18 additions & 1 deletion microsetta_interface/tests/test_implementation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from unittest import TestCase
from unittest import TestCase, main
from unittest.mock import patch
from microsetta_interface.server import app

Expand Down Expand Up @@ -29,11 +29,13 @@ def setUp(self):

app.app.testing = True
self.app = app.app.test_client()
self.app.__enter__()

def tearDown(self):
self.patch_for_get.stop()
self.patch_for_render_template.stop()
self.patch_for_session.stop()
self.app.__exit__(None, None, None)


class TestImplementation(TestBase):
Expand Down Expand Up @@ -62,3 +64,18 @@ def __init__(self, status_code, text, json_val, headers=None):
response = impl.get_source(account_id="1", source_id="2")
self.assertEqual(302, response.status_code)
self.assertEqual('/home', response.headers['Location'])

def test_authrocket_callback_noargs_error(self):
# We are observing exceptions on /authrocket_callback which occur with
# malformed requests. Currently, we are throwing a 500, but instead
# we should redirect
exp_status = 302
exp_location = '/home'

resp = self.app.get('/authrocket_callback')
self.assertEqual(exp_status, resp.status_code)
self.assertTrue(resp.headers['Location'].endswith(exp_location))


if __name__ == '__main__':
main()

0 comments on commit e3899db

Please sign in to comment.