PSGI tests in progress... (#583)

environments/ppa-mbqj77/deployments/1
Xavier Guimard 9 years ago
parent 8aa41789a9
commit feee76e5bd
  1. 2
      lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t
  2. 96
      lemonldap-ng-handler/t/lmConf-1
  3. 57
      lemonldap-ng-handler/t/lmConf-1.js
  4. 56
      lemonldap-ng-handler/t/test-psgi-lib.pm

@ -6,4 +6,6 @@ use strict;
require 't/test-psgi-lib.pm';
init('Lemonldap::NG::Handler::PSGI');
done_testing( count() );

@ -1,96 +0,0 @@
applicationList
'$data1 = {'1sample' => { catname => 'Sample applications',type => 'category', 'test1' => { type => 'application', options => { name => 'Application Test 1', uri => 'http://test1.example.com/', description => 'A simple application displaying authenticated user', logo => 'demo.png', display => 'auto', }, },'test2' => { type => 'application', options => { name => 'Application Test 2', uri => 'http://test2.example.com/', description => 'The same simple application displaying authenticated user', logo => 'thumbnail.png', display => 'auto', }, }, },'2administration' => { catname => 'Administration', type => 'category', 'manager' => { type => 'application', options => { name => 'WebSSO Manager', uri => 'http://manager.example.com/', description => 'Configure LemonLDAP::NG WebSSO', logo => 'configure.png', display => 'auto', }, },'sessions' => { type => 'application', options => { name => 'Sessions explorer', uri => 'http://manager.example.com/sessions.pl', description => 'Explore WebSSO sessions', logo => 'database.png', display => 'auto', }, }, 'notifications' => { type => 'application', options => { name => 'Notifications explorer', uri => 'http://manager.example.com/notifications.pl', description => 'Explore WebSSO notifications', logo => 'database.png', display => 'auto', }, }, }, '3documentation' => { catname => 'Documentation', type => 'category', 'localdoc' => { type => 'application', options => { name => 'Local documentation', uri => 'http://manager.example.com/doc/', description => 'Documentation supplied with LemonLDAP::NG', logo => 'help.png', display => 'on', }, },'officialwebsite' => { type => 'application', options => { name => 'Offical Website', uri => 'http://lemonldap-ng.org/', description => 'Official LemonLDAP::NG Website', logo => 'network.png', display => 'on', }, }, }, }'
authentication
'Demo'
cfgAuthor
'The LemonLDAP::NG team'
cfgNum
1
cookieName
'lemonldap'
demoExportedVars
'$data1 = {'uid' => 'uid','cn' => 'cn','mail' => 'mail'};'
domain
'example.com'
exportedHeaders
'$data1 = {'test2.example.com' => {'Auth-User' => '$uid'},'test1.example.com' => {'Auth-User' => '$uid'}};'
exportedVars
'$data1 = {'UA' => 'HTTP_USER_AGENT'};'
globalStorage
'Apache::Session::File'
globalStorageOptions
'$data1 = {'Directory' => '/tmp/'};'
groups
'$data1 = {};'
key
'qwertyui'
locationRules
'$data1 = {'test2.example.com' => {'default' => 'accept','^/logout' => 'logout_sso'},'test1.example.com' => {'default' => 'accept','^/logout' => 'logout_sso'},'manager.example.com' => {'default' => '$uid eq "dwho"'}};'
loginHistoryEnabled
1
macros
'$data1 = {'_whatToTrace' => '$_auth eq \'SAML\' ? "$_user\\@$_idpConfKey" : "$_user"'};'
notification
1
notificationStorage
'File'
notificationStorageOptions
'$data1 = {'dirName' => 'e2e-tests/conf/'};'
passwordDB
'Demo'
persistentStorage
'Apache::Session::File'
persistentStorageOptions
'$data1 = {'Directory' => '/tmp/'};'
portal
'http://auth.example.com/'
registerDB
'Null'
reloadUrls
'$data1 = {'reload.example.com' => 'http://reload.example.com/reload'};'
securedCookie
0
sessionDataToRemember
'$data1 = {};'
timeout
72000
userDB
'Demo'
whatToTrace
'$_whatToTrace'
captcha_data
'e2e-tests/conf/'
captcha_output
'e2e-tests/conf/'

@ -0,0 +1,57 @@
{
"authentication": "Demo",
"cfgAuthor": "The LemonLDAP::NG team",
"cfgAuthorIP": "127.0.0.1",
"cfgDate": 1428138808,
"cfgLog": "Handler test conf",
"cfgNum": "1",
"cookieName": "lemonldap",
"demoExportedVars": {
"cn": "cn",
"mail": "mail",
"uid": "uid"
},
"domain": "example.com",
"exportedHeaders": {
"test1.example.com": {
"Auth-User": "$uid"
},
"test2.example.com": {
"Auth-User": "$uid"
}
},
"exportedVars": {
"UA": "HTTP_USER_AGENT"
},
"globalStorage": "Apache::Session::File",
"globalStorageOptions": {
"Directory": "t/tmp",
"LockDirectory": "t/tmp/lock",
"generateModule": "Lemonldap::NG::Common::Apache::Session::Generate::SHA256"
},
"groups": {},
"key": "qwertyui",
"locationRules": {
"manager.example.com": {
"(?#Configuration)^/(manager\\.html|conf/)": "$uid eq \"dwho\"",
"(?#Notifications)^/notifications": "$uid eq \"dwho\" or $uid eq \"rtyler\"",
"(?#Sessions)^/sessions": "$uid eq \"dwho\" or $uid eq \"rtyler\"",
"default": "$uid eq \"dwho\""
},
"test1.example.com": {
"^/logout": "logout_sso",
"default": "accept"
},
"test2.example.com": {
"^/logout": "logout_sso",
"default": "accept"
}
},
"macros": {
"_whatToTrace": "$_auth eq 'SAML' ? \"$_user\\@$_idpConfKey\" : \"$_user\""
},
"portal": "http://auth.example.com/",
"reloadUrls": {},
"userDB": "Demo",
"whatToTrace": "_whatToTrace"
}

@ -6,26 +6,62 @@ use 5.10.0;
use_ok('Lemonldap::NG::Common::PSGI::Cli::Lib');
our $client;
our $count = 1;
ok(
$client = Lemonldap::NG::Common::PSGI::Cli::Lib->new(
app => sub {
return Lemonldap::NG::Handler::PSGI->run(configStorage => { type => 'File', dirName => 't' });
}
),
'Client object'
);
sub init {
my $module = shift;
ok(
$client = Lemonldap::NG::Handler::PSGI::Cli::Lib->new(
app => sub {
return $module->run(
configStorage => { type => 'File', dirName => 't' } );
}
),
'Client object'
);
count(1);
}
sub client {
return $client;
}
our $count = 2;
sub count {
my $c = shift;
$count += $c if ($c);
return $count;
}
package Lemonldap::NG::Handler::PSGI::Cli::Lib;
use Mouse;
extends 'Lemonldap::NG::Common::PSGI::Cli::Lib';
sub _get {
my ( $self, $path, $query, $host, $cookie ) = @_;
$query //= '';
$host ||= 'test1.example.com';
return $self->app->(
{
'HTTP_ACCEPT' => 'text/html',
'SCRIPT_NAME' => 'lmAuth',
'SERVER_NAME' => '127.0.0.1',
'QUERY_STRING' => $query,
'HTTP_CACHE_CONTROL' => 'max-age=0',
'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
'PATH_INFO' => $path,
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => $path . ( $query ? "?$query" : '' ),
'SERVER_PORT' => '8002',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'HTTP_USER_AGENT' =>
'Mozilla/5.0 (VAX-4000; rv:36.0) Gecko/20350101 Firefox',
'REMOTE_ADDR' => '127.0.0.1',
'HTTP_HOST' => '127.0.0.1:8002',
( $cookie ? ( HTTP_COOKIE => $cookie ) : () )
}
);
}
1;

Loading…
Cancel
Save