From b10161cdd56ce6f0ba348338c141142248b90636 Mon Sep 17 00:00:00 2001 From: Daisie Huang Date: Wed, 2 Oct 2024 12:41:04 -0700 Subject: [PATCH] testing flag --- candig_federation/network.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/candig_federation/network.py b/candig_federation/network.py index aa569bd..9e8d650 100644 --- a/candig_federation/network.py +++ b/candig_federation/network.py @@ -13,13 +13,15 @@ TYK_FEDERATION_API_ID = os.getenv("TYK_FEDERATION_API_ID") - +APPROLE_TOKEN = None +if os.getenv("TESTING", False): + APPROLE_TOKEN = "test" def get_registered_servers(): - stored_servers_dict, status_code = authx.auth.get_service_store_secret("federation", key="servers") + stored_servers_dict, status_code = authx.auth.get_service_store_secret("federation", key="servers", token=APPROLE_TOKEN) if status_code == 404: # no value was found, so this must need to be initialized - stored_servers_dict, status_code = authx.auth.set_service_store_secret("federation", key="servers", value=json.dumps({"servers": {}})) + stored_servers_dict, status_code = authx.auth.set_service_store_secret("federation", key="servers", value=json.dumps({"servers": {}}), token=APPROLE_TOKEN) return {} if status_code != 200: logger.error(f"Error in get_registered_servers: {stored_servers_dict}") @@ -73,10 +75,10 @@ def unregister_server(server_id): def get_registered_services(): - stored_services_dict, status_code = authx.auth.get_service_store_secret("federation", key="services") + stored_services_dict, status_code = authx.auth.get_service_store_secret("federation", key="services", token=APPROLE_TOKEN) if status_code == 404: # no value was found, so this must need to be initialized - stored_services_dict, status_code = authx.auth.set_service_store_secret("federation", key="services", value=json.dumps({"services": {}})) + stored_services_dict, status_code = authx.auth.set_service_store_secret("federation", key="services", value=json.dumps({"services": {}}), token=APPROLE_TOKEN) return {} if status_code != 200: logger.error(f"Error in get_registered_services: {stored_services_dict}")