Debian tests

This commit is contained in:
Xavier Guimard 2009-12-03 10:08:33 +00:00
parent 4c1574e034
commit 061994cfcc
12 changed files with 101 additions and 54 deletions

View File

@ -501,6 +501,7 @@ debian-packages: debian-dist
mv lemonldap-ng_$(VERSION).orig.tar.gz /tmp/
version=$(VERSION) && \
cd /tmp/ && \
rm -rf lemonldap-ng-$$version && \
tar xzf lemonldap-ng_$$version.orig.tar.gz && \
cd lemonldap-ng-$$version && \
debuild

View File

@ -1,4 +1,4 @@
debian/tmp/etc/lemonldap-ng/storage.conf
debian/tmp/etc/lemonldap-ng/lemonldap-ng.ini
debian/tmp/etc/lemonldap-ng/for_etc_hosts
debian/tmp/usr/share/perl5/Lemonldap/NG/Common*
debian/tmp/usr/share/man/man3/Lemonldap::NG::Common*

View File

@ -12,8 +12,8 @@ then
chown -R www-data:www-data /var/lib/lemonldap-ng/conf
chmod 750 /var/lib/lemonldap-ng/conf
chmod 640 /var/lib/lemonldap-ng/conf/*
chgrp www-data /etc/lemonldap-ng/storage.conf
chmod 640 /etc/lemonldap-ng/storage.conf
chgrp www-data /etc/lemonldap-ng/lemonldap-ng.ini
chmod 640 /etc/lemonldap-ng/lemonldap-ng.ini
for i in domain ldapServer ldapPort ldapBase managerDn managerPassword portal; do
db_get liblemonldap-ng-conf-perl/$i || true

View File

@ -19,7 +19,7 @@ configure-stamp:
dh_testdir
# Add here commands to configure the package.
$(MAKE) configure STORAGECONFFILE=/etc/lemonldap-ng/storage.conf \
$(MAKE) configure STORAGECONFFILE=/etc/lemonldap-ng/lemonldap-ng.ini \
PERLOPTIONS="INSTALLDIRS=vendor"
touch configure-stamp
@ -63,7 +63,7 @@ install: build
PORTALSKINSDIR=$(LMSHAREDIR)portal-skins/ \
MANAGERDATADIR=$(LMSHAREDIR)manager-imgs/ \
SESSIONSEXPLORERDATADIR=$(LMSHAREDIR)sessions-explorer-imgs/ \
STORAGECONFFILE=/etc/lemonldap-ng/storage.conf \
STORAGECONFFILE=/etc/lemonldap-ng/lemonldap-ng.ini \
TOOLSDIR=$(LMSHAREDIR)ressources/ \
CONFDIR=/etc/lemonldap-ng/ \
CRONDIR=/etc/cron.d/ \

View File

@ -21,11 +21,53 @@
;cda = 1
[configuration]
# Global configuration access type (File, SOAP, DBI, LDAP)
# GLOBAL CONFIGURATION ACCESS TYPE
# (File, SOAP, DBI, LDAP)
# Set here the parameters needed to access to Lemonldap::NG configuration.
# You have to set "type" to one of the followings :
#
# * File: you have to set 'dirName' parameter. Example:
#
# type = File
# dirName = /var/lib/lemonldap-ng/conf
#
# * DBI : you have to set 'dbiChain' (required) and 'dbiUser' and 'dbiPassword'
# if needed. Example:
#
# type = DBI
# dbiChain = DBI:mysql:database=lemonldap-ng;host=1.2.3.4
# dbiUser = lemonldap
# dbiPassword = password
#
# * SOAP: SOAP configuration access is a sort of proxy: the portal is
# configured to use the real session storage type (DBI or File for
# example).
# You have to set 'proxy' parameter. Example:
#
# type = SOAP
# proxy = https://auth.example.com/index.pl/config
# proxyOptions = { timeout => 5 }
# User = lemonldap
# Password = mypassword
#
# * LDAP: you have to set ldapServer, ldapConfBranch, ldapBindDN and ldapBindPassword.
#
# type = LDAP
# ldapServer = ldap://localhost
# ldapConfBase = ou=conf,ou=applications,dc=example,dc=com
# ldapBindDN = cn=manager,dc=example,dc=com
# ldapBindPassword = secret
type = File
dirName = /var/lib/lemonldap-ng/conf
# Configuration cache
# LOCAL CACHE CONFIGURATION
#
# To increase performances, use a local cache for the configuration. You have
# to choose a Cache::Cache module and set it's parameters (1 line). Example:
#
# localStorage = Cache::FileCache
# localStorageOptions = { 'namespace' => 'MyNamespace', 'default_expires_in' => 600, 'directory_umask' => '007', 'cache_root' => '/tmp', 'cache_depth' => 5, }
localStorage = Cache::FileCache
localStorageOptions = { 'namespace' => 'MyNamespace', 'default_expires_in' => 600, 'directory_umask' => '007', 'cache_root' => '/tmp', 'cache_depth' => 5, }

View File

@ -9,8 +9,9 @@ package Lemonldap::NG::Common::Conf;
use strict;
no strict 'refs';
use Lemonldap::NG::Common::Conf::Constants; #inherits
use Lemonldap::NG::Common::Crypto; #link protected cipher Object "cypher" in configuration hash
use Lemonldap::NG::Common::Conf::Constants; #inherits
use Lemonldap::NG::Common::Crypto
; #link protected cipher Object "cypher" in configuration hash
use Regexp::Assemble;
use Config::IniFiles;
@ -26,7 +27,7 @@ our $msg;
# Constructor.
# Succeed if it has found a way to access to Lemonldap::NG configuration with
# $arg (or default file). It can be :
# - Nothing: default configuration file is tested,
# - Nothing: default configuration file is tested,
# - { confFile => "/path/to/storage.conf" },
# - { Type => "File", dirName => "/path/to/conf/dir/" },
# - { Type => "DBI", dbiChain => "DBI:mysql:database=lemonldap-ng;host=1.2.3.4",
@ -46,15 +47,17 @@ sub new {
%$self = %{ $_[0] };
}
else {
if ( defined @_ && $#_%2 == 1 ) {
if ( defined @_ && $#_ % 2 == 1 ) {
%$self = @_;
}
}
unless ( $self->{mdone} ) {
unless ( $self->{type} ) {
# Use local conf to get configStorage and localStorage
my $localconf = $self->getLocalConf( CONFSECTION, $self->{confFile}, 0 );
if ( defined $localconf ) {
my $localconf =
$self->getLocalConf( CONFSECTION, $self->{confFile}, 0 );
if ( defined $localconf ) {
%$self = ( %$self, %$localconf );
}
}
@ -135,9 +138,9 @@ sub getConf {
}
else {
$r = $self->{refLocalStorage}->get('conf');
if ( $r->{cfgNum} == $args->{cfgNum} ) {
$msg = "configuration unchanged, get configuration from cache";
}
if ( $r->{cfgNum} == $args->{cfgNum} ) {
$msg = "configuration unchanged, get configuration from cache";
}
else {
$r = $self->getDBConf($args);
}
@ -172,47 +175,48 @@ sub getLocalConf {
my ( $self, $section, $file, $loaddefault ) = @_;
my $r;
$section ||= DEFAULTSECTION;
$file ||= DEFAULTCONFFILE;
$section ||= DEFAULTSECTION;
$file ||= DEFAULTCONFFILE;
$loaddefault = 1 unless ( defined $loaddefault );
# If default configuration cannot be read
# - Error if configuration section is requested
# - Silent exit for other section requests
unless ( -r $file ) {
if ( $section eq CONFSECTION) {
if ( $section eq CONFSECTION ) {
$msg = "Cannot read $file to get configuration access parameters";
return 0;
}
return $r;
return $r;
}
# Parse ini file
print STDERR Dumper(\%INC);use Data::Dumper;
my $cfg = Config::IniFiles->new(
-file => $file,
-allowempty => 1,
-file => $file,
-allowempty => 1,
);
unless ( defined $cfg ) {
$msg = "Local config error: ".@Config::IniFiles::errors;
$msg = "Local config error: " . @Config::IniFiles::errors;
return 0;
}
# Check if default section exists
unless ( $cfg->SectionExists( DEFAULTSECTION ) ) {
$msg = "Default section (".DEFAULTSECTION.") is missing";
unless ( $cfg->SectionExists(DEFAULTSECTION) ) {
$msg = "Default section (" . DEFAULTSECTION . ") is missing";
return 0;
}
# Check if configuration section exists
if ( $section eq CONFSECTION and !$cfg->SectionExists( CONFSECTION ) ) {
$msg = "Configuration section (".CONFSECTION.") is missing";
if ( $section eq CONFSECTION and !$cfg->SectionExists(CONFSECTION) ) {
$msg = "Configuration section (" . CONFSECTION . ") is missing";
return 0;
}
# First load all default section parameters
if ( $loaddefault ) {
foreach ($cfg->Parameters( DEFAULTSECTION )) {
if ($loaddefault) {
foreach ( $cfg->Parameters(DEFAULTSECTION) ) {
$r->{$_} = $cfg->val( DEFAULTSECTION, $_ );
if ( $r->{$_} =~ /^[{\[].*[}\]]$/ ) {
eval "\$r->{$_} = $r->{$_}";
@ -228,10 +232,10 @@ sub getLocalConf {
return $r if ( $section eq DEFAULTSECTION );
# Check if requested section exists
return 0 unless $cfg->SectionExists( $section );
return 0 unless $cfg->SectionExists($section);
# Load section parameters
foreach ($cfg->Parameters( $section )) {
foreach ( $cfg->Parameters($section) ) {
$r->{$_} = $cfg->val( $section, $_ );
if ( $r->{$_} =~ /^[{\[].*[}\]]$/ ) {
eval "\$r->{$_} = $r->{$_}";

View File

@ -13,7 +13,7 @@ BEGIN { use_ok('Lemonldap::NG::Common::CGI') }
use base ('Lemonldap::NG::Common::CGI');
sub subtest {
sub mySubtest {
return 'OK1';
}
@ -75,9 +75,9 @@ ok( $buf =~ /Cache-control: public; must-revalidate; max-age=\d+\r?\n/s,
ok( $buf =~ /Last-modified: /s, 'Last-Modified' );
# Test _sub mechanism
ok( $cgi->_sub('subtest') eq 'OK1', '_sub mechanism 1' );
$cgi->{subtest} = sub { return 'OK2' };
ok( $cgi->_sub('subtest') eq 'OK2', '_sub mechanism 2' );
ok( $cgi->_sub('mySubtest') eq 'OK1', '_sub mechanism 1' );
$cgi->{mySubtest} = sub { return 'OK2' };
ok( $cgi->_sub('mySubtest') eq 'OK2', '_sub mechanism 2' );
# SOAP
SKIP: {

View File

@ -43,7 +43,7 @@ our (
$whatToTrace, $https, $refLocalStorage,
$safe, $port, $statusPipe,
$statusOut, $customFunctions, $transform,
$cda, $safe,
$cda,
);
##########################################
@ -341,7 +341,7 @@ sub safe {
#no strict 'refs';
#return ${"$class\::safe"} if (${"$class\::safe"});
return $safe if($safe);
$class->lmLog( "Compiling safe jail for $class", 'debug' );
#$class->lmLog( "Compiling safe jail for $class", 'debug' );
#my $safe = new Safe;
$safe = new Safe;
my @t = $customFunctions ? split( /\s+/, $customFunctions ) : ();

View File

@ -5,14 +5,18 @@
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 2;
BEGIN { use_ok('Lemonldap::NG::Handler::CGI') }
use Test::More tests => 1;
BEGIN {
use_ok('Lemonldap::NG::Handler::CGI');
sub Lemonldap::NG::Handler::CGI::lmLog {}
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
__END__
my $p;
# CGI Environment
@ -26,8 +30,7 @@ ok(
$p = Lemonldap::NG::Handler::CGI->new(
{
configStorage => {
type => "File",
dirName => '/tmp/',
confFile => 'undefined.xx',
},
https => 0,
portal => 'http://auth.example.com',

View File

@ -27,19 +27,11 @@ sub extractFormInfo {
return PE_FORMEMPTY
unless (
(
( length( $self->{'user'} = $self->param('user') ) > 0 )
&& (
(
length( $self->{'password'} = $self->param('password') ) > 0
)
|| (
length(
$self->{'newpassword'} = $self->param('newpassword')
) > 0
)
)
( $self->{'user'} = $self->param('user') )
&& ( ( $self->{'password'} = $self->param('password') )
|| ( $self->{'newpassword'} = $self->param('newpassword') ) )
)
|| ( length( $self->{'mail'} = $self->param('mail') ) > 0 )
|| ( $self->{'mail'} = $self->param('mail') )
);
$self->{'oldpassword'} = $self->param('oldpassword');
$self->{'confirmpassword'} = $self->param('confirmpassword');

View File

@ -49,6 +49,8 @@ ok(
ok( $p->{test}, 'Authentication arguments' );
# Process test: first access
$ENV{REQUEST_URI} = '/?user=&password=';
$ENV{QUERY_STRING} = 'user=&password=';
ok( $p->process == 0, 'No user' );
ok( $p->{error} == PE_FIRSTACCESS, 'Error code: first access' );

View File

@ -8,7 +8,10 @@
package My::Portal;
use strict;
use Test::More tests => 16;
BEGIN { use_ok( 'Lemonldap::NG::Portal::Simple', ':all' ) }
BEGIN {
use_ok( 'Lemonldap::NG::Portal::Simple', ':all' );
sub Lemonldap::NG::Portal::Simple::lmLog {}
}
#use Lemonldap::NG::Portal::Simple;