diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ddc8112..85a615a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## Latest + +ENHANCEMENTS: + +* Allow regex on `grep` operation ([#61](https://github.com/fishi0x01/vsh/pull/61) - Thank you for implementation [mattlqx](https://github.com/mattlqx)) +* Allow quotes and escapes in input ([#61](https://github.com/fishi0x01/vsh/pull/61) - Thank you for implementation [mattlqx](https://github.com/mattlqx)) + +BUG FIXES: + +* Fix panic on `data` keys in KV1 ([#63](https://github.com/fishi0x01/vsh/pull/63) - Thank you for issue submission [tommartensen](https://github.com/tommartensen)) + ## v0.7.2 (October 4, 2020) BUG FIXES: diff --git a/Makefile b/Makefile index bd94f080..bf0e27d7 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,10 @@ get-bats: ## Download bats dependencies to test directory curl -sL https://github.com/bats-core/bats-file/archive/v0.2.0.tar.gz | tar xvz --strip 1 -C test/bin/plugins/bats-file integration-tests: ## Run integration test suites (requires bats - see get-bats) - test/run.sh + test/run-all-tests.sh + +single-test: ## Run a single test suite, e.g., make single-test KV_BACKEND=KV2 VAULT_VERSION=1.6.1 TEST_SUITE=commands/cp + KV_BACKEND=$(KV_BACKEND) VAULT_VERSION=$(VAULT_VERSION) TEST_SUITE=$(TEST_SUITE) test/run-single-test.sh local-vault-test-instance: ## Start a local vault container with integration test provisioning bash -c ". test/util/util.bash && setup" diff --git a/client/util.go b/client/util.go index 3c8b5023..e0bbc50a 100644 --- a/client/util.go +++ b/client/util.go @@ -80,7 +80,7 @@ func (client *Client) isTopLevelPath(absolutePath string) bool { } func isValidKV2Data(secret *api.Secret) bool { - _, exists := secret.Data["data"] + _, exists := secret.Data["data"].(map[string]interface{}) return exists } diff --git a/test/run.sh b/test/run-all-tests.sh similarity index 100% rename from test/run.sh rename to test/run-all-tests.sh diff --git a/test/run-single-test.sh b/test/run-single-test.sh new file mode 100755 index 00000000..c53adee7 --- /dev/null +++ b/test/run-single-test.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e # required to fail test suite when a single test fails + +VAULT_VERSION=${VAULT_VERSION:-"1.6.1"} +KV_BACKEND=${KV_BACKEND:-"KV2"} +TEST_SUITE=${TEST_SUITE:-"commands/cp"} + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +export DIR +BATS="${DIR}/bin/core/bin/bats" + +VAULT_VERSION=${VAULT_VERSION} KV_BACKEND="${KV_BACKEND}" ${BATS} "${DIR}/suites/${TEST_SUITE}.bats" diff --git a/test/suites/commands/cp.bats b/test/suites/commands/cp.bats index bac78e0d..ca1f5fb9 100644 --- a/test/suites/commands/cp.bats +++ b/test/suites/commands/cp.bats @@ -24,6 +24,27 @@ load ../../bin/plugins/bats-assert/load assert_success assert_output "test" + ######################################### + echo "==== case: copy single files with 'data' key ====" + run ${APP_BIN} -c "cp ${KV_BACKEND}/src/data/1 ${KV_BACKEND}/dest/data/1" + assert_success + + echo "ensure the file got copied to destination" + run get_vault_value "data" "${KV_BACKEND}/dest/data/1" + assert_success + assert_output "1" + + run ${APP_BIN} -c "cp ${KV_BACKEND}/src/data/2 ${KV_BACKEND}/dest/data/2" + assert_success + + echo "ensure the file got copied to destination" + run get_vault_value "data" "${KV_BACKEND}/dest/data/2" + assert_success + assert_output "2" + run get_vault_value "value" "${KV_BACKEND}/dest/data/2" + assert_success + assert_output "1" + ####################################### echo "==== case: copy non-existing file ====" run ${APP_BIN} -c "cp ${KV_BACKEND}/src/does/not/exist ${KV_BACKEND}/dest/a" diff --git a/test/util/util.bash b/test/util/util.bash index 42d8e4f8..94a7f6f7 100755 --- a/test/util/util.bash +++ b/test/util/util.bash @@ -1,6 +1,6 @@ #!/bin/bash -export VAULT_VERSION=${VAULT_VERSION:-"1.5.3"} +export VAULT_VERSION=${VAULT_VERSION:-"1.6.1"} export VAULT_CONTAINER_NAME="vsh-integration-test-vault" export VAULT_HOST_PORT=${VAULT_HOST_PORT:-"8888"} @@ -39,6 +39,8 @@ setup() { vault_exec "vault secrets enable -version=2 -path=KV2 kv" for kv_backend in "${KV_BACKENDS[@]}" do + vault_exec "vault kv put ${kv_backend}/src/data/1 data=1" + vault_exec "vault kv put ${kv_backend}/src/data/2 value=1 data=2" vault_exec "vault kv put ${kv_backend}/src/dev/1 value=1 fruit=apple" vault_exec "vault kv put ${kv_backend}/src/dev/2 value=2 fruit=banana" vault_exec "vault kv put ${kv_backend}/src/dev/3 value=3 fruit=berry"