line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: StatusTest.pm,v 1.9 2003/03/02 11:52:09 m_ilya Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTTP::WebTest::Plugin::StatusTest; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
HTTP::WebTest::Plugin::StatusTest - Checks the HTTP response status |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Not Applicable |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This plugin checks the HTTP response status. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
10
|
|
|
10
|
|
61
|
use strict; |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
459
|
|
20
|
|
|
|
|
|
|
|
21
|
10
|
|
|
10
|
|
113
|
use base qw(HTTP::WebTest::Plugin); |
|
10
|
|
|
|
|
36
|
|
|
10
|
|
|
|
|
940
|
|
22
|
|
|
|
|
|
|
|
23
|
10
|
|
|
10
|
|
58
|
use HTTP::Status; |
|
10
|
|
|
|
|
35
|
|
|
10
|
|
|
|
|
6093
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 TEST PARAMETERS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=for pod_merge copy params |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 status_code |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Given numeric HTTP Status Code, tests response returned that value. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head3 Default value |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
C<200> (OK). |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub param_types { |
40
|
190
|
|
|
190
|
1
|
2032
|
return q(status_code scalar); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub check_response { |
44
|
190
|
|
|
190
|
0
|
409
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
190
|
|
|
|
|
1247
|
$self->validate_params(qw(status_code)); |
47
|
|
|
|
|
|
|
|
48
|
190
|
|
|
|
|
831
|
my $code = $self->webtest->current_response->code; |
49
|
190
|
|
|
|
|
2308
|
my $status_line = $self->webtest->current_response->status_line; |
50
|
|
|
|
|
|
|
|
51
|
190
|
|
|
|
|
2819
|
my $expected_code = $self->test_param('status_code', RC_OK); |
52
|
190
|
|
|
|
|
545
|
my $ok = $code eq $expected_code; |
53
|
|
|
|
|
|
|
|
54
|
190
|
|
|
|
|
1040
|
my $comment = "Expected '$expected_code' and got: " . $status_line; |
55
|
|
|
|
|
|
|
|
56
|
190
|
|
|
|
|
1127
|
return ['Status code check', $self->test_result($ok, $comment)]; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 COPYRIGHT |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Copyright (c) 2000-2001 Richard Anderson. All rights reserved. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Copyright (c) 2001-2003 Ilya Martynov. All rights reserved. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
66
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SEE ALSO |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
L |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
L |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |