From 859be3923fcaa292486e6f98f0b3bae40a366841 Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Wed, 25 Feb 2009 18:10:07 +0000 Subject: [PATCH] * Doxygen doc update * More tests * perltidy on tests --- build/lemonldap-ng/debian/control | 9 +- modules/lemonldap-ng-common/META.yml | 1 + modules/lemonldap-ng-common/Makefile.PL | 1 + .../lib/Lemonldap/NG/Common/CGI.pm | 18 ++-- .../lib/Lemonldap/NG/Common/CGI/SOAPServer.pm | 2 + .../t/02-Common-Conf-File.t | 8 +- .../t/03-Common-Conf-DBI.t | 12 +-- .../t/04-Common-Conf-SOAP.t | 12 +-- modules/lemonldap-ng-common/t/10-Common.t | 2 +- modules/lemonldap-ng-common/t/20-Common-CGI.t | 67 +++++++++++++-- .../lib/Lemonldap/NG/Handler/AuthBasic.pm | 2 +- .../lib/Lemonldap/NG/Handler/CDA.pm | 2 +- .../lib/Lemonldap/NG/Handler/CGI.pm | 2 +- .../t/11-Lemonldap-NG-Handler-Status.t | 11 ++- .../t/30-Lemonldap-NG-Handler-CGI.t | 6 +- .../lib/Lemonldap/NG/Manager.pm | 2 +- .../lib/Lemonldap/NG/Manager/Sessions.pm | 16 ++-- modules/lemonldap-ng-manager/t/10-Manager.t | 12 +-- .../lemonldap-ng-manager/t/20-Manager-i18n.t | 6 +- .../t/50-Manager-SOAPServer.t | 20 +++-- modules/lemonldap-ng-portal/MANIFEST | 1 + modules/lemonldap-ng-portal/META.yml | 1 + .../lib/Lemonldap/NG/Portal/AuthApache.pm | 2 +- .../lib/Lemonldap/NG/Portal/CDA.pm | 7 -- .../lib/Lemonldap/NG/Portal/SharedConf.pm | 6 +- .../lib/Lemonldap/NG/Portal/Simple.pm | 3 + .../lib/Lemonldap/NG/Portal/_SOAP.pm | 14 ++-- .../t/04-Lemonldap-NG-Portal-SOAP.t | 84 +++++++++++++++++++ .../t/24-Lemonldap-NG-Portal-AuthRemote.t | 23 +++-- 29 files changed, 249 insertions(+), 103 deletions(-) create mode 100644 modules/lemonldap-ng-portal/t/04-Lemonldap-NG-Portal-SOAP.t diff --git a/build/lemonldap-ng/debian/control b/build/lemonldap-ng/debian/control index 9ac81fc36..06ed1703d 100644 --- a/build/lemonldap-ng/debian/control +++ b/build/lemonldap-ng/debian/control @@ -9,7 +9,7 @@ Standards-Version: 3.8.0 Package: lemonldap-ng Architecture: all -Depends: liblemonldap-ng-handler-perl (= ${binary:Version}), liblemonldap-ng-manager-perl (= ${binary:Version}), liblemonldap-ng-portal-perl (= ${binary:Version}) +Depends: ${misc:Depends}, liblemonldap-ng-handler-perl (= ${binary:Version}), liblemonldap-ng-manager-perl (= ${binary:Version}), liblemonldap-ng-portal-perl (= ${binary:Version}) Description: Lemonldap::NG Web-SSO system Lemonldap::NG is a complete Web-SSO system that can run with reverse-proxies or directly on application Apache servers. @@ -19,6 +19,7 @@ Description: Lemonldap::NG Web-SSO system Package: lemonldap-ng-doc Section: doc Architecture: all +Depends: ${misc:Depends} Description: Lemonldap::NG Web-SSO system documentation Lemonldap::NG is a complete Web-SSO system that can run with reverse-proxies or directly on application Apache servers. @@ -27,7 +28,7 @@ Description: Lemonldap::NG Web-SSO system documentation Package: liblemonldap-ng-handler-perl Architecture: all -Depends: libapache-session-perl, libwww-perl, libcache-cache-perl, liblemonldap-ng-conf-perl (= ${binary:Version}), libapache2-mod-perl2 | libapache-mod-perl +Depends: ${misc:Depends}, libapache-session-perl, libwww-perl, libcache-cache-perl, liblemonldap-ng-conf-perl (= ${binary:Version}), libapache2-mod-perl2 | libapache-mod-perl Suggests: liblemonldap-ng-portal-perl Description: Lemonldap::NG Apache module part Lemonldap::NG is a complete Web-SSO system that can run with reverse-proxies @@ -49,7 +50,7 @@ Description: Lemonldap::NG Apache administration interface part Package: liblemonldap-ng-manager-perl Architecture: all -Depends: libxml-simple-perl, liblemonldap-ng-conf-perl (= ${binary:Version}), libjs-jquery, liblemonldap-ng-handler-perl (= ${binary:Version}) +Depends: ${misc:Depends}, libxml-simple-perl, liblemonldap-ng-conf-perl (= ${binary:Version}), libjs-jquery, liblemonldap-ng-handler-perl (= ${binary:Version}) Recommends: libcache-cache-perl, libapache-session-perl, libsoap-lite-perl Description: Lemonldap::NG Apache manager part Lemonldap::NG is a complete Web-SSO system that can run with reverse-proxies @@ -59,7 +60,7 @@ Description: Lemonldap::NG Apache manager part Package: liblemonldap-ng-portal-perl Architecture: all -Depends: libapache-session-perl, libnet-ldap-perl, liblemonldap-ng-conf-perl (= ${binary:Version}), libhtml-template-perl, libjs-jquery, liblemonldap-ng-handler-perl (= ${binary:Version}), libxml-libxml-perl, libxml-libxslt-perl +Depends: ${misc:Depends}, libapache-session-perl, libnet-ldap-perl, liblemonldap-ng-conf-perl (= ${binary:Version}), libhtml-template-perl, libjs-jquery, liblemonldap-ng-handler-perl (= ${binary:Version}), libxml-libxml-perl, libxml-libxslt-perl Suggests: liblasso-perl, libcgi-session-perl, slapd Description: Lemonldap::NG Apache authentication portal part Lemonldap::NG is a complete Web-SSO system that can run with reverse-proxies diff --git a/modules/lemonldap-ng-common/META.yml b/modules/lemonldap-ng-common/META.yml index b56035561..c7f3c745b 100644 --- a/modules/lemonldap-ng-common/META.yml +++ b/modules/lemonldap-ng-common/META.yml @@ -12,6 +12,7 @@ requires: CGI: 3.08 Crypt::Rijndael: 0 DBI: 0 + IO::String: 0 Regexp::Assemble: 0 SOAP::Lite: 0 Storable: 0 diff --git a/modules/lemonldap-ng-common/Makefile.PL b/modules/lemonldap-ng-common/Makefile.PL index 07a623367..3251cf209 100644 --- a/modules/lemonldap-ng-common/Makefile.PL +++ b/modules/lemonldap-ng-common/Makefile.PL @@ -27,6 +27,7 @@ WriteMakefile( 'Storable' => 0, 'Regexp::Assemble' => 0, 'Cache::Cache' => 0, + 'IO::String' => 0, 'SOAP::Lite' => 0, 'Crypt::Rijndael' => 0, }, # e.g., Module::Name => 1.1 diff --git a/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm b/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm index a92b6838c..b8bd8a03f 100644 --- a/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm +++ b/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI.pm @@ -91,7 +91,7 @@ sub soapTest { Lemonldap::NG::Common::CGI::SOAPService->new( $obj || $self, @func ); Lemonldap::NG::Common::CGI::SOAPServer->dispatch_to($dispatcher) ->handle($self); - exit; + $self->quit(); } } @@ -179,7 +179,7 @@ sub startSyslog { $self->{_syslog} = 1; } -##@method protected void userLog(string mess, string level) +##@method void userLog(string mess, string level) # Log user actions on Apache logs or syslog. # @param $mess string to log # @param $level level of log message @@ -195,7 +195,7 @@ sub userLog { } ##@method void userInfo(string mess) -# Log user errors like "bad password". +# Log non important user actions. Alias for userLog() with facility "info". # @param $mess string to log sub userInfo { my ( $self, $mess ) = @_; @@ -204,7 +204,8 @@ sub userInfo { } ##@method void userNotice(string mess) -# Log user actions like access and logout. +# Log user actions like access and logout. Alias for userLog() with facility +# "warn". # @param $mess string to log sub userNotice { my ( $self, $mess ) = @_; @@ -213,7 +214,8 @@ sub userNotice { } ##@method void userError(string mess) -# Log user errors like "bad password". +# Log user errors like "bad password". Alias for userLog() with facility +# "error". # @param $mess string to log sub userError { my ( $self, $mess ) = @_; @@ -237,6 +239,12 @@ sub _sub { } } +## @method private void quit() +# Simply exit. +sub quit { + exit; +} + 1; __END__ diff --git a/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI/SOAPServer.pm b/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI/SOAPServer.pm index 6d6ed161d..b1b1efe04 100644 --- a/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI/SOAPServer.pm +++ b/modules/lemonldap-ng-common/lib/Lemonldap/NG/Common/CGI/SOAPServer.pm @@ -12,6 +12,8 @@ use base qw(SOAP::Transport::HTTP::Server); our $VERSION = '0.2'; +## @method protected void DESTROY() +# Call SOAP::Trace::objects(). sub DESTROY { SOAP::Trace::objects('()') } ## @cmethod Lemonldap::NG::Common::CGI::SOAPServer new(@param) diff --git a/modules/lemonldap-ng-common/t/02-Common-Conf-File.t b/modules/lemonldap-ng-common/t/02-Common-Conf-File.t index a3d06f1fb..e6428a0c4 100644 --- a/modules/lemonldap-ng-common/t/02-Common-Conf-File.t +++ b/modules/lemonldap-ng-common/t/02-Common-Conf-File.t @@ -17,10 +17,10 @@ my $h; ok( $h = new Lemonldap::NG::Common::Conf( - { - type => 'File', - dirName => ".", - } + { + type => 'File', + dirName => ".", + } ), 'type => file', ); diff --git a/modules/lemonldap-ng-common/t/03-Common-Conf-DBI.t b/modules/lemonldap-ng-common/t/03-Common-Conf-DBI.t index 297c88cec..34903e62d 100644 --- a/modules/lemonldap-ng-common/t/03-Common-Conf-DBI.t +++ b/modules/lemonldap-ng-common/t/03-Common-Conf-DBI.t @@ -17,13 +17,13 @@ my $h; @ARGV = ("help=groups"); ok( $h = new Lemonldap::NG::Common::Conf( - { - type => 'DBI', - dbiChain => "DBI:mysql:database=lemonldap-ng", - dbiUser => 'lemonldap-ng', - } + { + type => 'DBI', + dbiChain => "DBI:mysql:database=lemonldap-ng", + dbiUser => 'lemonldap-ng', + } ) ); -ok( $h->can( 'dbh' ) ); +ok( $h->can('dbh') ); diff --git a/modules/lemonldap-ng-common/t/04-Common-Conf-SOAP.t b/modules/lemonldap-ng-common/t/04-Common-Conf-SOAP.t index e5cd058e1..716853dcb 100644 --- a/modules/lemonldap-ng-common/t/04-Common-Conf-SOAP.t +++ b/modules/lemonldap-ng-common/t/04-Common-Conf-SOAP.t @@ -19,14 +19,14 @@ SKIP: { my $h; ok( $h = new Lemonldap::NG::Common::Conf( - { - type => 'SOAP', - proxy => 'http://localhost', - } + { + type => 'SOAP', + proxy => 'http://localhost', + } ) ); - ok( $h->can( '_connect' ) ); - ok( $h->can( '_soapCall' ) ); + ok( $h->can('_connect') ); + ok( $h->can('_soapCall') ); } ######################### diff --git a/modules/lemonldap-ng-common/t/10-Common.t b/modules/lemonldap-ng-common/t/10-Common.t index 41e1e62cb..27a3851be 100644 --- a/modules/lemonldap-ng-common/t/10-Common.t +++ b/modules/lemonldap-ng-common/t/10-Common.t @@ -6,7 +6,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More tests => 1; -BEGIN { use_ok('Lemonldap::NG::Common') }; +BEGIN { use_ok('Lemonldap::NG::Common') } ######################### diff --git a/modules/lemonldap-ng-common/t/20-Common-CGI.t b/modules/lemonldap-ng-common/t/20-Common-CGI.t index a0786f2d9..c024a217c 100644 --- a/modules/lemonldap-ng-common/t/20-Common-CGI.t +++ b/modules/lemonldap-ng-common/t/20-Common-CGI.t @@ -6,15 +6,51 @@ # change 'tests => 1' to 'tests => last_test_to_print'; package My::Portal; -use Test::More tests => 7; +use strict; +use IO::String; +use Test::More tests => 10; BEGIN { use_ok('Lemonldap::NG::Common::CGI') } -our @ISA = ('Lemonldap::NG::Common::CGI'); +use base ('Lemonldap::NG::Common::CGI'); sub subtest { return 'OK1'; } +sub abort { + shift; + $, = ''; + print STDERR @_; + die 'abort has been called'; +} + +sub quit { + 2; +} + +our $param; + +sub param { + return $param; +} + +sub soapfunc { + return 'SoapOK'; +} + +our $buf; + +tie *STDOUT, 'IO::String', $buf; +our $lastpos = 0; + +sub diff { + my $str = $buf; + $str =~ s/^.{$lastpos}//s if ($lastpos); + $str =~ s/\r//gs; + $lastpos = length $buf; + return $str; +} + ######################### # Insert your test code below, the Test::More module is use()ed here so read @@ -22,19 +58,16 @@ sub subtest { my $cgi; -ok( ( $cgi = My::Portal->new() ), 'New CGI' ); - -use IO::String; - -our $buf; - -#tie *STDOUT, 'IO::String', $buf; $ENV{SCRIPT_NAME} = '/test.pl'; $ENV{SCRIPT_FILENAME} = 't/20-Common-CGI.t'; $ENV{REQUEST_METHOD} = 'GET'; $ENV{REQUEST_URI} = '/'; $ENV{QUERY_STRING} = ''; +#$cgi = CGI->new; +ok( ( $cgi = Lemonldap::NG::Common::CGI->new() ), 'New CGI' ); +bless $cgi, 'My::Portal'; + # Test header_public ok( $buf = $cgi->header_public('t/20-Common-CGI.t'), 'header_public' ); ok( $buf =~ /Cache-control: public; must-revalidate; max-age=\d+\r?\n/s, @@ -46,3 +79,19 @@ ok( $cgi->_sub('subtest') eq 'OK1', '_sub mechanism 1' ); $cgi->{subtest} = sub { return 'OK2' }; ok( $cgi->_sub('subtest') eq 'OK2', '_sub mechanism 2' ); +# SOAP +SKIP: { + eval { require SOAP::Lite }; + skip + "SOAP::Lite is not installed, so CGI SOAP functions will not work", 3 + if ($@); + $ENV{HTTP_SOAPACTION} = + 'http://localhost/Lemonldap/NG/Common/CGI/SOAPService#soapfunc'; + $param = +'fr'; + ok( $cgi->soapTest('soapfunc') == 2, 'SOAP call exit fine' ); + my $tmp = diff(); + ok( $tmp =~ /^Status: 200/s, 'HTTP response 200' ); + ok( $tmp =~ /SoapOK<\/result>/s, + 'result of SOAP call' ); +} diff --git a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/AuthBasic.pm b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/AuthBasic.pm index f16fd7f6e..923e15cd1 100644 --- a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/AuthBasic.pm +++ b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/AuthBasic.pm @@ -32,7 +32,7 @@ BEGIN { } } -## @cmethod int run(Apache2::RequestRec apacheRequest) +## @rmethod int run(Apache2::RequestRec apacheRequest) # overload run subroutine to implement Auth-Basic mechanism. # @param $apacheRequest current request # @return Apache constant diff --git a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CDA.pm b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CDA.pm index 355e1cf75..40ac55c0e 100644 --- a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CDA.pm +++ b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CDA.pm @@ -16,7 +16,7 @@ use base qw(Lemonldap::NG::Handler::SharedConf); *EXPORT_TAGS = *Lemonldap::NG::Handler::SharedConf::EXPORT_TAGS; *EXPORT_OK = *Lemonldap::NG::Handler::SharedConf::EXPORT_OK; -## @cmethod int run(Apache2::RequestRec apacheRequest) +## @rmethod int run(Apache2::RequestRec apacheRequest) # overload run subroutine to implement cross-domain mechanism. # @param $apacheRequest # @return Apache constant diff --git a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CGI.pm b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CGI.pm index 2f66bdb3e..17f3765fb 100644 --- a/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CGI.pm +++ b/modules/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/CGI.pm @@ -146,7 +146,7 @@ sub goToPortal { exit; } -## @fn string private _uri() +## @fn private string _uri() # Builds current URL including "http://" and server name. # @return URL_string sub _uri { diff --git a/modules/lemonldap-ng-handler/t/11-Lemonldap-NG-Handler-Status.t b/modules/lemonldap-ng-handler/t/11-Lemonldap-NG-Handler-Status.t index d2c9cbd7e..c43a661a2 100644 --- a/modules/lemonldap-ng-handler/t/11-Lemonldap-NG-Handler-Status.t +++ b/modules/lemonldap-ng-handler/t/11-Lemonldap-NG-Handler-Status.t @@ -6,11 +6,11 @@ # change 'tests => 1' to 'tests => last_test_to_print'; BEGIN { - our $home=0; - $home++ if($ENV{DEBFULLNAME} and $ENV{DEBFULLNAME} eq 'Xavier Guimard'); + our $home = 0; + $home++ if ( $ENV{DEBFULLNAME} and $ENV{DEBFULLNAME} eq 'Xavier Guimard' ); } -use Test::More tests => 1 + 8*$home; +use Test::More tests => 1 + 8 * $home; BEGIN { use_ok( 'Lemonldap::NG::Handler::Simple', ':all' ) } ######################### @@ -18,7 +18,7 @@ BEGIN { use_ok( 'Lemonldap::NG::Handler::Simple', ':all' ) } # 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. -exit unless($home); +exit unless ($home); my $h; $h = bless {}, 'Lemonldap::NG::Handler::Simple'; @@ -50,8 +50,10 @@ ok( close($statusPipe) ); sub read { my $ok = 0; + #open LOG, '>/tmp/log'; while (<$statusOut>) { + #print LOG $_; $ok++ if (/^OK\s+:\s*2\s*\(2\.00\s*\/\s*mn\)$/); $ok++ if (/^REJECT\s+:\s*1\s*\(1\.00\s*\/\s*mn\)$/); @@ -60,6 +62,7 @@ sub read { last; } } + #print LOG "$ok\n"; #close LOG; return ( $ok == 3 ); diff --git a/modules/lemonldap-ng-handler/t/30-Lemonldap-NG-Handler-CGI.t b/modules/lemonldap-ng-handler/t/30-Lemonldap-NG-Handler-CGI.t index 0c11e4557..ad5f5c5fb 100644 --- a/modules/lemonldap-ng-handler/t/30-Lemonldap-NG-Handler-CGI.t +++ b/modules/lemonldap-ng-handler/t/30-Lemonldap-NG-Handler-CGI.t @@ -29,9 +29,9 @@ ok( type => "File", dirName => '/tmp/', }, - https => 0, - portal => 'http://auth.example.com', - globalStorage => 'Apache::Session::File', + https => 0, + portal => 'http://auth.example.com', + globalStorage => 'Apache::Session::File', } ), 'Portal object' diff --git a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm index b33e2f9f3..070742e4e 100644 --- a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm +++ b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager.pm @@ -233,7 +233,7 @@ sub printXmlConf { ); } -# @method protected hashRef buildTree(array p) +## @method protected hashRef buildTree(array p) # Transform Lemonldap::NG configuration into a tree that javascript library can # understand. # @param @p parameters given to Lemonldap::NG::Common::Conf::getConf() diff --git a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm index 52b6794c4..ae033a5fc 100755 --- a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm +++ b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Sessions.pm @@ -40,7 +40,7 @@ sub new { return $self; } -## @rmethod void process() +## @method void process() # Main method. sub process { my $self = shift; @@ -375,7 +375,7 @@ sub process { } } -## @rfn protected string htmlquote(string s) +## @fn protected string htmlquote(string s) # Change <, > and & to HTML encoded values in the string # @param $s HTML string # @return HTML string @@ -387,7 +387,7 @@ sub htmlquote { return $s; } -## @rfn protected void start() +## @fn protected void start() # Display HTTP and HTML headers. sub start { my $self = shift; @@ -446,7 +446,7 @@ sub start { ); } -## @rfn protected void ajaxnode(string id, string text, string param) +## @fn protected void ajaxnode(string id, string text, string param) # Display tree node with Ajax functions inside for opening the node. # @param $id HTML id of the element. # @param $text text to display @@ -457,7 +457,7 @@ sub ajaxNode { "
  • $text\n
    • {url:$ENV{SCRIPT_NAME}?$param}
  • \n"; } -## @rfn protected void window(string root) +## @fn protected void window(string root) # Design the main window # @param $root Text to display in the root node of the tree sub window { @@ -481,7 +481,7 @@ sub window { . '