@camunda/e2e-test-suite 0.0.1304 → 0.0.1305
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -15,6 +15,15 @@
|
|
|
15
15
|
# 409 ALREADY_EXISTS -> the caller is an admin and the membership is effective
|
|
16
16
|
# 2xx -> the caller is an admin and the membership was just added
|
|
17
17
|
# 403 FORBIDDEN -> the membership is not effective (yet)
|
|
18
|
+
#
|
|
19
|
+
# Nothing in the Helm values makes CLIENT_ID an admin: only the upgrade flow
|
|
20
|
+
# grants it, through the migration-only "Assign Test Client Admin Role" smoke
|
|
21
|
+
# test. On a fresh install the 403 is therefore permanent unless the membership
|
|
22
|
+
# is created. When ADMIN_CLIENT_ID/ADMIN_CLIENT_SECRET name a client that is an
|
|
23
|
+
# admin from the first boot (the qa layers seed "venom" through
|
|
24
|
+
# orchestration.security.initialization.defaultRoles.admin.clients), the first
|
|
25
|
+
# 403 makes that client assign CLIENT_ID to ROLE_ID, and the loop keeps polling
|
|
26
|
+
# with CLIENT_ID until the new membership is effective.
|
|
18
27
|
|
|
19
28
|
set -euo pipefail
|
|
20
29
|
|
|
@@ -27,21 +36,52 @@ ROLE_ID="${ROLE_ID:-admin}"
|
|
|
27
36
|
MAX_ATTEMPTS="${MAX_ATTEMPTS:-10}"
|
|
28
37
|
REQUEST_TIMEOUT="${REQUEST_TIMEOUT:-30}"
|
|
29
38
|
MAX_BACKOFF="${MAX_BACKOFF:-30}"
|
|
39
|
+
ADMIN_CLIENT_ID="${ADMIN_CLIENT_ID:-}"
|
|
40
|
+
ADMIN_CLIENT_SECRET="${ADMIN_CLIENT_SECRET:-}"
|
|
30
41
|
|
|
31
42
|
body_file="$(mktemp)"
|
|
32
43
|
trap 'rm -f "$body_file"' EXIT
|
|
33
44
|
|
|
34
45
|
fetch_token() {
|
|
46
|
+
local id="${1:-$CLIENT_ID}" secret="${2:-$CLIENT_SECRET}"
|
|
35
47
|
curl -sS --max-time "$REQUEST_TIMEOUT" -X POST "$TOKEN_URL" \
|
|
36
48
|
-H 'Content-Type: application/x-www-form-urlencoded' \
|
|
37
49
|
--data-urlencode 'grant_type=client_credentials' \
|
|
38
|
-
--data-urlencode "client_id=${
|
|
39
|
-
--data-urlencode "client_secret=${
|
|
50
|
+
--data-urlencode "client_id=${id}" \
|
|
51
|
+
--data-urlencode "client_secret=${secret}" |
|
|
40
52
|
jq -r '.access_token // empty'
|
|
41
53
|
}
|
|
42
54
|
|
|
55
|
+
# Returns 0 once ADMIN_CLIENT_ID has created (2xx) or found (409) the membership.
|
|
56
|
+
bootstrap_membership() {
|
|
57
|
+
local admin_token admin_status
|
|
58
|
+
admin_token="$(fetch_token "$ADMIN_CLIENT_ID" "$ADMIN_CLIENT_SECRET" || true)"
|
|
59
|
+
if [ -z "$admin_token" ]; then
|
|
60
|
+
echo "No access token returned by ${TOKEN_URL} for admin client '${ADMIN_CLIENT_ID}'."
|
|
61
|
+
return 1
|
|
62
|
+
fi
|
|
63
|
+
admin_status="$(
|
|
64
|
+
curl -sS --max-time "$REQUEST_TIMEOUT" -o "$body_file" -w '%{http_code}' \
|
|
65
|
+
-X PUT "${BASE_URL}/v2/roles/${ROLE_ID}/clients/${CLIENT_ID}" \
|
|
66
|
+
-H "Authorization: Bearer ${admin_token}" || echo 000
|
|
67
|
+
)"
|
|
68
|
+
case "$admin_status" in
|
|
69
|
+
2* | 409)
|
|
70
|
+
echo "Admin client '${ADMIN_CLIENT_ID}' assigned client '${CLIENT_ID}' to role '${ROLE_ID}' (HTTP ${admin_status})."
|
|
71
|
+
return 0
|
|
72
|
+
;;
|
|
73
|
+
*)
|
|
74
|
+
echo "Admin client '${ADMIN_CLIENT_ID}' could not assign client '${CLIENT_ID}' to role '${ROLE_ID}' (HTTP ${admin_status})."
|
|
75
|
+
cat "$body_file"
|
|
76
|
+
echo
|
|
77
|
+
return 1
|
|
78
|
+
;;
|
|
79
|
+
esac
|
|
80
|
+
}
|
|
81
|
+
|
|
43
82
|
attempt=1
|
|
44
83
|
backoff=5
|
|
84
|
+
bootstrapped=false
|
|
45
85
|
|
|
46
86
|
while [ "$attempt" -le "$MAX_ATTEMPTS" ]; do
|
|
47
87
|
# Re-mint the token on every attempt: memberships are attached to the session
|
|
@@ -72,6 +112,11 @@ while [ "$attempt" -le "$MAX_ATTEMPTS" ]; do
|
|
|
72
112
|
echo "Attempt ${attempt}/${MAX_ATTEMPTS}: role '${ROLE_ID}' is not effective yet for client '${CLIENT_ID}' (HTTP 403)."
|
|
73
113
|
cat "$body_file"
|
|
74
114
|
echo
|
|
115
|
+
if [ "$bootstrapped" = false ] && [ -n "$ADMIN_CLIENT_ID" ] && [ -n "$ADMIN_CLIENT_SECRET" ]; then
|
|
116
|
+
if bootstrap_membership; then
|
|
117
|
+
bootstrapped=true
|
|
118
|
+
fi
|
|
119
|
+
fi
|
|
75
120
|
;;
|
|
76
121
|
*)
|
|
77
122
|
echo "Attempt ${attempt}/${MAX_ATTEMPTS}: unexpected response while assigning role '${ROLE_ID}' (HTTP ${status})."
|