Skip to content

Commit

Permalink
login: add test case for login redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Aug 5, 2024
1 parent 1e9d86f commit ce235ca
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion t/scenarios/auth/t/100-auth.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use strict;
use Test::More;

BEGIN {
plan tests => 317;
plan tests => 362;

use lib('t');
require TestUtils;
Expand Down Expand Up @@ -212,3 +212,34 @@ BEGIN {
'location' => 'login.cgi\?nocookie&demo/thruk/cgi-bin/extinfo.cgi&type=2&host=localhost',
);
};

# check redirect from login page when already logged in
{
local $ENV{'THRUK_TEST_AUTH'} = 'test:test';
TestUtils::test_page(
'url' => '/thruk/cgi-bin/user.cgi',
'like' => ['>User<.*?>test<', 'none'],
);
local $ENV{'THRUK_TEST_AUTH'} = undef;

# still logged in?
TestUtils::test_page(
'url' => '/thruk/cgi-bin/user.cgi',
'like' => ['>User<.*?>test<', 'none'],
);

# redirect from login page when already got a session id
TestUtils::test_page(
'url' => '/thruk/cgi-bin/login.cgi?demo/thruk/cgi-bin/tac.cgi',
'redirect' => 1,
'location' => '/demo/thruk/cgi-bin/tac.cgi',
);

# logout
TestUtils::test_page(
'url' => '/thruk/cgi-bin/login.cgi?logout',
'like' => ['logout successful'],
'follow' => 1,
'code' => 401,
);
};

0 comments on commit ce235ca

Please sign in to comment.