From e91574fe3c830105f85bb81645eed7132f8741ea Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Mon, 23 Oct 2023 14:06:46 -0300 Subject: [PATCH] Fix tests --- auth-domain/user-manager/Dockerfile.test | 2 +- auth-domain/user-manager/src/api/auth.py | 4 ++-- auth-domain/user-manager/src/api/models/users.py | 3 ++- auth-domain/user-manager/src/tests/functional/test_auth.py | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/auth-domain/user-manager/Dockerfile.test b/auth-domain/user-manager/Dockerfile.test index c1fb2e6..3facdf6 100644 --- a/auth-domain/user-manager/Dockerfile.test +++ b/auth-domain/user-manager/Dockerfile.test @@ -4,7 +4,7 @@ FROM ${BASE_IMAGE} ENV FLASK_DEBUG=1 ENV FLASK_ENV=development -ENV DATABASE_TEST_URL=postgresql://postgres:postgres@usermanager-db:5432/api_test +ENV DATABASE_TEST_URL=postgresql://user:password@usermanager-db:5432/api_test # add and install requirements COPY --chown=python:python ./requirements.test.txt . diff --git a/auth-domain/user-manager/src/api/auth.py b/auth-domain/user-manager/src/api/auth.py index ae2d0d2..490a40a 100644 --- a/auth-domain/user-manager/src/api/auth.py +++ b/auth-domain/user-manager/src/api/auth.py @@ -54,8 +54,8 @@ class Login(Resource): access_token = user.encode_token(user.id, "access", user.airline) refresh_token = user.encode_token(user.id, "refresh") - response_object = {"access_token": access_token, - "refresh_token": refresh_token, + response_object = {"access_token": access_token, + "refresh_token": refresh_token, "user_id": user.id} return response_object, 200 diff --git a/auth-domain/user-manager/src/api/models/users.py b/auth-domain/user-manager/src/api/models/users.py index 92b357f..90ce346 100644 --- a/auth-domain/user-manager/src/api/models/users.py +++ b/auth-domain/user-manager/src/api/models/users.py @@ -89,8 +89,9 @@ class User(db.Model): def get_api_auth_full_user_model(cls, namespace): return namespace.clone( "User Full", - cls.get_api_auth_user_model(namespace), { + "username": fields.String(required=True), + "email": fields.String(required=True), "password": fields.String(required=True), }, ) diff --git a/auth-domain/user-manager/src/tests/functional/test_auth.py b/auth-domain/user-manager/src/tests/functional/test_auth.py index f92ee7b..1e70737 100644 --- a/auth-domain/user-manager/src/tests/functional/test_auth.py +++ b/auth-domain/user-manager/src/tests/functional/test_auth.py @@ -22,6 +22,8 @@ def test_user_registration(test_app, test_database): content_type="application/json", ) data = json.loads(resp.data.decode()) + print(data) + print(resp) assert resp.status_code == 201 assert resp.content_type == "application/json" assert TEST_USERNAME in data["username"]