Skip to content

Commit 0514bf6

Browse files
committed
Examine entitlements in CI
1 parent 5d132c1 commit 0514bf6

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

.github/check_entitlements.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
4+
# Derive additional environment variables
5+
TOKEN_URL="${OIDC_OP_TOKEN_ENDPOINT}"
6+
OTDF_HOST_AND_PORT="${OPENTDF_PLATFORM_HOST}"
7+
OTDF_CLIENT="${OPENTDF_CLIENT_ID}"
8+
OTDF_CLIENT_SECRET="${OPENTDF_CLIENT_SECRET}"
9+
10+
# Enable debug mode
11+
DEBUG=1
12+
13+
echo "🔧 Environment Configuration:"
14+
echo " TOKEN_URL: ${TOKEN_URL}"
15+
echo " OTDF_HOST_AND_PORT: ${OTDF_HOST_AND_PORT}"
16+
echo " OTDF_CLIENT: ${OTDF_CLIENT}"
17+
echo " OTDF_CLIENT_SECRET: ${OTDF_CLIENT_SECRET}"
18+
echo ""
19+
20+
get_token() {
21+
curl -k --location "$TOKEN_URL" \
22+
--header "X-VirtruPubKey;" \
23+
--header "Content-Type: application/x-www-form-urlencoded" \
24+
--data-urlencode "grant_type=client_credentials" \
25+
--data-urlencode "client_id=$OTDF_CLIENT" \
26+
--data-urlencode "client_secret=$OTDF_CLIENT_SECRET"
27+
}
28+
29+
echo "🔐 Getting access token..."
30+
BEARER=$( get_token | jq -r '.access_token' )
31+
[[ "${DEBUG:-}" == "1" ]] && echo "Got Access Token: ${BEARER}"
32+
echo ""
33+
34+
# Array of usernames to check
35+
USERNAMES=("opentdf" "sample-user" "sample-user-1" "cli-client" "opentdf-sdk")
36+
37+
for USERNAME in "${USERNAMES[@]}"; do
38+
echo "👤 Fetching entitlements for username: ${USERNAME}"
39+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
40+
41+
grpcurl -insecure \
42+
-H "authorization: Bearer $BEARER" \
43+
-d "{
44+
\"entities\": [
45+
{
46+
\"userName\": \"$USERNAME\"
47+
}
48+
]
49+
}" \
50+
"$OTDF_HOST_AND_PORT" \
51+
authorization.AuthorizationService/GetEntitlements
52+
53+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
54+
echo "✅ Entitlements retrieval complete for ${USERNAME}!"
55+
echo ""
56+
done
57+
58+
echo "🎉 All entitlement checks completed!"

.github/workflows/platform-integration-test-new.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs:
125125

126126
- name: Run all tests, minus integration tests
127127
env:
128-
OPENTDF_CLIENT_ID: "opentdf-sdk"
128+
OPENTDF_CLIENT_ID: "opentdf"
129129
OPENTDF_CLIENT_SECRET: "secret"
130130
OPENTDF_HOSTNAME: "localhost:8080"
131131
OIDC_TOKEN_ENDPOINT: "http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token"
@@ -141,7 +141,7 @@ jobs:
141141

142142
- name: Run integration tests
143143
env:
144-
OPENTDF_CLIENT_ID: "opentdf-sdk"
144+
OPENTDF_CLIENT_ID: "opentdf"
145145
OPENTDF_CLIENT_SECRET: "secret"
146146
OPENTDF_PLATFORM_HOST: "localhost:8080"
147147
OPENTDF_PLATFORM_URL: "http://localhost:8080"
@@ -151,6 +151,9 @@ jobs:
151151
TEST_OPENTDF_ATTRIBUTE_1: "https://example.com/attr/attr1/value/value1"
152152
TEST_OPENTDF_ATTRIBUTE_2: "https://example.com/attr/attr1/value/value2"
153153
run: |
154+
# Run check_entitlements.sh
155+
./.github/check_entitlements.sh
156+
154157
uv sync
155158
# Skip the tests marked "integration"
156159
uv run pytest -m "integration" --tb=short -vv tests

0 commit comments

Comments
 (0)