Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0-fr1] Fernet rotation kuttl tests #517

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/kuttl/common/scripts/create_test_token.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -euxo pipefail

oc wait --for=condition=ready pod openstackclient --timeout=30s -n $NAMESPACE

alias openstack="oc exec -tn $NAMESPACE openstackclient -- openstack"

export OS_TOKEN=$(openstack token issue -f value -c id)

echo $OS_TOKEN > /tmp/temporary_test_token
26 changes: 26 additions & 0 deletions tests/kuttl/common/scripts/validate_test_token.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
set -euxo pipefail

seconds=1
while [ $seconds -le 30 ]; do
rotatedat=$(oc get secret keystone -n $NAMESPACE -o jsonpath="{.metadata.annotations['keystone\.openstack\.org/rotatedat']}")
if [ $rotatedat != "2009-11-10T23:00:00Z" ]; then
break
fi
sleep 1
seconds=$(( $seconds + 1 ))
done

sleep 20 # make sure a rollout started

oc rollout status deployment/keystone -n $NAMESPACE

export OS_TOKEN=$(cat /tmp/temporary_test_token)

alias openstack="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"

if openstack endpoint list 2>&1 | grep "Failed to validate token"; then
exit 1
else
exit 0
fi
1 change: 1 addition & 0 deletions tests/kuttl/tests/fernet_rotation/00-assert.yaml
1 change: 1 addition & 0 deletions tests/kuttl/tests/fernet_rotation/00-deploy_keystone.yaml
5 changes: 5 additions & 0 deletions tests/kuttl/tests/fernet_rotation/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# create a test token, save it in /tmp/
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
commands:
- script: ../../common/scripts/create_test_token.sh
55 changes: 55 additions & 0 deletions tests/kuttl/tests/fernet_rotation/01-deploy_openstackclient.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: v1
kind: Pod
metadata:
annotations:
openshift.io/scc: anyuid
labels:
app: openstackclient
name: openstackclient
spec:
containers:
- args:
- --single-child
- --
- /bin/bash
- -c
- /bin/sleep infinity
command:
- /bin/dumb-init
env:
- name: OS_CLOUD
value: default
image: quay.io/podified-antelope-centos9/openstack-openstackclient:current-podified
imagePullPolicy: IfNotPresent
name: openstackclient
resources: {}
securityContext:
capabilities:
drop:
- ALL
runAsGroup: 42401
runAsNonRoot: true
runAsUser: 42401
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/openstack/clouds.yaml
name: openstack-config
subPath: clouds.yaml
- mountPath: /etc/openstack/secure.yaml
name: openstack-config-secret
subPath: secure.yaml
dnsPolicy: ClusterFirst
enableServiceLinks: true
volumes:
- configMap:
defaultMode: 420
name: openstack-config
name: openstack-config
- name: openstack-config-secret
secret:
defaultMode: 420
secretName: openstack-config-secret
6 changes: 6 additions & 0 deletions tests/kuttl/tests/fernet_rotation/02-assert.yaml
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/validate_test_token.sh
6 changes: 6 additions & 0 deletions tests/kuttl/tests/fernet_rotation/02-rotate_keys.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Secret
metadata:
name: keystone
annotations:
keystone.openstack.org/rotatedat: "2009-11-10T23:00:00Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
delete:
- apiVersion: v1
kind: Pod
name: openstackclient
1 change: 1 addition & 0 deletions tests/kuttl/tests/fernet_rotation/04-cleanup-keystone.yaml
1 change: 1 addition & 0 deletions tests/kuttl/tests/fernet_rotation/04-errors.yaml
Loading