Skip to content

Commit

Permalink
testing flag
Browse files Browse the repository at this point in the history
  • Loading branch information
daisieh committed Oct 2, 2024
1 parent 2ed9927 commit b10161c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions candig_federation/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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}")
Expand Down

0 comments on commit b10161c

Please sign in to comment.