From 32b5d2a7b7f2349e2a7b85e64abaa7e76999d0a7 Mon Sep 17 00:00:00 2001 From: Hrvoje Fekete Date: Tue, 19 Mar 2024 11:01:51 -0700 Subject: [PATCH] Updated variable naming. --- btr-api/.env.sample | 2 ++ btr-api/src/btr_api/config.py | 2 +- btr-api/src/btr_api/services/auth.py | 2 +- .../tests/unit/resources/test_submissions.py | 18 +++++++++--------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/btr-api/.env.sample b/btr-api/.env.sample index af2882b8..90c772bf 100644 --- a/btr-api/.env.sample +++ b/btr-api/.env.sample @@ -6,6 +6,8 @@ POD_NAMESPACE=local LD_SDK_KEY= # Registry Integration Services +AUTH_SVC_API_URL= +AUTH_SVC_API_VERSION=/api/v1 PAY_API_URL= PAY_API_VERSION=/api/v1 LEGAL_API_URL= diff --git a/btr-api/src/btr_api/config.py b/btr-api/src/btr_api/config.py index 143a8382..e1539614 100644 --- a/btr-api/src/btr_api/config.py +++ b/btr-api/src/btr_api/config.py @@ -104,7 +104,7 @@ class Config: # pylint: disable=too-few-public-methods JWT_OIDC_FIRSTNAME = os.getenv('JWT_OIDC_FIRSTNAME', 'firstname') JWT_OIDC_LASTNAME = os.getenv('JWT_OIDC_LASTNAME', 'lastname') - AUTH_SVC_URL = os.getenv('AUTH_SVC_URL', '') + AUTH_API_URL = os.getenv('AUTH_API_URL', '') + os.getenv('AUTH_API_VERSION', '') PAYMENT_SVC_URL = os.getenv('PAY_API_URL', '') + os.getenv('PAY_API_VERSION', '') LEGAL_SVC_URL = os.getenv('LEGAL_API_URL', '') + os.getenv('LEGAL_API_VERSION_2', '') BOR_SVC_URL = os.getenv('BOR_API_URL', '') + os.getenv('BOR_API_VERSION', '') diff --git a/btr-api/src/btr_api/services/auth.py b/btr-api/src/btr_api/services/auth.py index c10115b0..fc97c194 100644 --- a/btr-api/src/btr_api/services/auth.py +++ b/btr-api/src/btr_api/services/auth.py @@ -59,7 +59,7 @@ def __init__(self, app: Flask = None): def init_app(self, app: Flask): """Initialize app dependent variables.""" self.app = app - self.svc_url = app.config.get('AUTH_SVC_URL') + self.svc_url = app.config.get('AUTH_API_URL') self.timeout = app.config.get('AUTH_API_TIMEOUT', 20) self.sso_svc_token_url = app.config.get('SSO_SVC_TOKEN_URL') self.sso_svc_timeout = app.config.get('SSO_SVC_TIMEOUT', 20) diff --git a/btr-api/tests/unit/resources/test_submissions.py b/btr-api/tests/unit/resources/test_submissions.py index 26253529..dfcf1e15 100644 --- a/btr-api/tests/unit/resources/test_submissions.py +++ b/btr-api/tests/unit/resources/test_submissions.py @@ -37,7 +37,7 @@ def test_get_plots(app, client, session, jwt, requests_mock, test_name, submissi session.commit() id = sub.id - requests_mock.get(f"{app.config.get('AUTH_SVC_URL')}/entities/{sub.business_identifier}/authorizations", + requests_mock.get(f"{app.config.get('AUTH_API_URL')}/entities/{sub.business_identifier}/authorizations", json={"orgMembership": "COORDINATOR", 'roles': ['edit', 'view']}) # Test rv = client.get(f'/plots/{id}', @@ -82,7 +82,7 @@ def test_get_plots_auth(app, client, session, jwt, requests_mock, test_name, bus session.commit() search_id = sub.id - requests_mock.get(f"{app.config.get('AUTH_SVC_URL')}/entities/{business_identifier}/authorizations", + requests_mock.get(f"{app.config.get('AUTH_API_URL')}/entities/{business_identifier}/authorizations", json=auth_svc_response) headers = create_header(jwt, @@ -118,7 +118,7 @@ def test_post_plots_db_mocked(app, session, client, jwt, mocker, requests_mock): mocked_entity_response = {"business": {"adminFreeze": False, "state": "ACTIVE"}} identifier = json_data['businessIdentifier'] - requests_mock.get(f"{app.config.get('AUTH_SVC_URL')}/entities/{identifier}/authorizations", + requests_mock.get(f"{app.config.get('AUTH_API_URL')}/entities/{identifier}/authorizations", json={"orgMembership": "COORDINATOR", 'roles': ['edit', 'view']}) legal_api_mock = requests_mock.get( f"{app.config.get('LEGAL_SVC_URL')}/businesses/{identifier}", @@ -200,7 +200,7 @@ def test_post_plots(app, client, session, jwt, requests_mock): mocked_entity_response = {"business": {"adminFreeze": False, "state": "ACTIVE"}} identifier = json_data['businessIdentifier'] - requests_mock.get(f"{app.config.get('AUTH_SVC_URL')}/entities/{identifier}/authorizations", + requests_mock.get(f"{app.config.get('AUTH_API_URL')}/entities/{identifier}/authorizations", json={"orgMembership": "COORDINATOR", 'roles': ['edit', 'view']}) legal_api_mock = requests_mock.get( f"{app.config.get('LEGAL_SVC_URL')}/businesses/{identifier}", @@ -252,7 +252,7 @@ def test_post_plots_pay_error(app, client, session, jwt, requests_mock): mocked_entity_response = {"business": {"adminFreeze": False, "state": "ACTIVE"}} identifier = json_data['businessIdentifier'] - requests_mock.get(f"{app.config.get('AUTH_SVC_URL')}/entities/{identifier}/authorizations", + requests_mock.get(f"{app.config.get('AUTH_API_URL')}/entities/{identifier}/authorizations", json={"orgMembership": "COORDINATOR", 'roles': ['edit', 'view']}) legal_api_mock = requests_mock.get( f"{app.config.get('LEGAL_SVC_URL')}/businesses/{identifier}", @@ -296,7 +296,7 @@ def test_post_plots_auth_error(app, client, session, jwt, requests_mock): mocked_entity_response = {"business": {"adminFreeze": False, "state": "ACTIVE"}} identifier = json_data['businessIdentifier'] - requests_mock.get(f"{app.config.get('AUTH_SVC_URL')}/entities/{identifier}/authorizations", + requests_mock.get(f"{app.config.get('AUTH_API_URL')}/entities/{identifier}/authorizations", json={"orgMembership": "COORDINATOR", 'roles': ['edit', 'view']}) legal_api_mock = requests_mock.get( f"{app.config.get('LEGAL_SVC_URL')}/businesses/{identifier}", @@ -339,7 +339,7 @@ def test_post_plots_bor_error(app, client, session, jwt, requests_mock): mocked_entity_response = {"business": {"adminFreeze": False, "state": "ACTIVE"}} identifier = json_data['businessIdentifier'] - requests_mock.get(f"{app.config.get('AUTH_SVC_URL')}/entities/{identifier}/authorizations", + requests_mock.get(f"{app.config.get('AUTH_API_URL')}/entities/{identifier}/authorizations", json={"orgMembership": "COORDINATOR", 'roles': ['edit', 'view']}) legal_api_mock = requests_mock.get( f"{app.config.get('LEGAL_SVC_URL')}/businesses/{identifier}", @@ -389,7 +389,7 @@ def test_post_plots_invalid_entity(app, client, session, jwt, requests_mock, tes mocked_entity_response = {"business": {"adminFreeze": admin_freeze, "state": state}} identifier = json_data['businessIdentifier'] - requests_mock.get(f"{app.config.get('AUTH_SVC_URL')}/entities/{identifier}/authorizations", + requests_mock.get(f"{app.config.get('AUTH_API_URL')}/entities/{identifier}/authorizations", json={"orgMembership": "COORDINATOR", 'roles': ['edit', 'view']}) legal_api_mock = requests_mock.get( f"{app.config.get('LEGAL_SVC_URL')}/businesses/{identifier}", @@ -438,7 +438,7 @@ def test_get_latest_for_entity(app, client, session, jwt, requests_mock): (SubmissionService.create_submission(s2_dict, user.id)).save() (SubmissionService.create_submission(s3_dict, user.id)).save() - requests_mock.get(f"{app.config.get('AUTH_SVC_URL')}/entities/{test_identifier}/authorizations", + requests_mock.get(f"{app.config.get('AUTH_API_URL')}/entities/{test_identifier}/authorizations", json={"orgMembership": "COORDINATOR", 'roles': ['edit', 'view']}) # Test rv = client.get(f'/plots/entity/{test_identifier}',