github.com/crowdsecurity/crowdsec@v1.6.1/test/bats-detect/postfix-deb.bats (about) 1 #!/usr/bin/env bats 2 # vim: ft=bats:list:ts=8:sts=4:sw=4:et:ai:si: 3 4 set -u 5 6 setup_file() { 7 load "../lib/setup_file.sh" 8 load "${BATS_TEST_DIRNAME}/lib/setup_file_detect.sh" 9 } 10 11 teardown_file() { 12 load "../lib/teardown_file.sh" 13 deb-remove postfix 14 } 15 16 setup() { 17 if ! command -v dpkg >/dev/null; then 18 skip 'not a debian-like system' 19 fi 20 load "../lib/setup.sh" 21 load "../lib/bats-file/load.bash" 22 ./instance-data load 23 } 24 25 #---------- 26 27 @test "postfix: detect unit (fail)" { 28 run -0 cscli setup detect 29 run -0 jq -r '.setup | .[].detected_service' <(output) 30 refute_line 'postfix-systemd' 31 } 32 33 @test "postfix: install" { 34 run -0 sudo debconf-set-selections <<< "postfix postfix/mailname string hostname.example.com" 35 run -0 sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'" 36 run -0 deb-install postfix 37 run -0 sudo systemctl enable postfix.service 38 } 39 40 @test "postfix: detect unit (succeed)" { 41 run -0 cscli setup detect 42 run -0 jq -r '.setup | .[].detected_service' <(output) 43 assert_line 'postfix-systemd' 44 } 45 46 @test "postfix: install detected collection" { 47 run -0 cscli setup detect 48 run -0 cscli setup install-hub <(output) 49 }