First running test (#595)

This commit is contained in:
Xavier Guimard 2016-04-03 16:27:13 +00:00
parent 13051ce0af
commit 1a16c2dbc8
8 changed files with 116 additions and 5 deletions

View File

@ -36,7 +36,7 @@ our $_v = { session => {}, datas => {} };
BEGIN {
# Thread shared accessors
foreach (
qw(tsv cfgNum lastCheck checkTime confAcc localConfig logLevel _logLevel logLevels)
qw(tsv cfgNum lastCheck checkTime confAcc localConfig logLevel _logLevel logLevels lmConf)
)
{
eval " sub $_ {

View File

@ -1,5 +1,3 @@
#!/usr/bin/env perl -I pl/lib
#
# Test REST API with valid and invalid requests.
# Check also metadatas request (root of a conf)

View File

@ -9,7 +9,6 @@ extends(
'Lemonldap::NG::Handler::PSGI::Try',
'Lemonldap::NG::Portal::Main::Init',
'Lemonldap::NG::Portal::Main::Run',
'Lemonldap::NG::Portal::Main::Process',
);
1;

View File

@ -14,6 +14,8 @@ use Mouse;
use Lemonldap::NG::Portal::Main::Constants;
use Lemonldap::NG::Portal::Main::Request;
extends 'Lemonldap::NG::Portal::Main::Process';
our $VERSION = '2.0.0';
# List constants

View File

@ -14,7 +14,7 @@ sub changeUrldc {
my $urldc = $req->datas->{urldc};
if ( $req->id
and $urldc !~ m#^https?://[^/]*$self->{conf}->{domain}(:\d+)?/#oi
and $self->isTrustedUrl($urldc) )
and $self->p->isTrustedUrl($urldc) )
{
my $ssl = $urldc =~ /^https/;
$self->lmLog( 'CDA request', 'debug' );

View File

@ -0,0 +1,8 @@
use Test::More;
use strict;
require 't/test-lib.pm';
print STDERR Dumper(&client);
done_testing( count() );

View File

@ -0,0 +1,58 @@
{
"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/sessions",
"LockDirectory": "t/sessions/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",
"^/deny": "deny",
"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"
}

View File

@ -0,0 +1,46 @@
# Base library for portal tests
use strict;
use Data::Dumper;
use 5.10.0;
use_ok('Lemonldap::NG::Common::PSGI::Cli::Lib');
use_ok('Lemonldap::NG::Portal::Main');
our $client;
our $count = 3;
$Data::Dumper::Deparse = 1;
ok(
$client = Lemonldap::NG::Common::PSGI::Cli::Lib->new(
{
app => Lemonldap::NG::Portal::Main->run(
{
configStorage => { type => 'File', dirName => 't' },
logLevel => 'warn',
cookieName => 'lemonldap',
securedCookie => 0,
https => 0,
}
),
}
),
'Portal app'
);
sub client {
return $client;
}
sub count {
my $c = shift;
$count += $c if ($c);
return $count;
}
sub explain {
my ( $get, $ref ) = @_;
$get = Dumper($get) if ( ref $get );
print STDERR "Expect $ref, get $get\n";
}
1;