github.com/crowdsecurity/crowdsec@v1.6.1/test/bats-detect/pgsql-rpm.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 rpm-remove postgresql-server 14 } 15 16 setup() { 17 if ! command -v dnf >/dev/null; then 18 skip 'not a redhat-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 "pgsql: detect unit (fail)" { 28 run -0 cscli setup detect 29 run -0 jq -r '.setup | .[].detected_service' <(output) 30 refute_line 'pgsql-systemd-rpm' 31 } 32 33 @test "pgsql: install" { 34 run -0 rpm-install postgresql-server 35 # for centos 8, we need to create the cluster 36 if ! sudo bash -c 'stat /var/lib/pgsql/data/*'; then 37 sudo /usr/bin/postgresql-setup --initdb 38 fi 39 run -0 sudo systemctl enable postgresql.service 40 } 41 42 @test "pgsql: detect unit (succeed)" { 43 run -0 cscli setup detect 44 run -0 jq -r '.setup | .[].detected_service' <(output) 45 assert_line 'pgsql-systemd-rpm' 46 } 47 48 @test "pgsql: install detected collection" { 49 run -0 cscli setup detect 50 run -0 cscli setup install-hub <(output) 51 }