From c7bac26e1a7811ebce5e549af100019d44cad2fb Mon Sep 17 00:00:00 2001 From: Jim Date: Tue, 4 May 2021 10:25:11 -0400 Subject: [PATCH] Fix a broken auth token test and support conditional tests for "versioned" releases. (#1195) --- internal/tests/cli/README.md | 4 ++++ internal/tests/cli/boundary/_auth_tokens.bash | 2 +- internal/tests/cli/boundary/_version.bash | 5 ++++- internal/tests/cli/boundary/version.bats | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/internal/tests/cli/README.md b/internal/tests/cli/README.md index 804872273c..0b290c2306 100644 --- a/internal/tests/cli/README.md +++ b/internal/tests/cli/README.md @@ -32,7 +32,11 @@ export BOUNDARY_ADDR= 2. Run the tests ```bash +# for an untagged non-version of boundary bats -p boundary/ + +# for an official boundary version +IS_VERSION=true bats -p boundary/ ``` ## Running Tests Against Other Deployments diff --git a/internal/tests/cli/boundary/_auth_tokens.bash b/internal/tests/cli/boundary/_auth_tokens.bash index dd33a7a1cd..0d5ed021c7 100644 --- a/internal/tests/cli/boundary/_auth_tokens.bash +++ b/internal/tests/cli/boundary/_auth_tokens.bash @@ -3,7 +3,7 @@ function read_token() { then echo "y" | boundary auth-tokens read else - boundary auth-tokens read -id $1 + boundary auth-tokens read -id $1 -format json fi } diff --git a/internal/tests/cli/boundary/_version.bash b/internal/tests/cli/boundary/_version.bash index 794b9065db..cb417b2daf 100644 --- a/internal/tests/cli/boundary/_version.bash +++ b/internal/tests/cli/boundary/_version.bash @@ -3,6 +3,9 @@ function version() { } function version_is_valid() { + if [ "$IS_VERSION" = "" ]; then + skip "not a version build" + fi ver=$($(strip version) | jq -c '.version' | cut -d 'v' -f2) if [ "$ver" == "null" ]; then return 1 @@ -12,7 +15,7 @@ function version_is_valid() { function revision_is_valid() { len=$($(strip version) | jq -c '.revision' | cut -d '+' -f1 | wc -m) - if [ "$len" -eq 42 ]; then + if [ "$len" -eq 43 ]; then return 0 fi return 1 diff --git a/internal/tests/cli/boundary/version.bats b/internal/tests/cli/boundary/version.bats index 1794d8560d..bc10a78c18 100644 --- a/internal/tests/cli/boundary/version.bats +++ b/internal/tests/cli/boundary/version.bats @@ -16,3 +16,10 @@ export NEW_USER='test' echo "$output" [ "$status" -eq 0 ] } + + +@test "boundary/version: revision output is valid" { + run revision_is_valid + echo "$output" + [ "$status" -eq 0 ] +}