| 1 | #!perl -w |
| 2 | |
| 3 | use strict; |
| 4 | |
| 5 | use File::Spec; |
| 6 | use Test::More; |
| 7 | |
| 8 | BEGIN |
| 9 | { |
| 10 | my $skip_file = File::Spec->catfile( qw( t conf skip ) ); |
| 11 | |
| 12 | if ( -f $skip_file ) |
| 13 | { |
| 14 | plan skip_all => 'You must have the apreq2 module to run these tests with apache2.'; |
| 15 | } |
| 16 | else |
| 17 | { |
| 18 | plan tests => 6; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | use Apache::Test qw(:withtestmore); |
| 23 | use Apache::TestUtil; |
| 24 | use Apache::TestRequest qw(GET); |
| 25 | |
| 26 | my $ua = Apache::TestRequest::user_agent( cookie_jar => {} ); |
| 27 | |
| 28 | { |
| 29 | my $res = GET '/TestApache__basic'; |
| 30 | ok( $res->is_success, 'request succeeded' ); |
| 31 | ok( $res->header('set-cookie'), 'response includes cookie' ); |
| 32 | |
| 33 | my ($cookie_val1) = ( $res->header('set-cookie') =~ m{asw_cookie=([^;]+);} ); |
| 34 | |
| 35 | $res = GET '/TestApache__basic'; |
| 36 | $res->header('set-cookie') =~ m{asw_cookie=([^;]+);}; |
| 37 | my ($cookie_val2) = ( $res->header('set-cookie') =~ m{asw_cookie=([^;]+);} ); |
| 38 | |
| 39 | is( $cookie_val1, $cookie_val2, 'got the same cookie for each request' ); |
| 40 | unlike( $res->content, qr/ERROR/, 'no error message in response' ); |
| 41 | } |
| 42 | |
| 43 | { |
| 44 | my $res = GET '/TestApache__basic?delete=1'; |
| 45 | like( $res->header('set-cookie'), qr/asw_cookie=(?:;|\z)/, |
| 46 | 'no value in cookie when deleting' ); |
| 47 | unlike( $res->content, qr/ERROR/, 'no error message in response' ); |
| 48 | } |