Skip to content
Snippets Groups Projects
Commit 99b88a5d authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

test update

- fix expected results
- generate configuration file on-the-fly
parent d816e940
No related branches found
No related tags found
No related merge requests found
......@@ -17,5 +17,4 @@ EXTRA_DIST = \
README.md \
CHANGES.md \
t/edugain.xml \
t/manager.conf \
$(TESTS)
......@@ -8,18 +8,44 @@ use File::Temp;
use IPC::Run qw(run);
use Test::More;
plan tests => 4;
plan tests => 5;
$ENV{ACCOUNTMANAGER_CONFIG} = 't/manager.conf';
my $log = File::Temp->new(UNLINK => $ENV{TEST_DEBUG} ? 0 : 1);
diag("log file: $log") if $ENV{TEST_DEBUG};
my $has_database =
$ENV{TEST_DB_TYPE} &&
$ENV{TEST_DB_HOST} &&
$ENV{TEST_DB_NAME} &&
$ENV{TEST_DB_USER} &&
$ENV{TEST_DB_PASSWORD};
my $config = File::Temp->new(UNLINK => $ENV{TEST_DEBUG} ? 0 : 1);
print {$config} <<EOF;
[setup]
templates_dir = templates
subtest start_page => sub {
[federations]
edugain = t/edugain.xml
[app]
url = https://my.fqdn/accountmanager
support_email = support\@my.fqdn
[logger]
file = $log
level = debug
[mailer]
[idp]
[database]
type = mysql
host = localhost
name = account_manager
username = user
password = password
EOF
$config->flush();
diag("test configuration: $config") if $ENV{TEST_DEBUG};
$ENV{ACCOUNTMANAGER_CONFIG} = $config;
subtest "index page" => sub {
plan tests => 4;
......@@ -27,10 +53,9 @@ subtest start_page => sub {
local $ENV{QUERY_STRING} = '';
my ($out, $err, $rc) = run_executable('access-check-manager.cgi');
diag($out) if $ENV{TEST_DEBUG};
like(
$out,
qr{^Content-Type: text/html; charset=utf8\r\n\r\n},
qr{^Content-Type: text/html; charset=utf8\r\n\r\n}m,
'HTTP headers'
);
like(
......@@ -40,24 +65,49 @@ subtest start_page => sub {
);
like(
$out,
qr{<a href="\?action=select_sp" class="button">Get started</a>},
qr{<a href="\?action=start" class="button">Get started</a>},
'start button'
);
is($err, '', 'empty stderr');
};
subtest sp_selection_page => sub {
subtest "SP selection page, implicit federation selection" => sub {
plan tests => 4;
local $ENV{REQUEST_METHOD} = 'GET';
local $ENV{QUERY_STRING} = 'action=start';
my ($out, $err, $rc) = run_executable('access-check-manager.cgi');
like(
$out,
qr{^Content-Type: text/html; charset=utf8\r\n\r\n}m,
'HTTP headers'
);
like(
$out,
qr{<title>eduGAIN Access Check</title>},
'page title'
);
like(
$out,
qr{<select id="entityid" name="entityid" class="required">},
'page content contains SP list'
);
is($err, '', 'empty stderr');
};
subtest "SP selection page, explicit federation selection" => sub {
plan tests => 4;
local $ENV{REQUEST_METHOD} = 'GET';
local $ENV{QUERY_STRING} = 'action=select_sp';
local $ENV{QUERY_STRING} = 'action=select_sp&federation=edugain';
my ($out, $err, $rc) = run_executable('access-check-manager.cgi');
diag($out) if $ENV{TEST_DEBUG};
like(
$out,
qr{^Content-Type: text/html; charset=utf8\r\n\r\n},
qr{^Content-Type: text/html; charset=utf8\r\n\r\n}m,
'HTTP headers'
);
like(
......@@ -73,24 +123,23 @@ subtest sp_selection_page => sub {
is($err, '', 'empty stderr');
};
subtest email_selection_page_missing_parameter => sub {
subtest "email selection page, missing entityid parameter" => sub {
plan tests => 4;
local $ENV{REQUEST_METHOD} = 'GET';
local $ENV{QUERY_STRING} = 'action=select_email';
local $ENV{QUERY_STRING} = 'action=select_email&federation=edugain';
my ($out, $err, $rc) = run_executable('access-check-manager.cgi');
diag($out) if $ENV{TEST_DEBUG};
like(
$out,
qr{^Content-Type: text/html; charset=utf8\r\n\r\n},
qr{^Content-Type: text/html; charset=utf8\r\n\r\n}m,
'HTTP headers'
);
unlike(
like(
$out,
qr{<title>eduGAIN Access Check</title>},
'no page title'
'page title'
);
like(
$out,
......@@ -100,24 +149,23 @@ subtest email_selection_page_missing_parameter => sub {
is($err, '', 'empty stderr');
};
subtest email_selection_page_wrong_parameter => sub {
subtest "email selection page, invalid entityid parameter" => sub {
plan tests => 4;
local $ENV{REQUEST_METHOD} = 'GET';
local $ENV{QUERY_STRING} = 'action=select_email&entityid=foo';
local $ENV{QUERY_STRING} = 'action=select_email&federation=edugain&entityid=foo';
my ($out, $err, $rc) = run_executable('access-check-manager.cgi');
diag($out) if $ENV{TEST_DEBUG};
like(
$out,
qr{^Content-Type: text/html; charset=utf8\r\n\r\n},
qr{^Content-Type: text/html; charset=utf8\r\n\r\n}m,
'HTTP headers'
);
unlike(
like(
$out,
qr{<title>eduGAIN Access Check</title>},
'no page title'
'page title'
);
like(
$out,
......
[setup]
templates_dir = templates
federation_metadata_file = t/edugain.xml
[app]
url = https://my.fqdn/accountmanager
support_email = support@my.fqdn
[logger]
file = /dev/null
level = debug
[mailer]
sendmail_path = /bin/true
[database]
type = mysql
host = localhost
name = account_manager
user = user
password = password
[idp]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment