diff --git a/api/public/tests/features/steps/wolfram_alpha.py b/api/public/tests/features/steps/wolfram_alpha.py new file mode 100644 index 00000000..5ac015e8 --- /dev/null +++ b/api/public/tests/features/steps/wolfram_alpha.py @@ -0,0 +1,20 @@ +from http import HTTPStatus + +from behave import when, then +from hamcrest import assert_that + + +@when('a question is sent') +def send_question(context): + login = context.device_login + access_token = login['accessToken'] + context.wolfram_response = context.client.get( + '/v1/wa?input=what+is+the+capital+of+Brazil', + headers=dict(Authorization='Bearer {token}'.format(token=access_token)) + ) + + +@then('the wolfram alpha endpoint should return 200') +def validate_response(context): + response = context.wolfram_response + assert_that(response.status_code, HTTPStatus.OK) diff --git a/api/public/tests/features/wolfram_alpha.feature b/api/public/tests/features/wolfram_alpha.feature new file mode 100644 index 00000000..b44676c8 --- /dev/null +++ b/api/public/tests/features/wolfram_alpha.feature @@ -0,0 +1,5 @@ +Feature: Integration with Wolfram Alpha API + + Scenario: Question sent to the wolfram alpha endpoint + When a question is sent + Then the wolfram alpha endpoint should return 200 \ No newline at end of file diff --git a/shared/selene/api/public_endpoint.py b/shared/selene/api/public_endpoint.py index 0ba9e6ac..fdfc6772 100644 --- a/shared/selene/api/public_endpoint.py +++ b/shared/selene/api/public_endpoint.py @@ -21,13 +21,12 @@ ONE_DAY = 86400 def check_oauth_token(): + global_context.url = request.url exclude_paths = ['/v1/device/code', '/v1/device/activate', '/api/account', '/v1/auth/token'] exclude = any(request.path.startswith(path) for path in exclude_paths) - if not exclude: headers = request.headers if 'Authorization' not in headers: - global_context.url = request.url raise AuthenticationError('Oauth token not found') token_header = headers['Authorization'] device_authenticated = False @@ -37,7 +36,6 @@ def check_oauth_token(): if session: device_authenticated = True if not device_authenticated: - global_context.url = request.url raise AuthenticationError('device not authorized')