-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update unleash image repository (#782)
* Update unleash image repository * Disable SSL for local-ff provider DB * Add AdminAccessToken * Add clientAccessToken and update schema * Bump rhc-osdk-utils version * Randomize FeatureFlags Admin and Client tokens * Add feature flags test
- Loading branch information
1 parent
a3f06f1
commit 77045f5
Showing
6 changed files
with
146 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
FEATURE_FLAGS_POD=$(kubectl -n test-ff-local get pod -l env-app=test-ff-local-featureflags --output=jsonpath={.items..metadata.name}) | ||
ADMIN_TOKEN=$(kubectl -n test-ff-local get secret test-ff-local-featureflags -o json | jq -r '.data.adminAccessToken | @base64d') | ||
CLIENT_TOKEN=$(kubectl -n test-ff-local get secret test-ff-local-featureflags -o json | jq -r '.data.clientAccessToken | @base64d') | ||
FEATURE_TOGGLE_NAME='my-feature-toggle-1' | ||
|
||
get_request() { | ||
|
||
local TOKEN="$1" | ||
local ENDPOINT="$2" | ||
|
||
kubectl exec -n test-ff-local "$FEATURE_FLAGS_POD" -- wget -q -O- \ | ||
--header "Authorization: $TOKEN" "localhost:4242${ENDPOINT}" | ||
} | ||
|
||
post_request() { | ||
|
||
local TOKEN="$1" | ||
local ENDPOINT="$2" | ||
local DATA="$3" | ||
|
||
kubectl exec -n test-ff-local "$FEATURE_FLAGS_POD" -- wget -q -O- \ | ||
--post-data "$DATA" \ | ||
--header "Content-Type: application/json" \ | ||
--header "Authorization: $TOKEN" \ | ||
"localhost:4242${ENDPOINT}" | ||
} | ||
|
||
if get_request "$CLIENT_TOKEN" "/api/client/features/$FEATURE_TOGGLE_NAME"; then | ||
echo "Feature toggle '$FEATURE_TOGGLE_NAME' should not exist" | ||
exit 1 | ||
fi | ||
|
||
|
||
if ! post_request "$ADMIN_TOKEN" \ | ||
"/api/admin/projects/default/features" \ | ||
"{ \"name\": \"$FEATURE_TOGGLE_NAME\" }"; then | ||
echo "Error creating feature flag!" | ||
exit 1 | ||
fi | ||
|
||
if ! get_request "$CLIENT_TOKEN" "/api/client/features/$FEATURE_TOGGLE_NAME"; then | ||
echo "Feature toggle '$FEATURE_TOGGLE_NAME' should exist" | ||
fi | ||
|
||
if [ 'true' != "$(get_request "$CLIENT_TOKEN" "/api/client/features/$FEATURE_TOGGLE_NAME" | jq '.enabled==false')" ]; then | ||
echo "Feature toggle '$FEATURE_TOGGLE_NAME' should be disabled" | ||
exit 1 | ||
fi | ||
|
||
if ! post_request "$ADMIN_TOKEN" \ | ||
"/api/admin/projects/default/features/$FEATURE_TOGGLE_NAME/environments/development/on" ; then | ||
echo "Error enabling feature toggle '$FEATURE_TOGGLE_NAME'" | ||
exit 1 | ||
fi | ||
|
||
if [ 'true' != "$(get_request "$CLIENT_TOKEN" "/api/client/features/$FEATURE_TOGGLE_NAME" | jq '.enabled==true')" ]; then | ||
echo "Feature toggle '$FEATURE_TOGGLE_NAME' should be enabled" | ||
exit 1 | ||
fi |