Skip to content

Commit

Permalink
update cookie tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Jan 6, 2023
1 parent 5c811d0 commit 07758fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion t/300-controller_cookie_auth.t
Expand Up @@ -42,5 +42,5 @@ TestUtils::test_command({
TestUtils::test_command({
cmd => './script/thruk_auth',
stdin => '///____/thruk/cgi-bin/tac.cgi',
like => ['/^\/redirect\/thruk\/cgi\-bin\/login\.cgi\?thruk\/cgi\-bin\/tac\.cgi$/'],
like => ['/^\/redirect\/thruk\/cgi\-bin\/login\.cgi\?nocookie&thruk\/cgi\-bin\/tac\.cgi$/'],
});
8 changes: 6 additions & 2 deletions t/TestUtils.pm
Expand Up @@ -972,9 +972,13 @@ sub _external_request {
if($req->is_redirect and $req->{'_headers'}->{'location'} =~ m/\/thruk\/cgi\-bin\/login\.cgi\?(.*)$/mxo and defined $ENV{'THRUK_TEST_AUTH'}) {
die("login failed: ".Dumper($req)) unless $retry;
my $referer = uri_unescape($1);
$referer =~ s/^nocookie&//gmx;
$referer = '/'.$referer;
my($user, $pass) = split(/:/mx, $ENV{'THRUK_TEST_AUTH'}, 2);
my $r = _external_request($req->{'_headers'}->{'location'}, undef, undef, $agent);
$r = _external_request($req->{'_headers'}->{'location'}, undef, { password => $pass, login => $user, submit => 'login', referer => '/'.$referer }, $agent, undef, 0);
my $login_page = $req->{'_headers'}->{'location'};
my $r = _external_request($login_page, undef, undef, $agent);
$login_page =~ s/nocookie&//gmx;
$r = _external_request($login_page, undef, { password => $pass, login => $user, submit => 'login', referer => $referer }, $agent, undef, 0);
$req = _external_request($r->{'_headers'}->{'location'}, $start_to, $post, $agent, undef, 0);
}
return $req;
Expand Down
2 changes: 1 addition & 1 deletion templates/login.tt
Expand Up @@ -76,7 +76,7 @@
var val = window.location.search + window.location.hash;
val = val.replace(/\/thruk\/#/, '/thruk/');
val = val.replace(/^\?/, '');
val = val.replace(/^(logout|expired|invalid|problem|locked|setsession)&/, '');
val = val.replace(/^(logout|expired|invalid|problem|locked|setsession|nocookie)&/, '');
val = val.replace(/^\/*/, '/');
if(val != '') {
jQuery("INPUT[name='referer']").val(val);
Expand Down

0 comments on commit 07758fd

Please sign in to comment.