github.com/crowdsecurity/crowdsec@v1.6.1/test/bats-detect/proftpd-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      systemctl stop proftpd.service || :
    14      deb-remove proftpd proftpd-core
    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 "proftpd: detect unit (fail)" {
    29      run -0 cscli setup detect
    30      run -0 jq -r '.setup | .[].detected_service' <(output)
    31      refute_line 'proftpd-systemd'
    32  }
    33  
    34  @test "proftpd: install" {
    35      run -0 deb-install proftpd
    36      run -0 sudo systemctl unmask proftpd.service
    37      run -0 sudo systemctl enable proftpd.service
    38  }
    39  
    40  @test "proftpd: detect unit (succeed)" {
    41      run -0 cscli setup detect
    42      run -0 jq -r '.setup | .[].detected_service' <(output)
    43      assert_line 'proftpd-systemd'
    44  }
    45  
    46  @test "proftpd: install detected collection" {
    47      run -0 cscli setup detect
    48      run -0 cscli setup install-hub <(output)
    49  }