-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #503 from afaranha/kuttl
Add test to rotate keys until an old one invalidades
- Loading branch information
Showing
9 changed files
with
71 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
TMP_SECRET_FILE="/tmp/keystone-secret.yaml" | ||
|
||
generate_secret_yaml() { | ||
cat <<EOF > $TMP_SECRET_FILE | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: keystone | ||
namespace: keystone-kuttl-tests | ||
annotations: | ||
keystone.openstack.org/rotatedat: "2009-11-10T23:00:00Z" | ||
EOF | ||
} | ||
|
||
for rotation in {1..5}; do | ||
echo "Starting rotation $rotation..." | ||
|
||
# Apply new secret to trigger rotation | ||
generate_secret_yaml | ||
if ! oc apply -f $TMP_SECRET_FILE; then | ||
echo "Failed to apply the secret!" | ||
rm -f $TMP_SECRET_FILE | ||
exit 1 | ||
fi | ||
|
||
sleep 100 | ||
|
||
# Wait for rollout to complete | ||
if ! oc rollout status deployment/keystone -n $NAMESPACE --timeout=60s; then | ||
echo "Rollout status check failed for rotation $rotation." | ||
continue | ||
fi | ||
|
||
echo "Rotation $rotation completed successfully." | ||
done | ||
|
||
rm -f $TMP_SECRET_FILE | ||
echo "All rotations completed successfully." | ||
exit 0 |
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,14 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
export OS_TOKEN=$(cat /tmp/temporary_test_token) | ||
|
||
output=$(oc exec -tn $NAMESPACE openstackclient -- env -u OS_CLOUD - OS_AUTH_URL=http://keystone-public.keystone-kuttl-tests.svc:5000 OS_AUTH_TYPE=token OS_TOKEN=$OS_TOKEN openstack endpoint list 2>&1) | ||
|
||
filtered_output=$(echo "$output" | grep -i "Could not recognize Fernet token") | ||
|
||
if echo "$filtered_output" | grep -q "Could not recognize Fernet token"; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi |
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,6 @@ | ||
# validate that token saved in previous step works | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
namespaced: true | ||
commands: | ||
- script: ../../common/scripts/test_invalid_token.sh |
4 changes: 4 additions & 0 deletions
4
tests/kuttl/tests/fernet_rotation/03-rotate_keys_until_invalidate.yaml
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,4 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: ../../common/scripts/rotate_token.sh |
File renamed without changes.
File renamed without changes.
File renamed without changes.