From f570afbad19646e940d958c29126ddce784bffd9 Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Sun, 3 Oct 2010 19:58:07 +0000 Subject: [PATCH] Closes #181 --- .../lib/Lemonldap/NG/Manager/Uploader.pm | 25 +++++++++++++++++-- .../lib/Lemonldap/NG/Manager/_Struct.pm | 23 +++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Uploader.pm b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Uploader.pm index 2670a1f7e..3bf285c87 100644 --- a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Uploader.pm +++ b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Uploader.pm @@ -338,7 +338,7 @@ s/^(samlSPMetaDataXML|samlSPMetaDataExportedAttributes|samlSPMetaDataOptions)\/( } # END LOOP # 1.4 Loading unchanged parameters (ajax nodes not open) - $self->lmLog( "Save unchanged parameters", 'debug' ); + $self->lmLog( "Restore unchanged parameters", 'debug' ); foreach ( @{ $result->getChildrenByTagName('ignore') } ) { my $node = $_->getAttribute('value'); $node =~ s/^.*node=(.*?)(?:&.*)?\}$/$1/; @@ -356,7 +356,28 @@ s/^(samlSPMetaDataXML|samlSPMetaDataExportedAttributes|samlSPMetaDataOptions)\/( } } - # 1.5 Author attributes for accounting + # 1.5 Global tests + $self->lmLog( "Launch global tests", 'debug' ); + { + my $tests = $self->globalTests($newConf); + while ( my ( $name, $sub ) = each %$tests ) { + my ( $res, $msg ); + eval { + ( $res, $msg ) = $sub->(); + if ($res) { + if ($msg) { + $errors->{warnings}->{$name} = $msg; + } + } + else { + $errors->{error}->{$name} = $msg; + } + }; + $errors->{warnings}->{$name} = "Test $name failed" if($@); + } + } + + # 1.6 Author attributes for accounting $newConf->{cfgAuthor} = $ENV{REMOTE_USER} || 'anonymous'; $newConf->{cfgAuthorIP} = $ENV{REMOTE_ADDR}; $newConf->{cfgDate} = time(); diff --git a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm index 4370e2839..d0ac5fbdf 100644 --- a/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm +++ b/modules/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm @@ -1782,4 +1782,27 @@ sub subDefaultConf { }; } +## @method hashref globalTests(hashref conf) +# Return a hash ref where keys are the names of the tests and values +# subroutines to execute +# @param $conf Configuration to test +# @return hash ref where keys are the names of the tests and values +sub globalTests { + my ( $self, $conf ) = splice @_; + return { + 'portalIsInDomain' => sub { + + # TODO: better parsing + return ( + 1, + ( + index( $conf->{portal}, $conf->{domain} ) > 0 + ? '' + : "Portal seems not to be in the domain $conf->{domain}" + ) + ); + }, + }; +} + 1;