7 # The test functions are placed here to make things easier
9 use DebbugsTest qw(:all);
15 # HTTP::Server:::Simple defines a SIG{CHLD} handler that breaks system; undef it here.
19 %config = create_debbugs_configuration(debug => exists $ENV{DEBUG}?$ENV{DEBUG}:0);
24 $ENV{DEBBUGS_CONFIG_FILE} = "$config{config_dir}/debbugs_config";
27 diag("spool_dir: $config{spool_dir}\n");
28 diag("config_dir: $config{config_dir}\n");
29 diag("sendmail_dir: $config{sendmail_dir}\n");
33 my $libravatar_cgi_handler = sub {
35 $ENV{DEBBUGS_CONFIG_FILE} = $config{config_dir}."/debbugs_config";
36 open($fh,'-|',-e './cgi/libravatar.cgi'? './cgi/libravatar.cgi'
37 : '../cgi/libravatar.cgi');
41 if (/^\s*$/ and $status) {
42 print "HTTP/1.1 $status OK\n";
48 if (/^Status:\s*(\d+)/i) {
58 ok(DebbugsTest::HTTPServer::fork_and_create_webserver($libravatar_cgi_handler,$port),
59 'forked HTTP::Server::Simple successfully');
62 my $ua = LWP::UserAgent->new;
63 $ua->agent("DebbugsTesting/0.1 ");
66 my $req = HTTP::Request->new(GET => "http://localhost:$port/?avatar=no");
68 my $res = $ua->request($req);
69 ok($res->is_success(),'cgi/libravatar.cgi returns success');
70 my $etag = $res->header('Etag');
72 $req = HTTP::Request->new(GET => "http://localhost:$port/?avatar=no",
73 ['If-None-Match',$etag]);
74 $res = $ua->request($req);
75 ok($res->code() eq '304','If-None-Match set gives us 304 not modified');