github.com/crowdsecurity/crowdsec@v1.6.1/test/bats/03_noagent.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  }
     9  
    10  teardown_file() {
    11      load "../lib/teardown_file.sh"
    12  }
    13  
    14  setup() {
    15      load "../lib/setup.sh"
    16      ./instance-data load
    17  }
    18  
    19  teardown() {
    20      ./instance-crowdsec stop
    21  }
    22  
    23  #----------
    24  
    25  @test "with agent: test without -no-cs flag" {
    26      config_set '.common.log_media="stdout"'
    27      rune -0 wait-for \
    28          --err "Starting processing data" \
    29          "${CROWDSEC}"
    30  }
    31  
    32  @test "no agent: crowdsec LAPI should run (-no-cs flag)" {
    33      config_set '.common.log_media="stdout"'
    34      rune -0 wait-for \
    35          --err "CrowdSec Local API listening" \
    36          "${CROWDSEC}" -no-cs
    37  }
    38  
    39  @test "no agent: crowdsec LAPI should run (no crowdsec_service in configuration file)" {
    40      config_disable_agent
    41      config_log_stderr
    42      rune -0 wait-for \
    43          --err "crowdsec agent is disabled" \
    44          "${CROWDSEC}"
    45  }
    46  
    47  @test "no agent: cscli config show" {
    48      config_set '.crowdsec_service.enable=false'
    49      rune -0 cscli config show -o human
    50      assert_output --partial "Global:"
    51      assert_output --partial "cscli:"
    52      assert_output --partial "Local API Server:"
    53      assert_output --partial "Crowdsec (disabled):"
    54  
    55      config_set 'del(.crowdsec_service)'
    56      rune -0 cscli config show -o human
    57      assert_output --partial "Global:"
    58      assert_output --partial "cscli:"
    59      assert_output --partial "Local API Server:"
    60      refute_output --partial "Crowdsec"
    61  }
    62  
    63  @test "no agent: cscli config backup" {
    64      config_disable_agent
    65      backupdir=$(TMPDIR="${BATS_TEST_TMPDIR}" mktemp -u)
    66      rune -0 cscli config backup "${backupdir}"
    67      assert_stderr --partial "Starting configuration backup"
    68      rune -1 cscli config backup "${backupdir}"
    69  
    70      assert_stderr --partial "failed to backup config"
    71      assert_stderr --partial "file exists"
    72      rm -rf -- "${backupdir:?}"
    73  }
    74  
    75  @test "no agent: lapi status should be ok" {
    76      config_disable_agent
    77      ./instance-crowdsec start
    78      rune -0 cscli lapi status
    79      assert_stderr --partial "You can successfully interact with Local API (LAPI)"
    80  }
    81  
    82  @test "cscli metrics" {
    83      config_disable_agent
    84      ./instance-crowdsec start
    85      rune -0 cscli lapi status
    86      rune -0 cscli metrics
    87  }