Permalink
Browse files

added new case option: parsewarning

  • Loading branch information...
1 parent 35b0619 commit ceef9d06edec1f1d6cf55c4f792779e004d93667 @sni committed Nov 13, 2012
View
@@ -7,6 +7,9 @@ For information and documentation, visit the website at http://www.webinject.org
---------------------------------
Release History:
+Version 1.76 - Tue Nov 13 12:46:14 CET 2012
+ - added new case option parsewarning
+
Version 1.74 - Sat May 12 13:36:48 CEST 2012
- changed html output into tables (Karsten Sievert)
- support gzipped content (Simone Tiraboschi)
View
@@ -31,7 +31,7 @@ use Error qw(:try); # for web services verification (you may comment
use Data::Dumper; # dump hashes for debugging
use File::Temp qw/ tempfile /; # create temp files
-our $VERSION = '1.74';
+our $VERSION = '1.76';
=head1 NAME
@@ -309,12 +309,13 @@ sub _run_test_case {
confess("no testcase!") unless defined $case;
- $case->{'id'} = 1 unless defined $case->{'id'};
- $case->{'passedcount'} = 0;
- $case->{'failedcount'} = 0;
- $case->{'iswarning'} = 0;
- $case->{'iscritical'} = 0;
- $case->{'messages'} = [];
+ # set some defaults
+ $case->{'id'} = 1 unless defined $case->{'id'};
+ $case->{'passedcount'} = 0;
+ $case->{'failedcount'} = 0;
+ $case->{'iswarning'} = 0;
+ $case->{'iscritical'} = 0;
+ $case->{'messages'} = [];
$useragent = $self->_get_useragent() unless defined $useragent;
@@ -1237,7 +1238,7 @@ sub _parseresponse {
$self->{'parsedresult'}->{$type} = $1;
}
## use critic
- else {
+ elsif(!defined $case->{'parsewarning'} or $case->{'parsewarning'}) {
push @{$case->{'messages'}}, {'key' => $type.'-success', 'value' => 'false', 'html' => "<span class=\"fail\">Failed Parseresult, cannot find</span> $leftboundary(.*?)$rightboundary" };
$self->_out("Failed Parseresult, cannot find $leftboundary(*)$rightboundary\n");
$case->{'iswarning'} = 1;
@@ -15,7 +15,7 @@ if($ENV{TEST_AUTHOR}) {
plan skip_all => 'HTTP::Server::Simple::CGI required';
}
else{
- plan tests => 44;
+ plan tests => 50;
}
}
else{
@@ -35,7 +35,9 @@ TestWebServer->start_webserver();
# start our test cases
test_case_01();
test_case_02();
-test_case_03();
+test_case_03_1();
+test_case_03_2();
+test_case_03_3();
test_case_04();
test_case_05();
test_case_06();
@@ -74,8 +76,8 @@ sub test_case_02 {
}
##################################################
-# Test File 03
-sub test_case_03 {
+# Test File 03 - 1
+sub test_case_03_1 {
@ARGV = ($Bin."/data/03-parse_response.xml");
my $webinject = Webinject->new();
$webinject->{'config'}->{'baseurl'} = 'http://localhost:58080';
@@ -86,6 +88,30 @@ sub test_case_03 {
}
##################################################
+# Test File 03 - 2
+sub test_case_03_2 {
+ @ARGV = ($Bin."/data/03-parse_response2.xml");
+ my $webinject = Webinject->new();
+ $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080';
+ my $rc = $webinject->engine();
+ is($webinject->{'result'}->{'totalpassedcount'}, 1, '03-parse_response2.xml - passed count');
+ is($webinject->{'result'}->{'totalfailedcount'}, 0, '03-parse_response2.xml - fail count');
+ is($rc, 1, '03-parse_response.xml - return code');
+}
+
+##################################################
+# Test File 03 - 3
+sub test_case_03_3 {
+ @ARGV = ($Bin."/data/03-parse_response3.xml");
+ my $webinject = Webinject->new();
+ $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080';
+ my $rc = $webinject->engine();
+ is($webinject->{'result'}->{'totalpassedcount'}, 1, '03-parse_response2.xml - passed count');
+ is($webinject->{'result'}->{'totalfailedcount'}, 0, '03-parse_response2.xml - fail count');
+ is($rc, 0, '03-parse_response.xml - return code');
+}
+
+##################################################
# Test File 04
sub test_case_04 {
@ARGV = ($Bin."/data/04-repeated_tests.xml");
@@ -0,0 +1,10 @@
+<testcases repeat="1">
+<case
+ id = "1"
+ description1 = "test parse response warning"
+ method = "get"
+ url = "{BASEURL}/teststring"
+ verifyresponsecode = "200"
+ parseresponse = "HTTP|NOTFOUND"
+/>
+</testcases>
@@ -0,0 +1,11 @@
+<testcases repeat="1">
+<case
+ id = "1"
+ description1 = "test parse response no warning"
+ method = "get"
+ url = "{BASEURL}/teststring"
+ verifyresponsecode = "200"
+ parseresponse = "HTTP|NOTFOUND"
+ parsewarning = "0"
+/>
+</testcases>

0 comments on commit ceef9d0

Please sign in to comment.