Use grep for more reliable JSON value detection in test script

- Replace Bash pattern matching with grep for more consistent testing
- Add more explicit comments about detecting sealed/unsealed status
- Improve overall reliability of the test script

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Harald Hoyer 2025-03-20 12:55:53 +01:00
parent 334fc50ac7
commit 8595cdead3

View file

@ -118,7 +118,8 @@ fi
# Verify Vault is unsealed
vault_status=$(docker-compose exec -T vault env VAULT_ADDR=http://127.0.0.1:8200 vault status -format=json 2>/dev/null || echo '{"sealed": true}')
if [[ "$vault_status" == *'"sealed":false'* ]]; then
# Check if Vault is unsealed by looking for "sealed":false - needs jq for reliable parsing
if echo "$vault_status" | grep -q '"sealed":false'; then
log "INFO" "Vault is properly unsealed"
else
log "ERROR" "Vault is still sealed"
@ -143,7 +144,7 @@ sleep 5
# Verify Vault is sealed after restart (it should be)
vault_status=$(docker-compose exec -T vault env VAULT_ADDR=http://127.0.0.1:8200 vault status -format=json 2>/dev/null || echo '{"sealed": true}')
if [[ "$vault_status" == *'"sealed":true'* ]]; then
if echo "$vault_status" | grep -q '"sealed":true'; then
log "INFO" "Vault is correctly sealed after restart"
else
log "WARN" "Vault is not sealed after restart - this is unexpected"
@ -166,7 +167,7 @@ docker-compose run -e VAULT_ADDR=http://vault:8200 \
# Verify Vault is unsealed now
vault_status=$(docker-compose exec -T vault env VAULT_ADDR=http://127.0.0.1:8200 vault status -format=json 2>/dev/null || echo '{"sealed": true}')
if [[ "$vault_status" == *'"sealed":false'* ]]; then
if echo "$vault_status" | grep -q '"sealed":false'; then
log "INFO" "Vault was successfully unsealed after restart"
else
log "ERROR" "Vault is still sealed after restart"