All checks were successful
continuous-integration/drone/push Build is passing
In preparation for the new abra release, let's fix all integration tests After merging, this needs to be cherry-picked into the release-0-9 branch. - [x] app_backup.bats (skip this one) - [x] app_check.bats (fixed bybd21014fed
) - [x] app_cmd.bats (partially fixed in08232b74f6
), has known regression coop-cloud/organising#581 - [x] app_config.bats (no changes needed) - [x] app_cp.bats (no changes needed) - [x] app_deploy.bats - [x] app_errors.bats (no changes needed) - [x] app_list.bats (no changes needed) - [x] app_logs.bats (no changes needed) - [x] app_new.bats (no changes needed) - [x] app_ps.bats (no changes needed) - [x] app_remove.bats (fixed by [2f29fbeb2e](coop-cloud/abra#403/commits/2f29fbeb2e018656413fa25f8615b7a98cdcb083)) - [x] app_restart.bats (no changes needed - [x] app_restore.bats (fixed by [f2dd5afc38](coop-cloud/abra#403/commits/f2dd5afc38a25a8316899fa0c6d59499445868d7)) - [x] app_rollback.bats (partially fixed by6e99b74c24
) - [x] app_run.bats (no changes needed) - [x] app_secret.bats (fixed bybd069d32f6
) - [x] app_services.bats (no changes needed) - [x] app_undeploy.bats (no changes needed) - [x] app_upgrade.bats (no changes needed) - [x] app_version.bats (partially fixed byad323ad2bd
) - [x] app_volume.bats (fixed by [03c3823770](coop-cloud/abra#403/commits/03c38237707ae795b723180eb07a7edc84a8de35)) - [x] autocomplete.bats (no changes needed) - [x] catalogue.bats (no changes needed) - [x] dirs.bats (no changes needed) - [x] install.bats (failes, but is expected) - [x] recipe_diff.bats (no changes needed) - [x] recipe_fetch.bats (no changes needed) - [x] recipe_lint.bats (fixed by [b6b0808066](coop-cloud/abra#403/commits/b6b0808066a11e4bcd77517ec39600d500bcb944)) - [x] recipe_list.bats (no changes needed) - [x] recipe_new.bats (fixed by [0aac464ded](coop-cloud/abra#403/commits/0aac464ded6b43afb3ec37ade2f64d6191b9838f)) - [x] recipe_release.bats (no changes needed) - [x] recipe_reset.bats (no changes needed) - [x] recipe_sync.bats (no changes needed) - [x] recipe_upgrade.bats (fixed by [ab86904cf4](coop-cloud/abra#403/commits/ab86904cf45db89c7c189ca1fd9971909bd446dd)) - [x] recipe_version.bats (fixed by81897bf4da
) - [x] server_add.bats - [x] server_list.bats - [x] server_prune.bats (no changes needed) - [x] server_remove.bats - [x] upgrade.bats - [x] version.bats (no changes needed) Co-authored-by: decentral1se <cellarspoon@riseup.net> Reviewed-on: coop-cloud/abra#403 Co-authored-by: p4u1 <p4u1_f4u1@riseup.net> Co-committed-by: p4u1 <p4u1_f4u1@riseup.net>
350 lines
9.6 KiB
Bash
350 lines
9.6 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
setup_file(){
|
|
load "$PWD/tests/integration/helpers/common"
|
|
_common_setup
|
|
_add_server
|
|
|
|
run $ABRA app new "$TEST_RECIPE" \
|
|
--no-input \
|
|
--server "$TEST_SERVER" \
|
|
--domain "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
}
|
|
|
|
teardown_file(){
|
|
_rm_app
|
|
_rm_server
|
|
_reset_recipe
|
|
}
|
|
|
|
setup(){
|
|
load "$PWD/tests/integration/helpers/common"
|
|
_common_setup
|
|
}
|
|
|
|
@test "generate: validate arguments" {
|
|
run $ABRA app secret generate
|
|
assert_failure
|
|
assert_output --partial 'no app provided'
|
|
|
|
run $ABRA app secret generate DOESNTEXIST
|
|
assert_failure
|
|
assert_output --partial 'cannot find app'
|
|
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN"
|
|
assert_failure
|
|
assert_output --partial 'missing arguments'
|
|
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" testSecret testVersion --all
|
|
assert_failure
|
|
assert_output --partial 'cannot use'
|
|
assert_output --partial "'--all' together"
|
|
}
|
|
|
|
@test "generate: single secret no match" {
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" DOESNTEXIST v1
|
|
assert_failure
|
|
assert_output --partial "doesn't exist in the env config"
|
|
}
|
|
|
|
@test "generate: create secrets" {
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_output --partial 'test_pass_one'
|
|
assert_output --partial 'test_pass_two'
|
|
refute_output --partial 'extra_pass'
|
|
assert_output --partial 'false'
|
|
refute_output --partial 'true'
|
|
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
assert_output --partial 'test_pass_one'
|
|
assert_output --partial 'test_pass_two'
|
|
refute_output --partial 'extra_pass'
|
|
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_output --partial 'test_pass_one'
|
|
assert_output --partial 'test_pass_two'
|
|
refute_output --partial 'extra_pass'
|
|
refute_output --partial 'false'
|
|
assert_output --partial 'true'
|
|
|
|
run docker -c "$TEST_SERVER" secret ls
|
|
assert_success
|
|
assert_output --partial 'test_pass_one'
|
|
assert_output --partial 'test_pass_two'
|
|
refute_output --partial 'extra_pass'
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
}
|
|
|
|
@test "generate: broken if missing version" {
|
|
run sed -i '/SECRET_TEST_PASS_ONE_VERSION=.*/d' \
|
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
|
assert_failure
|
|
assert_output --partial 'missing version'
|
|
|
|
_reset_app
|
|
}
|
|
|
|
@test "generate: use version from app env" {
|
|
run sed -i 's/SECRET_TEST_PASS_ONE_VERSION=v1/SECRET_TEST_PASS_ONE_VERSION=v2/g' \
|
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
assert_output --partial 'test_pass_one'
|
|
|
|
run bash -c '$ABRA app secret ls $TEST_APP_DOMAIN --machine | \
|
|
jq -r ".[] | select(.name==\"test_pass_one\") | .version"'
|
|
assert_success
|
|
assert_output --partial 'v2'
|
|
refute_output --partial 'v1'
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
|
|
_reset_app
|
|
}
|
|
|
|
@test "generate: generate extra secret based on COMPOSE_FILE" {
|
|
run sed -i 's/COMPOSE_FILE="compose.yml"/COMPOSE_FILE="compose.yml:compose.extra_secret.yml"/g' \
|
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
|
|
run sed -i 's/#SECRET_EXTRA_PASS_VERSION=v1/SECRET_EXTRA_PASS_VERSION=v1/g' \
|
|
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
|
|
assert_success
|
|
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
assert_output --partial 'extra_pass'
|
|
|
|
run docker -c "$TEST_SERVER" secret ls
|
|
assert_success
|
|
assert_output --partial "$TEST_APP_DOMAIN_extra_pass_v1"
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
|
|
_reset_app
|
|
}
|
|
|
|
@test "generate: bail if unstaged changes and no --chaos" {
|
|
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
|
assert_failure
|
|
assert_output --partial 'locally unstaged changes'
|
|
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
}
|
|
|
|
@test "generate: do not generate if not enabled" {
|
|
run sed -i '/- test_pass_one/d' "$ABRA_DIR/recipes/$TEST_RECIPE/compose.yml"
|
|
assert_success
|
|
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all --chaos
|
|
assert_success
|
|
assert_output --partial 'test_pass_one not enabled in recipe config'
|
|
assert_output --partial 'test_pass_two'
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all --chaos
|
|
assert_success
|
|
|
|
_checkout_recipe
|
|
}
|
|
|
|
@test "generate: ensure secret name uses trimmed stack name" {
|
|
# NOTE(d1): 45 chars, to ensure that the app name must be trimmed
|
|
testAppDomain="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
|
|
|
run $ABRA app new "$TEST_RECIPE" \
|
|
--no-input \
|
|
--server "$TEST_SERVER" \
|
|
--domain "$testAppDomain.$TEST_SERVER" \
|
|
--secrets \
|
|
--debug
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$testAppDomain.$TEST_SERVER.env"
|
|
assert_output --partial "avoid runtime limits"
|
|
|
|
run $ABRA app secret rm "$testAppDomain.$TEST_SERVER" --all
|
|
assert_success
|
|
|
|
run rm -rf "$ABRA_DIR/servers/$TEST_SERVER/$testAppDomain.$TEST_SERVER.env"
|
|
assert_success
|
|
assert_not_exists "$ABRA_DIR/servers/$TEST_SERVER/$testAppDomain.$TEST_SERVER.env"
|
|
}
|
|
|
|
@test "generate: secret length honoured" {
|
|
run bash -c '$ABRA app secret generate "$TEST_APP_DOMAIN" --all --machine \
|
|
| jq -r ".[] | select(.name==\"test_pass_two\") | .value" | awk "{print length}"'
|
|
assert_success
|
|
assert_output --partial '10' # NOTE(d1): hardcoded # length=10 in recipe config
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
}
|
|
|
|
@test "insert: validate arguments" {
|
|
run $ABRA app secret insert
|
|
assert_failure
|
|
assert_output --partial 'no app provided'
|
|
|
|
run $ABRA app secret insert "$TEST_APP_DOMAIN"
|
|
assert_failure
|
|
assert_output --partial 'missing arguments'
|
|
|
|
run $ABRA app secret insert "$TEST_APP_DOMAIN" bar
|
|
assert_failure
|
|
assert_output --partial 'missing arguments'
|
|
|
|
run $ABRA app secret insert "$TEST_APP_DOMAIN" bar baz
|
|
assert_failure
|
|
assert_output --partial 'missing arguments'
|
|
}
|
|
|
|
@test "insert: create secret" {
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_output --partial 'false'
|
|
|
|
run $ABRA app secret insert "$TEST_APP_DOMAIN" test_pass_one v1 foo
|
|
assert_success
|
|
assert_output --partial 'successfully stored on server'
|
|
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_output --partial 'true'
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" test_pass_one
|
|
assert_success
|
|
}
|
|
|
|
@test "rm: validate arguments" {
|
|
run $ABRA app secret rm
|
|
assert_failure
|
|
assert_output --partial 'no app provided'
|
|
|
|
run $ABRA app secret rm DOESNTEXIST
|
|
assert_failure
|
|
assert_output --partial 'cannot find app'
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN"
|
|
assert_failure
|
|
assert_output --partial 'no secret(s) specified'
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" test_pass_one --all
|
|
assert_failure
|
|
assert_output --partial 'cannot use'
|
|
assert_output --partial "'--all' together"
|
|
}
|
|
|
|
@test "rm: single secret no match" {
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" foo_password
|
|
assert_failure
|
|
assert_output --partial "doesn't exist on server"
|
|
}
|
|
|
|
@test "rm: no secret match" {
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
|
assert_failure
|
|
assert_output --partial 'no secrets to remove'
|
|
}
|
|
|
|
@test "rm: remove secret" {
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_output --partial 'true'
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_output --partial 'false'
|
|
}
|
|
|
|
@test "rm: bail if unstaged changes and no --chaos" {
|
|
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
|
assert_failure
|
|
assert_output --partial 'locally unstaged changes'
|
|
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
}
|
|
|
|
@test "ls: validate arguments" {
|
|
run $ABRA app secret ls
|
|
assert_failure
|
|
assert_output --partial 'no app provided'
|
|
|
|
run $ABRA app secret ls DOESNTEXIST
|
|
assert_failure
|
|
assert_output --partial 'cannot find app'
|
|
}
|
|
|
|
@test "ls: show secrets" {
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_output --partial 'false'
|
|
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_output --partial 'true'
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
}
|
|
|
|
@test "ls: show secrets as machine readable" {
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
|
assert_success
|
|
assert_output --partial 'false'
|
|
|
|
run $ABRA app secret generate "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN" --machine
|
|
assert_success
|
|
assert_output --partial '"created-on-server":"true"'
|
|
|
|
run $ABRA app secret rm "$TEST_APP_DOMAIN" --all
|
|
assert_success
|
|
}
|
|
|
|
@test "ls: bail if unstaged changes and no --chaos" {
|
|
run bash -c "echo foo >> $ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_success
|
|
assert_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
|
|
run $ABRA app secret ls "$TEST_APP_DOMAIN"
|
|
assert_failure
|
|
assert_output --partial 'locally unstaged changes'
|
|
|
|
run rm -rf "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
assert_not_exists "$ABRA_DIR/recipes/$TEST_RECIPE/foo"
|
|
}
|