Skip to content

Commit 9651057

Browse files
Merge branch 'Mayank-goel360:main' into main
2 parents 1cabe3d + b6306d1 commit 9651057

File tree

3 files changed

+134
-7
lines changed

3 files changed

+134
-7
lines changed

β€Ž.github/workflows/checkvalid.ymlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: Valid
22

3+
34
on:
45
pull_request:
56
types: [opened, synchronize]

β€Ž.github/workflows/token.ymlβ€Ž

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# .github/workflows/test-oidc-get.yml
21
name: Test OIDC GET Request
32

43
on:
@@ -7,15 +6,14 @@ on:
76
- main
87

98
permissions:
10-
id-token: write # enable OIDC token issuance
11-
contents: read # allows checkout (not strictly needed here)
9+
id-token: write
10+
contents: read
1211

1312
jobs:
1413
oidc-get:
1514
runs-on: ubuntu-latest
1615
env:
1716
CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
18-
API_URL: https://sentinel-content-validationapi-prod-bvgsc3hjhyeqangg.canadacentral-01.azurewebsites.net/ # πŸ” replace with your GET endpoint
1917

2018
steps:
2119
- name: πŸ” Request OIDC token from GitHub
@@ -30,9 +28,55 @@ jobs:
3028
echo "βœ”οΈ Token length: ${#token}"
3129
echo "TOKEN=$token" >> $GITHUB_ENV
3230
33-
- name: πŸ“‘ Send GET request with Bearer token
31+
- name: πŸ“‘ Send GET request to prod
3432
run: |
35-
echo "πŸš€ Sending GET to $API_URL"
36-
response=$(curl -s -H "Authorization: Bearer $TOKEN" "$API_URL")
33+
echo "πŸš€ Sending GET to https://sentinel-content-validationapi-prod-bvgsc3hjhyeqangg.canadacentral-01.azurewebsites.net/"
34+
35+
# Check if TOKEN is set
36+
if [ -z "$TOKEN" ]; then
37+
echo "❌ TOKEN is not set. Make sure the OIDC token was fetched correctly."
38+
exit 1
39+
fi
40+
41+
# Send the GET request and capture both response and HTTP status
42+
response=$(curl -s -w "\n%{http_code}" -H "Authorization: Bearer $TOKEN" "https://sentinel-content-validationapi-prod-bvgsc3hjhyeqangg.canadacentral-01.azurewebsites.net/")
43+
44+
# Split response and status
45+
http_body=$(echo "$response" | sed '$d')
46+
http_status=$(echo "$response" | tail -n1)
47+
48+
echo "πŸ” HTTP Status: $http_status"
49+
echo "πŸ” Raw Response:"
50+
echo "$http_body"
51+
52+
# Check if the response is valid JSON
53+
if echo "$http_body" | jq . > /dev/null 2>&1; then
54+
echo "βœ”οΈ Parsed JSON:"
55+
echo "$http_body" | jq .
56+
else
57+
echo "⚠️ Response is not valid JSON or is empty."
58+
exit 1
59+
fi
60+
61+
# Fail the step if the HTTP status is not 2xx
62+
if [[ "$http_status" != 2* ]]; then
63+
echo "❌ Request failed with status $http_status"
64+
exit 1
65+
fi
66+
67+
- name: πŸ“‘ Send GET request too prod
68+
run: |
69+
echo "πŸš€ Sending GET to prod"
70+
response=$(curl -s -H "Authorization: Bearer $TOKEN" "https://sentinel-content-validationapi-prod-bvgsc3hjhyeqangg.canadacentral-01.azurewebsites.net/")
71+
echo "πŸ” Response JSON:"
72+
echo "$response" | jq .
73+
74+
75+
76+
- name: πŸ“‘ Send GET request too dev
77+
run: |
78+
echo "πŸš€ Sending GET to dev"
79+
response=$(curl -s -H "Authorization: Bearer $TOKEN" "https://sentintel-content-dev-fue4ashcg9fnfge9.canadacentral-01.azurewebsites.net/")
3780
echo "πŸ” Response JSON:"
3881
echo "$response" | jq .
82+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Test OIDC GET Request for dev
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
id-token: write
10+
contents: read
11+
12+
jobs:
13+
oidc-get:
14+
runs-on: ubuntu-latest
15+
env:
16+
CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
17+
18+
steps:
19+
- name: πŸ” Request OIDC token from GitHub
20+
id: fetch_token
21+
run: |
22+
echo "🌐 Requesting OIDC token..."
23+
raw=$(curl -s \
24+
-H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
25+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=api://${CLIENT_ID}")
26+
echo "πŸ” Raw token response JSON: $raw"
27+
token=$(echo "$raw" | jq -r '.value')
28+
echo "βœ”οΈ Token length: ${#token}"
29+
echo "TOKEN=$token" >> $GITHUB_ENV
30+
31+
- name: πŸ“‘ Send GET request to prod
32+
run: |
33+
echo "πŸš€ Sending GET to https://sentinel-content-validationapi-prod-bvgsc3hjhyeqangg.canadacentral-01.azurewebsites.net/"
34+
35+
# Check if TOKEN is set
36+
if [ -z "$TOKEN" ]; then
37+
echo "❌ TOKEN is not set. Make sure the OIDC token was fetched correctly."
38+
exit 1
39+
fi
40+
41+
# Send the GET request and capture both response and HTTP status
42+
response=$(curl -s -w "\n%{http_code}" -H "Authorization: Bearer $TOKEN" "https://sentintel-content-dev-fue4ashcg9fnfge9.canadacentral-01.azurewebsites.net/")
43+
44+
# Split response and status
45+
http_body=$(echo "$response" | sed '$d')
46+
http_status=$(echo "$response" | tail -n1)
47+
48+
echo "πŸ” HTTP Status: $http_status"
49+
echo "πŸ” Raw Response:"
50+
echo "$http_body"
51+
52+
# Check if the response is valid JSON
53+
if echo "$http_body" | jq . > /dev/null 2>&1; then
54+
echo "βœ”οΈ Parsed JSON:"
55+
echo "$http_body" | jq .
56+
else
57+
echo "⚠️ Response is not valid JSON or is empty."
58+
exit 1
59+
fi
60+
61+
# Fail the step if the HTTP status is not 2xx
62+
if [[ "$http_status" != 2* ]]; then
63+
echo "❌ Request failed with status $http_status"
64+
exit 1
65+
fi
66+
67+
68+
- name: πŸ“‘ Send GET request too dev
69+
run: |
70+
echo "πŸš€ Sending GET to dev"
71+
response=$(curl -s -H "Authorization: Bearer $TOKEN" "https://sentintel-content-dev-fue4ashcg9fnfge9.canadacentral-01.azurewebsites.net/")
72+
echo "πŸ” Response JSON:"
73+
echo "$response" | jq .
74+
75+
- name: πŸ“‘ Send GET request too prod
76+
run: |
77+
echo "πŸš€ Sending GET to prod"
78+
response=$(curl -s -H "Authorization: Bearer $TOKEN" "https://sentinel-content-validationapi-prod-bvgsc3hjhyeqangg.canadacentral-01.azurewebsites.net/")
79+
echo "πŸ” Response JSON:"
80+
echo "$response" | jq .
81+
82+

0 commit comments

Comments
Β (0)