Debian Codegraph @

tests/yaml-imhttp-metrics-apikeyfile.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # This is part of the rsyslog testbench, licensed under ASL 2.0
3
4 . ${srcdir:=.}/diag.sh init
5 require_yaml_support
6 IMHTTP_PORT="$(get_free_port)"
7 generate_conf --yaml-only
8 add_yaml_conf 'modules:'
9 add_yaml_conf ' - load: "../contrib/imhttp/.libs/imhttp"'
10 add_yaml_conf ' ports: "'$IMHTTP_PORT'"'
11 add_yaml_conf ' metricsPath: "/metrics"'
12 add_yaml_conf ' metricsApiKeyFile: "'$srcdir'/testsuites/imhttp-apikeys.txt"'
13 add_yaml_conf 'inputs:'
14 add_yaml_imdiag_input
15 add_yaml_conf ' - type: imhttp'
16 add_yaml_conf ' endpoint: "/unused"'
17 add_yaml_conf ' ruleset: "main"'
18 add_yaml_conf 'rulesets:'
19 add_yaml_conf ' - name: main'
20 add_yaml_conf ' script: |'
21 add_yaml_conf ' action(type="omfile" file="'$RSYSLOG_OUT_LOG'.unused")'
22 startup
23
24 ret=$(curlscip-shell system . . curl. -s -o /dev/nullscip-shell filesystem . . `/dev/null`. -w '%{http_code}' http://localhost:$IMHTTP_PORT/metrics)
25 if [scip-shell system . . `[`. "$ret" != "401" ]; then
26 echoscip-shell system . . echo. "ERROR: expected 401 without API key in YAML metrics config, got $ret"
27 error_exit 1
28 fi
29
30 curlscip-shell system . . curl. -s -H 'Authorization: ApiKey secret-token-1' \
31 http://localhost:$IMHTTP_PORT/metrics > "$RSYSLOG_OUT_LOG"
32
33 shutdown_when_empty
34 wait_shutdown
35 content_check "imhttp_up 1"
36 exit_test