From 9b10d9634117f3af0ecbebe2978ee571ef9381bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Oudot?= Date: Thu, 29 May 2014 07:38:50 +0000 Subject: [PATCH] Fix unit tests after introducing RegisterDB (#26) --- .../Lemonldap/NG/Common/Conf/Attributes.pm | 7 ++++ .../lib/Lemonldap/NG/Portal/RegisterDBDemo.pm | 36 +++++++++++++++++++ .../lib/Lemonldap/NG/Portal/RegisterDBNull.pm | 1 + .../t/01-Lemonldap-NG-Portal-Simple.t | 2 ++ lemonldap-ng-portal/t/03-XSS-protection.t | 1 + .../t/04-Lemonldap-NG-Portal-SOAP.t | 1 + .../t/05-Lemonldap-NG-Portal-Safe.t | 1 + .../t/20-Lemonldap-NG-Portal-AuthApache.t | 1 + .../t/21-Lemonldap-NG-Portal-AuthSSL.t | 1 + .../t/22-Lemonldap-NG-Portal-AuthCAS.t | 2 ++ .../t/24-Lemonldap-NG-Portal-AuthRemote.t | 1 + .../t/25-Lemonldap-NG-Portal-Multi.t | 6 ++++ .../t/26-Lemonldap-NG-Portal-AuthChoice.t | 1 + .../t/26-Lemonldap-NG-Portal-AuthProxy.t | 1 + .../t/30-Lemonldap-NG-Portal-UserDBNull.t | 1 + .../t/40-Lemonldap-NG-Portal-CDA.t | 2 +- .../t/50-Lemonldap-NG-Portal-Menu.t | 1 + .../t/61-Lemonldap-NG-Portal-SAML.t | 2 +- .../t/66-Lemonldap-NG-Portal-Captcha.t | 1 + .../t/67-Lemonldap-NG-Portal-AuthBrowserID.t | 1 + 20 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 lemonldap-ng-portal/lib/Lemonldap/NG/Portal/RegisterDBDemo.pm diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Attributes.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Attributes.pm index ec972c5e0..031d3c6e5 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Attributes.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Attributes.pm @@ -896,6 +896,13 @@ has 'redirectFormMethod' => ( documentation => 'HTTP method for redirect page form', ); +has 'registerDB' => ( + is => 'rw', + isa => 'Str', + default => 'Demo', + documentation => 'Register module', +); + has 'remoteGlobalStorage' => ( is => 'rw', isa => 'Str', diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/RegisterDBDemo.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/RegisterDBDemo.pm new file mode 100644 index 000000000..00b7c499b --- /dev/null +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/RegisterDBDemo.pm @@ -0,0 +1,36 @@ +##@file +# Demo register backend file + +##@class +# Demo register backend class +package Lemonldap::NG::Portal::RegisterDBDemo; + +use strict; +use Lemonldap::NG::Portal::Simple; + +## @method int computeLogin +# Compute a login from register infos +# @result Lemonldap::NG::Portal constant +sub computeLogin { + my ($self) = splice @_; + + # Get first letter of firstname and lastname + my $login = + substr( lc $self->{registerInfo}->{firstname}, 0, 1 ) + . lc $self->{registerInfo}->{lastname}; + + $self->{registerInfo}->{login} = $login; + + return PE_OK; +} + +## @method int createUser +# Do nothing +# @result Lemonldap::NG::Portal constant +sub createUser { + my ($self) = splice @_; + + return PE_OK; +} + +1; diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/RegisterDBNull.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/RegisterDBNull.pm index edf050af6..be8ba0267 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/RegisterDBNull.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/RegisterDBNull.pm @@ -11,6 +11,7 @@ use Lemonldap::NG::Portal::Simple; our $VERSION = '1.4.0'; sub getLogin { + my $self = splice @_; $self->{registerInfo}->{login} = ""; return PE_OK; } diff --git a/lemonldap-ng-portal/t/01-Lemonldap-NG-Portal-Simple.t b/lemonldap-ng-portal/t/01-Lemonldap-NG-Portal-Simple.t index a5a556563..9f3b91642 100644 --- a/lemonldap-ng-portal/t/01-Lemonldap-NG-Portal-Simple.t +++ b/lemonldap-ng-portal/t/01-Lemonldap-NG-Portal-Simple.t @@ -41,6 +41,7 @@ ok( authentication => 'LDAP test=1', userDB => 'LDAP', passwordDB => 'LDAP', + registerDB => 'LDAP', cookieName => 'lemonldap', whatToTrace => '_user', multiValuesSeparator => '; ', @@ -71,6 +72,7 @@ $p = Lemonldap::NG::Portal::Simple->new( authentication => 'LDAP test=1', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', cookieName => 'lemonldap', whatToTrace => 'dummy', multiValuesSeparator => '; ', diff --git a/lemonldap-ng-portal/t/03-XSS-protection.t b/lemonldap-ng-portal/t/03-XSS-protection.t index e8cbaf7c9..2d5bf9230 100644 --- a/lemonldap-ng-portal/t/03-XSS-protection.t +++ b/lemonldap-ng-portal/t/03-XSS-protection.t @@ -134,6 +134,7 @@ ok( authentication => 'LDAP test=1', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', domain => 'example.com', trustedDomains => '.example2.com example3.com', checkXSS => 1, diff --git a/lemonldap-ng-portal/t/04-Lemonldap-NG-Portal-SOAP.t b/lemonldap-ng-portal/t/04-Lemonldap-NG-Portal-SOAP.t index d3f54f39b..01c294cda 100644 --- a/lemonldap-ng-portal/t/04-Lemonldap-NG-Portal-SOAP.t +++ b/lemonldap-ng-portal/t/04-Lemonldap-NG-Portal-SOAP.t @@ -78,6 +78,7 @@ SKIP: { authentication => 'Null', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', soap => 1, } ), diff --git a/lemonldap-ng-portal/t/05-Lemonldap-NG-Portal-Safe.t b/lemonldap-ng-portal/t/05-Lemonldap-NG-Portal-Safe.t index 6dfb78f2a..495d0d305 100644 --- a/lemonldap-ng-portal/t/05-Lemonldap-NG-Portal-Safe.t +++ b/lemonldap-ng-portal/t/05-Lemonldap-NG-Portal-Safe.t @@ -25,6 +25,7 @@ ok( authentication => 'Null', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', useSafeJail => 1, } ), diff --git a/lemonldap-ng-portal/t/20-Lemonldap-NG-Portal-AuthApache.t b/lemonldap-ng-portal/t/20-Lemonldap-NG-Portal-AuthApache.t index 1318d2e85..0ff1bb22f 100644 --- a/lemonldap-ng-portal/t/20-Lemonldap-NG-Portal-AuthApache.t +++ b/lemonldap-ng-portal/t/20-Lemonldap-NG-Portal-AuthApache.t @@ -23,6 +23,7 @@ ok( authentication => 'Apache', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', } ) ); diff --git a/lemonldap-ng-portal/t/21-Lemonldap-NG-Portal-AuthSSL.t b/lemonldap-ng-portal/t/21-Lemonldap-NG-Portal-AuthSSL.t index d43da1e69..b8e36d470 100644 --- a/lemonldap-ng-portal/t/21-Lemonldap-NG-Portal-AuthSSL.t +++ b/lemonldap-ng-portal/t/21-Lemonldap-NG-Portal-AuthSSL.t @@ -23,6 +23,7 @@ ok( authentication => 'SSL', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', } ) ); diff --git a/lemonldap-ng-portal/t/22-Lemonldap-NG-Portal-AuthCAS.t b/lemonldap-ng-portal/t/22-Lemonldap-NG-Portal-AuthCAS.t index e773d8c45..52e0551e7 100644 --- a/lemonldap-ng-portal/t/22-Lemonldap-NG-Portal-AuthCAS.t +++ b/lemonldap-ng-portal/t/22-Lemonldap-NG-Portal-AuthCAS.t @@ -35,6 +35,7 @@ SKIP: { authentication => 'CAS', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', CAS_url => 'https://cas.example.com', CAS_pgt => '/tmp/pgt.txt', CAS_proxiedServices => {}, @@ -50,6 +51,7 @@ SKIP: { authentication => 'CAS', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', CAS_url => 'https://cas.example.com', CAS_pgt => '/tmp/pgt.txt', CAS_proxiedServices => { 'CAS1' => 'http://cas1.example.com' }, diff --git a/lemonldap-ng-portal/t/24-Lemonldap-NG-Portal-AuthRemote.t b/lemonldap-ng-portal/t/24-Lemonldap-NG-Portal-AuthRemote.t index 9046b2fcb..cfec8ca57 100644 --- a/lemonldap-ng-portal/t/24-Lemonldap-NG-Portal-AuthRemote.t +++ b/lemonldap-ng-portal/t/24-Lemonldap-NG-Portal-AuthRemote.t @@ -58,6 +58,7 @@ ok( authentication => 'Remote', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', cookieName => 'lemonldap', portal => 'http://abc', remotePortal => 'http://zz/', diff --git a/lemonldap-ng-portal/t/25-Lemonldap-NG-Portal-Multi.t b/lemonldap-ng-portal/t/25-Lemonldap-NG-Portal-Multi.t index cbf159931..24cb4a78f 100644 --- a/lemonldap-ng-portal/t/25-Lemonldap-NG-Portal-Multi.t +++ b/lemonldap-ng-portal/t/25-Lemonldap-NG-Portal-Multi.t @@ -81,6 +81,7 @@ my ( $test, $testU ); authentication => 'Multi 1;2', userDB => 'Multi 1;2', passwordDB => 'Null', + registerDB => 'Null', cookieName => 'lemonldap', whatToTrace => 'dummy', multiValuesSeparator => '; ', @@ -115,6 +116,7 @@ my ( $test, $testU ); authentication => 'Multi 1;2', userDB => 'Multi 1;2', passwordDB => 'Null', + registerDB => 'Null', cookieName => 'lemonldap', whatToTrace => 'dummy', multiValuesSeparator => '; ', @@ -143,6 +145,7 @@ my ( $test, $testU ); authentication => 'Multi 1;2', userDB => 'Multi 3;4', passwordDB => 'Null', + registerDB => 'Null', cookieName => 'lemonldap', whatToTrace => 'dummy', multiValuesSeparator => '; ', @@ -171,6 +174,7 @@ my ( $test, $testU ); authentication => 'Multi 1 1==0;2 1==0', userDB => 'Multi 3;4', passwordDB => 'Null', + registerDB => 'Null', cookieName => 'lemonldap', whatToTrace => 'dummy', multiValuesSeparator => '; ', @@ -196,6 +200,7 @@ my ( $test, $testU ); authentication => 'Multi 1;2 1==0', userDB => 'Multi 3;4', passwordDB => 'Null', + registerDB => 'Null', cookieName => 'lemonldap', whatToTrace => 'dummy', multiValuesSeparator => '; ', @@ -221,6 +226,7 @@ my ( $test, $testU ); authentication => 'Multi 1;2 1==1', userDB => 'Multi 3;4', passwordDB => 'Null', + registerDB => 'Null', cookieName => 'lemonldap', whatToTrace => 'dummy', multiValuesSeparator => '; ', diff --git a/lemonldap-ng-portal/t/26-Lemonldap-NG-Portal-AuthChoice.t b/lemonldap-ng-portal/t/26-Lemonldap-NG-Portal-AuthChoice.t index c1ef693c6..32b067a30 100644 --- a/lemonldap-ng-portal/t/26-Lemonldap-NG-Portal-AuthChoice.t +++ b/lemonldap-ng-portal/t/26-Lemonldap-NG-Portal-AuthChoice.t @@ -32,6 +32,7 @@ ok( authentication => 'Choice', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', getUser => sub { PE_OK }, setSessionInfo => sub { PE_OK }, portal => 'http://abc', diff --git a/lemonldap-ng-portal/t/26-Lemonldap-NG-Portal-AuthProxy.t b/lemonldap-ng-portal/t/26-Lemonldap-NG-Portal-AuthProxy.t index c167a6313..6336f20a0 100644 --- a/lemonldap-ng-portal/t/26-Lemonldap-NG-Portal-AuthProxy.t +++ b/lemonldap-ng-portal/t/26-Lemonldap-NG-Portal-AuthProxy.t @@ -58,6 +58,7 @@ ok( authentication => 'Proxy', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', cookieName => 'lemonldap', portal => 'http://abc', soapAuthService => 'https://lm.com', diff --git a/lemonldap-ng-portal/t/30-Lemonldap-NG-Portal-UserDBNull.t b/lemonldap-ng-portal/t/30-Lemonldap-NG-Portal-UserDBNull.t index 4c2a23ef0..50b24922f 100644 --- a/lemonldap-ng-portal/t/30-Lemonldap-NG-Portal-UserDBNull.t +++ b/lemonldap-ng-portal/t/30-Lemonldap-NG-Portal-UserDBNull.t @@ -28,6 +28,7 @@ ok( authentication => 'Null', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', exportedVars => { uid => "TEST_STRING", }, } ) diff --git a/lemonldap-ng-portal/t/40-Lemonldap-NG-Portal-CDA.t b/lemonldap-ng-portal/t/40-Lemonldap-NG-Portal-CDA.t index 91690d356..9506ff8e2 100644 --- a/lemonldap-ng-portal/t/40-Lemonldap-NG-Portal-CDA.t +++ b/lemonldap-ng-portal/t/40-Lemonldap-NG-Portal-CDA.t @@ -32,7 +32,7 @@ ok( authentication => 'Null', userDB => 'Null', passwordDB => 'Null', - + registerDB => 'Null', } ), 'Portal object' diff --git a/lemonldap-ng-portal/t/50-Lemonldap-NG-Portal-Menu.t b/lemonldap-ng-portal/t/50-Lemonldap-NG-Portal-Menu.t index aa64fdf8a..61fbe0fae 100644 --- a/lemonldap-ng-portal/t/50-Lemonldap-NG-Portal-Menu.t +++ b/lemonldap-ng-portal/t/50-Lemonldap-NG-Portal-Menu.t @@ -24,6 +24,7 @@ my $p = Lemonldap::NG::Portal::Simple->new( authentication => 'Null', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', applicationList => {}, locationRules => { 'test.example.com' => { diff --git a/lemonldap-ng-portal/t/61-Lemonldap-NG-Portal-SAML.t b/lemonldap-ng-portal/t/61-Lemonldap-NG-Portal-SAML.t index 888d0cf18..bc57f3980 100644 --- a/lemonldap-ng-portal/t/61-Lemonldap-NG-Portal-SAML.t +++ b/lemonldap-ng-portal/t/61-Lemonldap-NG-Portal-SAML.t @@ -23,7 +23,7 @@ SKIP: { userDB => 'SAML', issuerDB => 'Null', passwordDB => 'Null', - + registerDB => 'Null', } ); diff --git a/lemonldap-ng-portal/t/66-Lemonldap-NG-Portal-Captcha.t b/lemonldap-ng-portal/t/66-Lemonldap-NG-Portal-Captcha.t index 68422d331..ccb350ace 100644 --- a/lemonldap-ng-portal/t/66-Lemonldap-NG-Portal-Captcha.t +++ b/lemonldap-ng-portal/t/66-Lemonldap-NG-Portal-Captcha.t @@ -14,6 +14,7 @@ my $p = Lemonldap::NG::Portal::Simple->new( authentication => 'Demo', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', applicationList => {}, locationRules => { 'test.example.com' => { diff --git a/lemonldap-ng-portal/t/67-Lemonldap-NG-Portal-AuthBrowserID.t b/lemonldap-ng-portal/t/67-Lemonldap-NG-Portal-AuthBrowserID.t index 58ae475d8..02b045951 100644 --- a/lemonldap-ng-portal/t/67-Lemonldap-NG-Portal-AuthBrowserID.t +++ b/lemonldap-ng-portal/t/67-Lemonldap-NG-Portal-AuthBrowserID.t @@ -23,6 +23,7 @@ ok( authentication => 'BrowserID', userDB => 'Null', passwordDB => 'Null', + registerDB => 'Null', } ) );