]>
Commit | Line | Data |
---|---|---|
a832cd59 MG |
1 | #!/usr/bin/perl |
2 | use v5.14; | |
3 | use warnings; | |
4 | ||
5 | use Test::More tests => 8; | |
6 | use Gruntmaster::Opener; | |
7 | ||
8 | my $opened; | |
9 | BEGIN { | |
10 | no warnings 'redefine'; | |
11 | *Gruntmaster::Opener::open_problem = sub { $opened = 1 }; | |
12 | } | |
13 | ||
14 | sub _test { | |
15 | my ($line, $should_open, $name) = @_; | |
16 | $line =~ s,DATE,[01/Jan/2015:00:00:00 +0200],; | |
17 | $opened = ''; | |
18 | handle_line $line; | |
19 | is $opened, $should_open, $name | |
20 | } | |
21 | ||
22 | _test '192.0.2.41 - mgv DATE "GET /pb/problem1?contest=test HTTP/1.1" 200 1234', 1, 'normal case'; | |
23 | _test '192.0.2.41 - mgv DATE "HEAD http://gruntmaster.example.org/pb/problem1?contest=test HTTP/1.0" 200 1234', 1, 'absolute url'; | |
24 | _test '2001:db8:abcd::1234 - mgv DATE "GET /pb/%61%62%63%64?%63ontes%74=%62%61%64 SPDY/3" 200 1234', 1, 'superfluous percent encoding'; | |
25 | ||
26 | _test '192.0.2.41 - mgv DATE "GET /pb/problem1?contest=test HTTP/1.1" 500 1234', '', 'internal server error'; | |
27 | _test '192.0.2.41 - - DATE "GET /pb/problem1?contest=test HTTP/1.1" 401 1234', '', 'not logged in'; | |
28 | _test '192.0.2.41 - mgv DATE "GET /pb/?contest=test HTTP/1.0" 200 1234', '', 'problem list'; | |
29 | _test '2001:db8:abcd::1234 - mgv DATE "GET /pb/asd SPDY/3" 200 1234', '', 'not in contest'; | |
30 | _test 'junk', '', 'junk'; |