mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
Merge remote-tracking branch 'origin/topic/struck/BIT-1277'
* origin/topic/struck/BIT-1277: [ADD] Added the feature to return 0 content to the python http test server and added functionality for post requests [ADD] added baseline for the new active-http test and added a test to check for the content-length 0 fix. [ADD] added baseline for the new exec test and added a test to check for the empty files fix. [FIX] exec should write an empty string when file is empty instead of the filename [FIX] Add files to result table even if the files are empty BIT-1277 #merged
This commit is contained in:
commit
4216a5eb1c
9 changed files with 76 additions and 14 deletions
|
@ -1,4 +1,9 @@
|
|||
[code=200, msg=OK^M, body=It works!, headers={
|
||||
test1, [code=200, msg=OK^M, body=It works!, headers={
|
||||
[Server] = 1.0,
|
||||
[Content-type] = text/plain,
|
||||
[Date] = July 22, 2013
|
||||
}]
|
||||
test2, [code=200, msg=OK^M, body=, headers={
|
||||
[Server] = 1.0,
|
||||
[Content-type] = text/plain,
|
||||
[Date] = July 22, 2013
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
test2, [exit_code=1, signal_exit=F, stdout=[here's something on stdout, some more stdout, last stdout], stderr=[and some stderr, more stderr, last stderr], files=<uninitialized>]
|
||||
test1, [exit_code=0, signal_exit=F, stdout=[done, exit, stop], stderr=<uninitialized>, files={
|
||||
[out1] = [insert text here, and here],
|
||||
[out2] = [insert more text here, and there]
|
||||
}]
|
||||
test2, [exit_code=1, signal_exit=F, stdout=[here's something on stdout, some more stdout, last stdout], stderr=[and some stderr, more stderr, last stderr], files=<uninitialized>]
|
||||
test4, [exit_code=0, signal_exit=F, stdout=[hibye], stderr=<uninitialized>, files=<uninitialized>]
|
||||
test5, [exit_code=0, signal_exit=F, stdout=<uninitialized>, stderr=<uninitialized>, files={
|
||||
[out4] = [test],
|
||||
[out3] = []
|
||||
}]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# @TEST-REQUIRES: which python
|
||||
# @TEST-REQUIRES: which curl
|
||||
#
|
||||
# @TEST-EXEC: btest-bg-run httpd python $SCRIPTS/httpd.py --max 1 --addr=127.0.0.1
|
||||
# @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
|
||||
|
@ -11,18 +11,32 @@
|
|||
@load base/frameworks/communication # let network-time run. otherwise there are no heartbeats...
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local req = ActiveHTTP::Request($url="127.0.0.1:32123");
|
||||
global c: count = 0;
|
||||
|
||||
when ( local resp = ActiveHTTP::request(req) )
|
||||
{
|
||||
print resp;
|
||||
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";
|
||||
terminate();
|
||||
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"]);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ function check_exit_condition()
|
|||
{
|
||||
c += 1;
|
||||
|
||||
if ( c == 3 )
|
||||
if ( c == 4 )
|
||||
terminate();
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,8 @@ event bro_init()
|
|||
# Not sure of a portable way to test signals yet.
|
||||
#test_cmd("test3", [$cmd="bash ../suicide.sh"]);
|
||||
test_cmd("test4", [$cmd="bash ../stdin.sh", $stdin="hibye"]);
|
||||
test_cmd("test5", [$cmd="bash ../empty_file.sh",
|
||||
$read_files=set("out3", "out4")]);
|
||||
}
|
||||
|
||||
@TEST-END-FILE
|
||||
|
@ -73,3 +75,9 @@ echo "nope"
|
|||
read -r line
|
||||
echo "$line"
|
||||
@TEST-END-FILE
|
||||
|
||||
@TEST-START-FILE empty_file.sh
|
||||
#! /usr/bin/env bash
|
||||
touch out3
|
||||
echo "test" > out4
|
||||
@TEST-END-FILE
|
||||
|
|
|
@ -2,13 +2,28 @@
|
|||
|
||||
import BaseHTTPServer
|
||||
|
||||
|
||||
class MyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.send_header("Content-type", "text/plain")
|
||||
self.end_headers()
|
||||
self.wfile.write("It works!")
|
||||
|
||||
if "/empty" in self.path:
|
||||
self.wfile.write("")
|
||||
else:
|
||||
self.wfile.write("It works!")
|
||||
|
||||
def do_POST(self):
|
||||
self.send_response(200)
|
||||
self.send_header("Content-type", "text/plain")
|
||||
self.end_headers()
|
||||
|
||||
if "/empty" in self.path:
|
||||
self.wfile.write("")
|
||||
else:
|
||||
self.wfile.write("It works!")
|
||||
|
||||
def version_string(self):
|
||||
return "1.0"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue