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

Add token renewal test #4330

Merged
merged 2 commits into from
Jul 18, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ log-info "verifying cert auth..."

# Verify Token Auth
log-info "verifying token auth..."
TOKEN=$(./bin/kubectl exec -n vault vault-0 -- vault token create -policy=spire -field=token)
TOKEN=$(./bin/kubectl exec -n vault vault-0 -- vault token create -policy=spire -ttl=1m -field=token)
./bin/kubectl create secret -n spire generic vault-credential \
--from-literal=token=$TOKEN
./bin/kubectl apply -k ./conf/server/token-auth
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -eo pipefail

log-debug "verifying token renewal..."

timeout=$(date -ud "1 minute 30 second" +%s)
count=0

while [ $(date -u +%s) -lt $timeout ]; do
count=`./bin/kubectl logs -n spire $(./bin/kubectl get pod -n spire -o name) | echo "$(grep "Successfully renew auth token" || [[ $? == 1 ]])" | wc -l`
if [ $count -ge 2 ]; then
log-info "token renewal is verified"
exit 0
fi
sleep 10
done

fail-now "expected number of token renewal log not found"
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ vault policy write spire /tmp/spire.hcl
vault auth enable approle
vault write auth/approle/role/spire \
secret_id_ttl=120m \
token_ttl=60m \
token_max_tll=120m \
token_ttl=1m \
policies="spire"

# Configure K8s Auth Method
Expand All @@ -19,11 +18,13 @@ vault write auth/kubernetes/config kubernetes_host=https://$KUBERNETES_SERVICE_H
vault write auth/kubernetes/role/my-role \
bound_service_account_names=spire-server \
bound_service_account_namespaces=spire \
token_ttl=1m \
policies=spire

# Configure Cert Auth Method
vault auth enable cert
vault write auth/cert/certs/my-role \
display_name=spire \
token_ttl=1m \
policies=spire \
certificate=@/tmp/cert_auth_ca.pem
Loading