18 lines
658 B
Bash
Executable File
18 lines
658 B
Bash
Executable File
#!/bin/bash
|
|
# Self-check for the Discord webhook helpers: bash test_webhook.sh
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck source=network-config.sh
|
|
source "$SCRIPT_DIR/network-config.sh"
|
|
|
|
line='{"timestamp":"2026-11-05T12:00:00Z","src_ip":"1.2.3.4","dst_port":8080}'
|
|
msg=$(webhook_msg "$line") || { echo "FAIL: valid line rejected"; exit 1; }
|
|
echo "$msg" | grep -q "1.2.3.4" || { echo "FAIL: src_ip missing from: $msg"; exit 1; }
|
|
echo "$msg" | grep -q "8080" || { echo "FAIL: dst_port missing from: $msg"; exit 1; }
|
|
|
|
if webhook_msg 'not json' >/dev/null; then
|
|
echo "FAIL: invalid line accepted"
|
|
exit 1
|
|
fi
|
|
|
|
echo "OK: $msg"
|