2022-03-09 15:15:18 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
# vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si:
|
|
|
|
|
|
|
|
set -u
|
|
|
|
|
|
|
|
setup_file() {
|
2022-03-18 09:13:12 +00:00
|
|
|
load "../lib/setup_file.sh"
|
2022-03-09 15:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown_file() {
|
2022-03-18 09:13:12 +00:00
|
|
|
load "../lib/teardown_file.sh"
|
2022-03-09 15:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
load "../lib/setup.sh"
|
|
|
|
./instance-data load
|
|
|
|
./instance-crowdsec start
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
./instance-crowdsec stop
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------
|
|
|
|
|
|
|
|
@test "$FILE cscli alerts list, with and without --machine" {
|
2022-04-13 13:17:49 +00:00
|
|
|
is_db_postgres && skip
|
2022-03-09 15:15:18 +00:00
|
|
|
run -0 cscli decisions add -i 10.20.30.40 -t ban
|
|
|
|
|
|
|
|
run -0 cscli alerts list
|
|
|
|
refute_output --partial 'MACHINE'
|
|
|
|
# machine name appears quoted in the "REASON" column
|
2022-03-29 15:06:49 +00:00
|
|
|
assert_output --regexp "\| 'githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})?' \|"
|
|
|
|
refute_output --regexp "\| githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})? \|"
|
2022-03-09 15:15:18 +00:00
|
|
|
|
2022-03-17 11:20:08 +00:00
|
|
|
run -0 cscli alerts list -m
|
|
|
|
assert_output --partial 'MACHINE'
|
2022-03-29 15:06:49 +00:00
|
|
|
assert_output --regexp "\| 'githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})?' \|"
|
|
|
|
assert_output --regexp "\| githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})? \|"
|
2022-03-17 11:20:08 +00:00
|
|
|
|
2022-03-09 15:15:18 +00:00
|
|
|
run -0 cscli alerts list --machine
|
|
|
|
assert_output --partial 'MACHINE'
|
2022-03-29 15:06:49 +00:00
|
|
|
assert_output --regexp "\| 'githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})?' \|"
|
|
|
|
assert_output --regexp "\| githubciXXXXXXXXXXXXXXXXXXXXXXXX([a-zA-Z0-9]{16})? \|"
|
2022-03-09 15:15:18 +00:00
|
|
|
}
|