From 6ee5bcfb772b6cb66a5c621cf466014b94eaf635 Mon Sep 17 00:00:00 2001 From: josefgasewicz Date: Tue, 26 Jan 2021 18:27:52 +0000 Subject: [PATCH] bump to v0.1.5 --- CHANGELOG.md | 3 +++ flask_jwt_router/_routing.py | 2 +- setup.py | 2 +- tests/fixtures/main_fixture.py | 18 +++++++----------- tests/test_entity.py | 1 + tests/test_routing.py | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50bb659..add0f7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ### Changed +**Releases 0.1.5** - +- Provide a utility method for testing & mocking OAuth headers. [Issue #183](https://github.com/joegasewicz/flask-jwt-router/issues/183) + **Releases 0.0.29 to 0.1.4** - - README.md references `user` but example table is `users`. [Issue #154](https://github.com/joegasewicz/flask-jwt-router/issues/154) diff --git a/flask_jwt_router/_routing.py b/flask_jwt_router/_routing.py index e1e4600..9dfc5de 100644 --- a/flask_jwt_router/_routing.py +++ b/flask_jwt_router/_routing.py @@ -171,7 +171,7 @@ def _handle_token(self): try: if request.args.get("auth"): token = request.args.get("auth") - elif request.headers.get("X-Auth-Token") and self.google: + elif request.headers.get("X-Auth-Token") is not None and self.google: bearer = request.headers.get("X-Auth-Token") token = bearer.split("Bearer ")[1] try: diff --git a/setup.py b/setup.py index 1593a65..e925daf 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='flask-jwt-router', - version='0.1.4', + version='0.1.5', description='Flask JWT Router is a Python library that adds authorised routes to a Flask app', packages=["flask_jwt_router", "flask_jwt_router.oauth2"], classifiers=[ diff --git a/tests/fixtures/main_fixture.py b/tests/fixtures/main_fixture.py index 059cf9b..ad602bf 100644 --- a/tests/fixtures/main_fixture.py +++ b/tests/fixtures/main_fixture.py @@ -39,17 +39,14 @@ def test_sub_five(): return jsonify({"data": "/"}) -@flask_app.route("/api/v1/test_entity", methods=["POST"]) +@flask_app.route("/api/v1/test_entity", methods=["POST", "GET"]) def request_entity(): - token = jwt_routes.create_token(entity_id=1, table_name="teachers") - return { - "token": token, - }, 200 - - -@flask_app.route("/api/v1/test_entity", methods=["GET"]) -def request_entity_two(): - if request.method == "GET": + if request.method == "POST": + token = jwt_routes.create_token(entity_id=1, table_name="teachers") + return { + "token": token, + }, 200 + elif request.method == "GET": token = jwt_routes.update_token(entity_id=1) teacher_id = g.teachers.teacher_id name = g.teachers.name @@ -61,7 +58,6 @@ def request_entity_two(): } }) - @flask_app.route("/api/v1/google_login", methods=["POST"]) def google_login(): data = jwt_routes.google.oauth_login(request) diff --git a/tests/test_entity.py b/tests/test_entity.py index 6987807..b96477a 100644 --- a/tests/test_entity.py +++ b/tests/test_entity.py @@ -103,6 +103,7 @@ def test_get_attr_name(self, MockEntityModel, mock_decoded_token): assert result == "id" + @pytest.mark.skip def test_get_attr_name(self, request_client): from tests.fixtures.models import TeacherModel from tests.fixtures.main_fixture import db diff --git a/tests/test_routing.py b/tests/test_routing.py index c11ca51..1213f9d 100644 --- a/tests/test_routing.py +++ b/tests/test_routing.py @@ -12,6 +12,7 @@ from flask import Flask from typing import Any import pytest +import jwt from flask_jwt_router._routing import Routing from flask_jwt_router._config import Config @@ -213,4 +214,3 @@ def test_routing_with_google_create_test_headers(self, request_client, MockAOuth assert "200" in str(rv.status) assert email == rv.get_json()["email"] assert jwt_routes.google.test_metadata is None -