mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
43 lines
992 B
Text
43 lines
992 B
Text
# @TEST-REQUIRES: which python
|
|
# @TEST-REQUIRES: which curl
|
|
#
|
|
# @TEST-EXEC: btest-bg-run httpd python $SCRIPTS/httpd.py --max 2 --addr=127.0.0.1
|
|
# @TEST-EXEC: sleep 3
|
|
# @TEST-EXEC: btest-bg-run bro bro -b %INPUT
|
|
# @TEST-EXEC: btest-bg-wait 15
|
|
# @TEST-EXEC: cat bro/.stdout | sort >output
|
|
# @TEST-EXEC: btest-diff output
|
|
|
|
@load base/utils/active-http
|
|
@load base/frameworks/communication # let network-time run. otherwise there are no heartbeats...
|
|
redef exit_only_after_terminate = T;
|
|
|
|
global c: count = 0;
|
|
|
|
function check_exit_condition()
|
|
{
|
|
c += 1;
|
|
|
|
if ( c == 2 )
|
|
terminate();
|
|
}
|
|
|
|
function test_request(label: string, req: ActiveHTTP::Request)
|
|
{
|
|
when ( local response = ActiveHTTP::request(req) )
|
|
{
|
|
print label, response;
|
|
check_exit_condition();
|
|
}
|
|
timeout 1min
|
|
{
|
|
print "HTTP request timeout";
|
|
check_exit_condition();
|
|
}
|
|
}
|
|
|
|
event bro_init()
|
|
{
|
|
test_request("test1", [$url="127.0.0.1:32123"]);
|
|
test_request("test2", [$url="127.0.0.1:32123/empty", $method="POST"]);
|
|
}
|