github.com/crowdsecurity/crowdsec@v1.6.1/test/bats-detect/vsftpd-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      sudo systemctl stop vsftpd.service 2>/dev/null || :
    14      deb-remove vsftpd
    15  }
    16  
    17  setup() {
    18      if ! command -v dpkg >/dev/null; then
    19          skip 'not a debian-like system'
    20      fi
    21      load "../lib/setup.sh"
    22      load "../lib/bats-file/load.bash"
    23      ./instance-data load
    24  }
    25  
    26  #----------
    27  
    28  @test "vsftpd: detect unit (fail)" {
    29      run -0 cscli setup detect
    30      run -0 jq -r '.setup | .[].detected_service' <(output)
    31      refute_line 'vsftpd-systemd'
    32  }
    33  
    34  @test "vsftpd: install" {
    35      run -0 deb-install vsftpd
    36      run -0 sudo systemctl enable vsftpd.service
    37  }
    38  
    39  @test "vsftpd: detect unit (succeed)" {
    40      run -0 cscli setup detect
    41      run -0 jq -r '.setup | .[].detected_service' <(output)
    42      assert_line 'vsftpd-systemd'
    43  }
    44  
    45  @test "vsftpd: install detected collection" {
    46      run -0 cscli setup detect
    47      run -0 cscli setup install-hub <(output)
    48  }