diff --git a/t/account-manager.cgi.t b/t/account-manager.cgi.t new file mode 100755 index 0000000000000000000000000000000000000000..aba7bd9e921444461164ea17022941ed78899c19 --- /dev/null +++ b/t/account-manager.cgi.t @@ -0,0 +1,78 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use English qw(-no_match_vars); +use File::Temp; +use IPC::Run qw(run); +use Test::More; + +plan tests => 2; + +$ENV{ACCOUNTMANAGER_CONFIG} = 't/manager.conf'; + +subtest start_page => sub { + + plan tests => 4; + + local $ENV{REQUEST_METHOD} = 'GET'; + local $ENV{QUERY_STRING} = ''; + + my ($out, $err, $rc) = run_executable('account-manager.cgi'); + diag($out) if $ENV{TEST_DEBUG}; + like( + $out, + qr{^Content-Type: text/html\n\n}, + 'HTTP headers' + ); + like( + $out, + qr{<title>eduGAIN Access Check</title>}, + 'page title' + ); + like( + $out, + qr{<button id="start_testing">Go on testing the service</button>}, + 'start button' + ); + is($err, '', 'empty stderr'); +}; + +subtest sp_selection_page => sub { + + plan tests => 4; + + local $ENV{REQUEST_METHOD} = 'GET'; + local $ENV{QUERY_STRING} = 'action=account_wizard'; + + my ($out, $err, $rc) = run_executable('account-manager.cgi'); + diag($out) if $ENV{TEST_DEBUG}; + like( + $out, + qr{^Content-Type: text/html\n\n}, + 'HTTP headers' + ); + like( + $out, + qr{<title>eduGAIN Access Check - Select your Service Provider</title>}, + 'page title' + ); + like( + $out, + qr{<select id="sp_entityid" name="sp_entityid" class="required">}, + 'selection list' + ); + is($err, '', 'empty stderr'); +}; + +sub run_executable { + my ($executable, $args) = @_; + + my @args = $args ? split(/\s+/, $args) : (); + run( + [ $EXECUTABLE_NAME, '-I', 'lib', 'bin/' . $executable, @args ], + \my ($in, $out, $err) + ); + return ($out, $err, $CHILD_ERROR >> 8); +}