mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-03 20:40:45 -05:00
* LDAP Check out Check in System test Cases Part-1 * Test run on pipeline * Test run on pipeline * Linter error fix * Fix linter issue * Linter error fix * lint issue * lint issue * lint issue * lint issue * lint issue * lint issues * bug fix * lint fix * Run test on pipeline * Remove file enos.vars.hcl from repository * Revert "Remove file enos.vars.hcl from repository" This reverts commit bec9bcd5e1d8b07a662756c2385ca90e035fc125. * Restore enos.vars.hcl to repository * CI build failure fix * CI bug fix * CI bug fix * CI bug fix * CI bug fix * CI bug fix * Replace string based error detection with exit code * Changing pipeline run variable to false --------- Co-authored-by: KajalKusum <kajal.kusum@hashicorp.com> Co-authored-by: Kajal Kusum <kajal.kusum@ibm.com> Co-authored-by: Luis (LT) Carbonell <lt.carbonell@hashicorp.com>
42 lines
1.2 KiB
Bash
42 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Copyright IBM Corp. 2016, 2025
|
|
# SPDX-License-Identifier: BUSL-1.1
|
|
|
|
set -e
|
|
|
|
fail() {
|
|
echo "$1" 1>&2
|
|
exit 1
|
|
}
|
|
|
|
[[ -z "$REQPATH" ]] && fail "REQPATH env variable has not been set"
|
|
[[ -z "$VAULT_ADDR" ]] && fail "VAULT_ADDR env variable has not been set"
|
|
[[ -z "$VAULT_INSTALL_DIR" ]] && fail "VAULT_INSTALL_DIR env variable has not been set"
|
|
[[ -z "$VAULT_TOKEN" ]] && fail "VAULT_TOKEN env variable has not been set"
|
|
|
|
binpath="${VAULT_INSTALL_DIR}/vault"
|
|
test -x "$binpath" || fail "unable to locate vault binary at $binpath"
|
|
|
|
export VAULT_FORMAT=json
|
|
|
|
echo "Vault DELETE request to path: $REQPATH"
|
|
|
|
set +e
|
|
output=$("$binpath" delete "$REQPATH" 2>&1)
|
|
exit_code=$?
|
|
set -e
|
|
|
|
# Always print output
|
|
if [ "$exit_code" -eq 0 ]; then
|
|
printf "%s\n" "$output"
|
|
else
|
|
printf "%s\n" "$output" >&2
|
|
# Handle expected errors gracefully (idempotent delete)
|
|
# Exit code 2 typically means "not found" - acceptable for idempotent cleanup
|
|
if [ "$exit_code" -eq 2 ]; then
|
|
echo "Note: Path not found (exit code 2), treating as successful cleanup: $REQPATH" >&2
|
|
exit 0
|
|
fi
|
|
# For other errors, fail the test
|
|
fail "failed to delete path: $REQPATH exit_code=${exit_code}"
|
|
fi
|