|
@@ -35,10 +35,9 @@ declare stderr
|
|
|
|
|
|
# no "usage" output after every error
|
|
# no "usage" output after every error
|
|
run -1 --separate-stderr cscli blahblah
|
|
run -1 --separate-stderr cscli blahblah
|
|
- run -0 echo "${stderr}"
|
|
|
|
# error is displayed as log entry, not with print
|
|
# error is displayed as log entry, not with print
|
|
- assert_output --partial 'level=fatal msg="unknown command \"blahblah\" for \"cscli\""'
|
|
|
|
- refute_output --partial 'unknown command "blahblah" for "cscli"'
|
|
|
|
|
|
+ assert_stderr --partial 'level=fatal msg="unknown command \"blahblah\" for \"cscli\""'
|
|
|
|
+ refute_stderr --partial 'unknown command "blahblah" for "cscli"'
|
|
}
|
|
}
|
|
|
|
|
|
@test "cscli version" {
|
|
@test "cscli version" {
|
|
@@ -101,8 +100,7 @@ declare stderr
|
|
ONLINE_API_CREDENTIALS_YAML="$(config_get '.api.server.online_client.credentials_path')"
|
|
ONLINE_API_CREDENTIALS_YAML="$(config_get '.api.server.online_client.credentials_path')"
|
|
rm "${ONLINE_API_CREDENTIALS_YAML}"
|
|
rm "${ONLINE_API_CREDENTIALS_YAML}"
|
|
run -1 --separate-stderr cscli capi status
|
|
run -1 --separate-stderr cscli capi status
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "Local API is disabled, please run this command on the local API machine: loading online client credentials: failed to read api server credentials configuration file '${ONLINE_API_CREDENTIALS_YAML}': open ${ONLINE_API_CREDENTIALS_YAML}: no such file or directory"
|
|
|
|
|
|
+ assert_stderr --partial "Local API is disabled, please run this command on the local API machine: loading online client credentials: failed to read api server credentials configuration file '${ONLINE_API_CREDENTIALS_YAML}': open ${ONLINE_API_CREDENTIALS_YAML}: no such file or directory"
|
|
}
|
|
}
|
|
|
|
|
|
@test "cscli config show -o human" {
|
|
@test "cscli config show -o human" {
|
|
@@ -147,12 +145,10 @@ declare stderr
|
|
# test that we need a valid path
|
|
# test that we need a valid path
|
|
# disabled because in CI, the empty string is not passed as a parameter
|
|
# disabled because in CI, the empty string is not passed as a parameter
|
|
## run -1 --separate-stderr cscli config backup ""
|
|
## run -1 --separate-stderr cscli config backup ""
|
|
- ## run -0 echo "${stderr}"
|
|
|
|
- ## assert_output --partial "Failed to backup configurations: directory path can't be empty"
|
|
|
|
|
|
+ ## assert_stderr --partial "Failed to backup configurations: directory path can't be empty"
|
|
|
|
|
|
run -1 --separate-stderr cscli config backup "/dev/null/blah"
|
|
run -1 --separate-stderr cscli config backup "/dev/null/blah"
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "Failed to backup configurations: while creating /dev/null/blah: mkdir /dev/null/blah: not a directory"
|
|
|
|
|
|
+ assert_stderr --partial "Failed to backup configurations: while creating /dev/null/blah: mkdir /dev/null/blah: not a directory"
|
|
|
|
|
|
# pick a dirpath
|
|
# pick a dirpath
|
|
backupdir=$(TMPDIR="${BATS_TEST_TMPDIR}" mktemp -u)
|
|
backupdir=$(TMPDIR="${BATS_TEST_TMPDIR}" mktemp -u)
|
|
@@ -163,9 +159,8 @@ declare stderr
|
|
|
|
|
|
# don't overwrite an existing backup
|
|
# don't overwrite an existing backup
|
|
run -1 --separate-stderr cscli config backup "${backupdir}"
|
|
run -1 --separate-stderr cscli config backup "${backupdir}"
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "Failed to backup configurations"
|
|
|
|
- assert_output --partial "file exists"
|
|
|
|
|
|
+ assert_stderr --partial "Failed to backup configurations"
|
|
|
|
+ assert_stderr --partial "file exists"
|
|
|
|
|
|
SIMULATION_YAML="$(config_get '.config_paths.simulation_path')"
|
|
SIMULATION_YAML="$(config_get '.config_paths.simulation_path')"
|
|
|
|
|
|
@@ -180,8 +175,7 @@ declare stderr
|
|
# backup: detect missing files
|
|
# backup: detect missing files
|
|
rm "${SIMULATION_YAML}"
|
|
rm "${SIMULATION_YAML}"
|
|
run -1 --separate-stderr cscli config backup "${backupdir}"
|
|
run -1 --separate-stderr cscli config backup "${backupdir}"
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --regexp "Failed to backup configurations: failed copy .* to .*: stat .*: no such file or directory"
|
|
|
|
|
|
+ assert_stderr --regexp "Failed to backup configurations: failed copy .* to .*: stat .*: no such file or directory"
|
|
rm -rf -- "${backupdir:?}"
|
|
rm -rf -- "${backupdir:?}"
|
|
}
|
|
}
|
|
|
|
|
|
@@ -199,47 +193,38 @@ declare stderr
|
|
LOCAL_API_CREDENTIALS=$(config_get '.api.client.credentials_path')
|
|
LOCAL_API_CREDENTIALS=$(config_get '.api.client.credentials_path')
|
|
rm -f "${LOCAL_API_CREDENTIALS}"
|
|
rm -f "${LOCAL_API_CREDENTIALS}"
|
|
run -1 --separate-stderr cscli lapi status
|
|
run -1 --separate-stderr cscli lapi status
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "loading api client: while reading yaml file: open ${LOCAL_API_CREDENTIALS}: no such file or directory"
|
|
|
|
|
|
+ assert_stderr --partial "loading api client: while reading yaml file: open ${LOCAL_API_CREDENTIALS}: no such file or directory"
|
|
|
|
|
|
run -1 --separate-stderr cscli alerts list
|
|
run -1 --separate-stderr cscli alerts list
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "loading api client: while reading yaml file: open ${LOCAL_API_CREDENTIALS}: no such file or directory"
|
|
|
|
|
|
+ assert_stderr --partial "loading api client: while reading yaml file: open ${LOCAL_API_CREDENTIALS}: no such file or directory"
|
|
|
|
|
|
run -1 --separate-stderr cscli decisions list
|
|
run -1 --separate-stderr cscli decisions list
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "loading api client: while reading yaml file: open ${LOCAL_API_CREDENTIALS}: no such file or directory"
|
|
|
|
|
|
+ assert_stderr --partial "loading api client: while reading yaml file: open ${LOCAL_API_CREDENTIALS}: no such file or directory"
|
|
}
|
|
}
|
|
|
|
|
|
@test "cscli - empty LAPI credentials file" {
|
|
@test "cscli - empty LAPI credentials file" {
|
|
LOCAL_API_CREDENTIALS=$(config_get '.api.client.credentials_path')
|
|
LOCAL_API_CREDENTIALS=$(config_get '.api.client.credentials_path')
|
|
truncate -s 0 "${LOCAL_API_CREDENTIALS}"
|
|
truncate -s 0 "${LOCAL_API_CREDENTIALS}"
|
|
run -1 --separate-stderr cscli lapi status
|
|
run -1 --separate-stderr cscli lapi status
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "no credentials or URL found in api client configuration '${LOCAL_API_CREDENTIALS}'"
|
|
|
|
|
|
+ assert_stderr --partial "no credentials or URL found in api client configuration '${LOCAL_API_CREDENTIALS}'"
|
|
|
|
|
|
run -1 --separate-stderr cscli alerts list
|
|
run -1 --separate-stderr cscli alerts list
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "no credentials or URL found in api client configuration '${LOCAL_API_CREDENTIALS}'"
|
|
|
|
|
|
+ assert_stderr --partial "no credentials or URL found in api client configuration '${LOCAL_API_CREDENTIALS}'"
|
|
|
|
|
|
run -1 --separate-stderr cscli decisions list
|
|
run -1 --separate-stderr cscli decisions list
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "no credentials or URL found in api client configuration '${LOCAL_API_CREDENTIALS}'"
|
|
|
|
|
|
+ assert_stderr --partial "no credentials or URL found in api client configuration '${LOCAL_API_CREDENTIALS}'"
|
|
}
|
|
}
|
|
|
|
|
|
@test "cscli - missing LAPI client settings" {
|
|
@test "cscli - missing LAPI client settings" {
|
|
config_set 'del(.api.client)'
|
|
config_set 'del(.api.client)'
|
|
run -1 --separate-stderr cscli lapi status
|
|
run -1 --separate-stderr cscli lapi status
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "loading api client: no API client section in configuration"
|
|
|
|
|
|
+ assert_stderr --partial "loading api client: no API client section in configuration"
|
|
|
|
|
|
run -1 --separate-stderr cscli alerts list
|
|
run -1 --separate-stderr cscli alerts list
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "loading api client: no API client section in configuration"
|
|
|
|
|
|
+ assert_stderr --partial "loading api client: no API client section in configuration"
|
|
|
|
|
|
run -1 --separate-stderr cscli decisions list
|
|
run -1 --separate-stderr cscli decisions list
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "loading api client: no API client section in configuration"
|
|
|
|
|
|
+ assert_stderr --partial "loading api client: no API client section in configuration"
|
|
}
|
|
}
|
|
|
|
|
|
@test "cscli - malformed LAPI url" {
|
|
@test "cscli - malformed LAPI url" {
|
|
@@ -247,19 +232,16 @@ declare stderr
|
|
config_set "${LOCAL_API_CREDENTIALS}" '.url="https://127.0.0.1:-80"'
|
|
config_set "${LOCAL_API_CREDENTIALS}" '.url="https://127.0.0.1:-80"'
|
|
|
|
|
|
run -1 --separate-stderr cscli lapi status
|
|
run -1 --separate-stderr cscli lapi status
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial 'parsing api url'
|
|
|
|
- assert_output --partial 'invalid port \":-80\" after host'
|
|
|
|
|
|
+ assert_stderr --partial 'parsing api url'
|
|
|
|
+ assert_stderr --partial 'invalid port \":-80\" after host'
|
|
|
|
|
|
run -1 --separate-stderr cscli alerts list
|
|
run -1 --separate-stderr cscli alerts list
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial 'parsing api url'
|
|
|
|
- assert_output --partial 'invalid port \":-80\" after host'
|
|
|
|
|
|
+ assert_stderr --partial 'parsing api url'
|
|
|
|
+ assert_stderr --partial 'invalid port \":-80\" after host'
|
|
|
|
|
|
run -1 --separate-stderr cscli decisions list
|
|
run -1 --separate-stderr cscli decisions list
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial 'parsing api url'
|
|
|
|
- assert_output --partial 'invalid port \":-80\" after host'
|
|
|
|
|
|
+ assert_stderr --partial 'parsing api url'
|
|
|
|
+ assert_stderr --partial 'invalid port \":-80\" after host'
|
|
}
|
|
}
|
|
|
|
|
|
@test "cscli metrics" {
|
|
@test "cscli metrics" {
|
|
@@ -268,8 +250,7 @@ declare stderr
|
|
assert_output --partial "ROUTE"
|
|
assert_output --partial "ROUTE"
|
|
assert_output --partial '/v1/watchers/login'
|
|
assert_output --partial '/v1/watchers/login'
|
|
|
|
|
|
- run -0 echo "${stderr}"
|
|
|
|
- assert_output --partial "Local Api Metrics:"
|
|
|
|
|
|
+ assert_stderr --partial "Local Api Metrics:"
|
|
}
|
|
}
|
|
|
|
|
|
@test "'cscli completion' with or without configuration file" {
|
|
@test "'cscli completion' with or without configuration file" {
|