Skip to content

Commit dc9d75e

Browse files
committed
Rename file and delte test file
1 parent e603bd3 commit dc9d75e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

test_health_check.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import requests
2+
import os
3+
import boto3
4+
import json
5+
#
6+
# Retrieve environment variables
7+
8+
9+
10+
cog_user = os.getenv('COG_USER')
11+
cog_pass = os.getenv('COG_PASS')
12+
cog_client_id = os.getenv('COG_CLIENT_ID')
13+
14+
# Create a Cognito client
15+
client = boto3.client('cognito-idp')
16+
response = client.initiate_auth(
17+
AuthFlow='USER_PASSWORD_AUTH',
18+
AuthParameters={
19+
'USERNAME': cog_user,
20+
'PASSWORD': cog_pass,
21+
},
22+
ClientId=cog_client_id
23+
)
24+
token = response['AuthenticationResult']['AccessToken']
25+
# print("Access Token:", token) # Debug print to check the token format
26+
27+
headers = {'Authorization': f'Bearer {token}'}
28+
# print("Headers being sent:", headers) # Debug print to check the headers
29+
30+
url = 'https://d3vc8w9zcq658.cloudfront.net/am-uds-dapa/collections'
31+
response = requests.get(url, headers=headers)
32+
33+
# Check if the request was successful
34+
if response.status_code == 200:
35+
print("Success:", json.dumps(response.json(), indent=4))
36+
else:
37+
print("Failed to fetch data:", response.status_code, response.text)
38+
39+
40+
41+
def main():
42+
43+
44+
45+
46+
if __main__ == "__main__":
47+
main()

0 commit comments

Comments
 (0)