Bug 36598: (QA follow-up): tidy up code
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
460a48cf69
commit
13b0aa1262
|
|
@ -75,12 +75,16 @@ sub register {
|
|||
if ( $method eq 'GET' || $method eq 'HEAD' || $method eq 'OPTIONS' || $method eq 'TRACE' ) {
|
||||
my $op = $c->req->param('op');
|
||||
if ( $op && $op =~ /^cud-/ ) {
|
||||
return $c->reply->exception('Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"')->rendered(400);
|
||||
return $c->reply->exception(
|
||||
'Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"')
|
||||
->rendered(400);
|
||||
}
|
||||
} else {
|
||||
my $op = $c->req->param('op');
|
||||
if ( $op && $op !~ /^cud-/ ) {
|
||||
return $c->reply->exception('Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"')->rendered(400);
|
||||
return $c->reply->exception(
|
||||
'Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"')
|
||||
->rendered(400);
|
||||
}
|
||||
|
||||
if ( $c->cookie('CGISESSID') && !$self->is_csrf_valid( $c->req ) ) {
|
||||
|
|
|
|||
|
|
@ -43,15 +43,19 @@ subtest 'CSRF - Intranet' => sub {
|
|||
subtest 'GETting what should be POSTed should fail' => sub {
|
||||
plan tests => 3;
|
||||
|
||||
$t->get_ok('/cgi-bin/koha/mainpage.pl?op=cud-login')->status_is(400)
|
||||
->content_like( qr/Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"/, 'Body contains correct error message' );
|
||||
$t->get_ok('/cgi-bin/koha/mainpage.pl?op=cud-login')->status_is(400)->content_like(
|
||||
qr/Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"/,
|
||||
'Body contains correct error message'
|
||||
);
|
||||
};
|
||||
|
||||
subtest 'POSTing what should be GET should fail' => sub {
|
||||
plan tests => 3;
|
||||
|
||||
$t->post_ok('/cgi-bin/koha/mainpage.pl?op=login')->status_is(400)
|
||||
->content_like( qr/Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"/, 'Body contains correct error message' );
|
||||
$t->post_ok('/cgi-bin/koha/mainpage.pl?op=login')->status_is(400)->content_like(
|
||||
qr/Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"/,
|
||||
'Body contains correct error message'
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -91,14 +95,18 @@ subtest 'CSRF - OPAC' => sub {
|
|||
subtest 'GETting what should be POSTed should fail' => sub {
|
||||
plan tests => 3;
|
||||
|
||||
$t->get_ok('/cgi-bin/koha/opac-user.pl?op=cud-login')->status_is(400)
|
||||
->content_like( qr/Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"/, 'Body contains correct error message' );
|
||||
$t->get_ok('/cgi-bin/koha/opac-user.pl?op=cud-login')->status_is(400)->content_like(
|
||||
qr/Incorrect use of a safe HTTP method with an `op` parameter that starts with "cud-"/,
|
||||
'Body contains correct error message'
|
||||
);
|
||||
};
|
||||
|
||||
subtest 'POSTing what should be GET should fail' => sub {
|
||||
plan tests => 3;
|
||||
|
||||
$t->post_ok('/cgi-bin/koha/opac-user.pl?op=login')->status_is(400)
|
||||
->content_like( qr/Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"/, 'Body contains correct error message' );
|
||||
$t->post_ok('/cgi-bin/koha/opac-user.pl?op=login')->status_is(400)->content_like(
|
||||
qr/Incorrect use of an unsafe HTTP method with an `op` parameter that does not start with "cud-"/,
|
||||
'Body contains correct error message'
|
||||
);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue