Skip to content

Commit d6381eb

Browse files
committed
Update firm affiliation logic to work in sandbox
1 parent ff81711 commit d6381eb

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

auth-api/devops/vaults.gcp.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ NOTIFY_API_VERSION="op://API/$APP_ENV/notify-api/NOTIFY_API_VERSION"
3030
PAY_API_URL="op://API/$APP_ENV/pay-api/PAY_API_URL"
3131
PAY_API_VERSION="op://API/$APP_ENV/pay-api/PAY_API_VERSION"
3232
LEGAL_API_URL="op://API/$APP_ENV/legal-api/LEGAL_API_URL"
33+
LEGAL_SANDBOX_API_URL="op://API/sandbox/legal-api/LEGAL_API_URL"
3334
LEGAL_API_VERSION="op://API/$APP_ENV/legal-api/LEGAL_API_VERSION"
3435
LEGAL_API_VERSION_2="op://API/$APP_ENV/legal-api/LEGAL_API_VERSION_2"
3536
GCP_AUTH_KEY="op://gcp-queue/$APP_ENV/gtksf3/AUTHPAY_GCP_AUTH_KEY"

auth-api/docs/dotenv_template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ PAYBC_CLIENT_SECRET=test
5757
PAYBC_PORTAL_URL=http://localhost:8080
5858
NOTIFY_API_URL="https://mock-lear-tools.pathfinder.gov.bc.ca/rest/SBC+Notify+API+Reference/2.0.0/api/v1"
5959
LEGAL_API_URL="https://legal-api-dev.pathfinder.gov.bc.ca/api/v1"
60+
LEGAL_SANDBOX_API_URL="https://legal-api-dev.pathfinder.gov.bc.ca/api/v1"
6061

6162

6263

auth-api/env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ NOTIFY_API_VERSION="/api/v1"
4343
PAY_API_URL="https://pay-api-dev.apps.silver.devops.gov.bc.ca"
4444
PAY_API_VERSION="/api/v1"
4545
LEGAL_API_URL="https://legal-api-dev.apps.silver.devops.gov.bc.ca"
46+
LEGAL_SANDBOX_API_URL="https://legal-api-dev.apps.silver.devops.gov.bc.ca"
4647
LEGAL_API_VERSION="/api/v1"
4748
LEGAL_API_VERSION_2"/api/v2"
4849

auth-api/src/auth_api/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class _Config: # pylint: disable=too-few-public-methods
131131
PAY_API_URL = os.getenv("PAY_API_URL", "") + os.getenv("PAY_API_VERSION", "")
132132

133133
LEGAL_API_URL = os.getenv("LEGAL_API_URL", "")
134+
LEGAL_SANDBOX_API_URL = os.getenv("LEGAL_SANDBOX_API_URL", "")
134135
LEGAL_API_VERSION = os.getenv("LEGAL_API_VERSION")
135136
LEGAL_API_VERSION_2 = os.getenv("LEGAL_API_VERSION_2", "")
136137

@@ -300,6 +301,7 @@ class TestConfig(_Config): # pylint: disable=too-few-public-methods
300301
ENTITY_SVC_CLIENT_SECRET = os.getenv("KEYCLOAK_TEST_ADMIN_SECRET")
301302

302303
LEGAL_API_URL = "https://mock-auth-tools.pathfinder.gov.bc.ca/rest/legal-api/2.7"
304+
LEGAL_SANDBOX_API_URL = "https://mock-auth-tools.pathfinder.gov.bc.ca/rest/legal-api/2.7"
303305
LEGAL_API_VERSION_2 = "/api/v1"
304306

305307
NOTIFY_API_URL = "http://localhost:8080/notify-api/api/v1"

auth-api/src/auth_api/services/affiliation.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from auth_api.utils.passcode import validate_passcode
4141
from auth_api.utils.roles import ALL_ALLOWED_ROLES, CLIENT_AUTH_ROLES, STAFF, Role
4242
from auth_api.utils.user_context import UserContext, user_context
43+
from auth_api.utils.util import get_request_environment
4344

4445
from .activity_log_publisher import ActivityLogPublisher
4546
from .rest_service import RestService
@@ -560,7 +561,14 @@ def _get_nr_details(nr_number: str):
560561

561562
@staticmethod
562563
def _validate_firms_party(token, business_identifier, party_name_str: str):
563-
legal_api_url = current_app.config.get("LEGAL_API_URL") + current_app.config.get("LEGAL_API_VERSION_2")
564+
env = get_request_environment()
565+
if env == "sandbox":
566+
legal_api_url = current_app.config.get("LEGAL_SANDBOX_API_URL") + current_app.config.get(
567+
"LEGAL_API_VERSION_2"
568+
)
569+
else:
570+
legal_api_url = current_app.config.get("LEGAL_API_URL") + current_app.config.get("LEGAL_API_VERSION_2")
571+
564572
parties_url = f"{legal_api_url}/businesses/{business_identifier}/parties"
565573
try:
566574
lear_response = RestService.get(parties_url, token=token, skip_404_logging=True)

0 commit comments

Comments
 (0)