@@ -31,18 +31,23 @@ def generate_authentication(self, env, base_url):
3131 # For the test_url, note that we don't need a message_id that actually exists in
3232 # the backend. The test will only check that the API doesn't return a 401,
3333 # a 404 response means the authentication is working.
34- test_url = f"{ base_url } /v1/messages/message_id "
34+ test_url = f"{ base_url } /letters "
3535
36- if env in [ "internal-dev" , "ref" ] :
36+ if env == "internal-dev" :
3737 api_key = os .environ ["NON_PROD_API_KEY" ]
3838 private_key = os .environ ["NON_PROD_PRIVATE_KEY" ]
3939 url = "https://internal-dev.api.service.nhs.uk/oauth2/token"
40- kid = "local"
40+ kid = "internal-dev-test-1"
41+ elif env == "ref" :
42+ api_key = os .environ ["NON_PROD_API_KEY" ]
43+ private_key = os .environ ["NON_PROD_PRIVATE_KEY" ]
44+ url = "https://ref.api.service.nhs.uk/oauth2/token"
45+ kid = "internal-dev-test-1"
4146 elif env == "int" :
4247 api_key = os .environ .get ("INTEGRATION_API_KEY" )
4348 private_key = os .environ .get ("INTEGRATION_PRIVATE_KEY" )
4449 url = "https://int.api.service.nhs.uk/oauth2/token"
45- kid = "local "
50+ kid = "internal-dev-test-1 "
4651 elif env == "prod" :
4752 api_key = os .environ .get ("PRODUCTION_API_KEY" )
4853 private_key = os .environ .get ("PRODUCTION_PRIVATE_KEY" )
@@ -65,7 +70,7 @@ def generate_and_test_new_token(self, api_key, private_key, url, kid, test_url):
6570 valid_auth = False
6671
6772 for i in range (self .max_tests ):
68- print (f"Testing new token, attemp #{ i + 1 } " )
73+ print (f"Testing new token, attempt #{ i + 1 } " )
6974 if new_token is None :
7075 new_token = self .generate_new_token (api_key , private_key , url , kid )
7176 time_since_new_token = int (time ())
@@ -93,6 +98,8 @@ def generate_new_token(self, api_key, private_key, url, kid):
9398 with open (private_key , "r" ) as f :
9499 pk_pem = f .read ()
95100
101+ private_key_file = f"{ private_key } "
102+
96103 token_expiry = int (time ()) + self .token_validity
97104
98105 claims = {
0 commit comments