Tidy + typo
This commit is contained in:
parent
fedea4abbd
commit
cccd025dfc
|
@ -98,7 +98,7 @@ sub portalConsts {
|
||||||
'92' => 'PE_GET_SERVICE_NOT_ALLOWED',
|
'92' => 'PE_GET_SERVICE_NOT_ALLOWED',
|
||||||
'93' => 'PE_IMPERSONATION_SERVICE_NOT_ALLOWED',
|
'93' => 'PE_IMPERSONATION_SERVICE_NOT_ALLOWED',
|
||||||
'94' => 'PE_ISSUERMISSINGREQATTR',
|
'94' => 'PE_ISSUERMISSINGREQATTR',
|
||||||
'95' => 'PE_RESETCERTIFICATE_INVALIDE',
|
'95' => 'PE_RESETCERTIFICATE_INVALID',
|
||||||
'96' => 'PE_RESETCERTIFICATE_FOREMPTY',
|
'96' => 'PE_RESETCERTIFICATE_FOREMPTY',
|
||||||
'97' => 'PE_RESETCERTIFICATE_FIRSTACCESS'
|
'97' => 'PE_RESETCERTIFICATE_FIRSTACCESS'
|
||||||
};
|
};
|
||||||
|
|
|
@ -102,7 +102,7 @@ sub portalConstants {
|
||||||
PE_GET_SERVICE_NOT_ALLOWED => 92,
|
PE_GET_SERVICE_NOT_ALLOWED => 92,
|
||||||
PE_IMPERSONATION_SERVICE_NOT_ALLOWED => 93,
|
PE_IMPERSONATION_SERVICE_NOT_ALLOWED => 93,
|
||||||
PE_ISSUERMISSINGREQATTR => 94,
|
PE_ISSUERMISSINGREQATTR => 94,
|
||||||
PE_RESETCERTIFICATE_INVALIDE => 95,
|
PE_RESETCERTIFICATE_INVALID => 95,
|
||||||
PE_RESETCERTIFICATE_FOREMPTY => 96,
|
PE_RESETCERTIFICATE_FOREMPTY => 96,
|
||||||
PE_RESETCERTIFICATE_FIRSTACCESS => 97,
|
PE_RESETCERTIFICATE_FIRSTACCESS => 97,
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,7 +98,7 @@ use constant {
|
||||||
PE_GET_SERVICE_NOT_ALLOWED => 92,
|
PE_GET_SERVICE_NOT_ALLOWED => 92,
|
||||||
PE_IMPERSONATION_SERVICE_NOT_ALLOWED => 93,
|
PE_IMPERSONATION_SERVICE_NOT_ALLOWED => 93,
|
||||||
PE_ISSUERMISSINGREQATTR => 94,
|
PE_ISSUERMISSINGREQATTR => 94,
|
||||||
PE_RESETCERTIFICATE_INVALIDE => 95,
|
PE_RESETCERTIFICATE_INVALID => 95,
|
||||||
PE_RESETCERTIFICATE_FOREMPTY => 96,
|
PE_RESETCERTIFICATE_FOREMPTY => 96,
|
||||||
PE_RESETCERTIFICATE_FIRSTACCESS => 97,
|
PE_RESETCERTIFICATE_FIRSTACCESS => 97,
|
||||||
};
|
};
|
||||||
|
@ -195,7 +195,7 @@ sub portalConsts {
|
||||||
'92' => 'PE_GET_SERVICE_NOT_ALLOWED',
|
'92' => 'PE_GET_SERVICE_NOT_ALLOWED',
|
||||||
'93' => 'PE_IMPERSONATION_SERVICE_NOT_ALLOWED',
|
'93' => 'PE_IMPERSONATION_SERVICE_NOT_ALLOWED',
|
||||||
'94' => 'PE_ISSUERMISSINGREQATTR',
|
'94' => 'PE_ISSUERMISSINGREQATTR',
|
||||||
'95' => 'PE_RESETCERTIFICATE_INVALIDE',
|
'95' => 'PE_RESETCERTIFICATE_INVALID',
|
||||||
'96' => 'PE_RESETCERTIFICATE_FOREMPTY',
|
'96' => 'PE_RESETCERTIFICATE_FOREMPTY',
|
||||||
'97' => 'PE_RESETCERTIFICATE_FIRSTACCESS'
|
'97' => 'PE_RESETCERTIFICATE_FIRSTACCESS'
|
||||||
};
|
};
|
||||||
|
@ -296,7 +296,7 @@ our @EXPORT_OK = (
|
||||||
'PE_GET_SERVICE_NOT_ALLOWED',
|
'PE_GET_SERVICE_NOT_ALLOWED',
|
||||||
'PE_IMPERSONATION_SERVICE_NOT_ALLOWED',
|
'PE_IMPERSONATION_SERVICE_NOT_ALLOWED',
|
||||||
'PE_ISSUERMISSINGREQATTR',
|
'PE_ISSUERMISSINGREQATTR',
|
||||||
'PE_RESETCERTIFICATE_INVALIDE',
|
'PE_RESETCERTIFICATE_INVALID',
|
||||||
'PE_RESETCERTIFICATE_FOREMPTY',
|
'PE_RESETCERTIFICATE_FOREMPTY',
|
||||||
'PE_RESETCERTIFICATE_FIRSTACCESS'
|
'PE_RESETCERTIFICATE_FIRSTACCESS'
|
||||||
);
|
);
|
||||||
|
|
|
@ -29,7 +29,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
|
||||||
PE_PASSWORD_OK
|
PE_PASSWORD_OK
|
||||||
PE_TOKENEXPIRED
|
PE_TOKENEXPIRED
|
||||||
PE_USERNOTFOUND
|
PE_USERNOTFOUND
|
||||||
PE_RESETCERTIFICATE_INVALIDE
|
PE_RESETCERTIFICATE_INVALID
|
||||||
PE_RESETCERTIFICATE_FOREMPTY
|
PE_RESETCERTIFICATE_FOREMPTY
|
||||||
PE_RESETCERTIFICATE_FIRSTACCESS
|
PE_RESETCERTIFICATE_FIRSTACCESS
|
||||||
);
|
);
|
||||||
|
@ -481,8 +481,8 @@ sub modifyCertificate {
|
||||||
$self->userLogger->debug( "Unable to decode certificate for user "
|
$self->userLogger->debug( "Unable to decode certificate for user "
|
||||||
. Net::SSLeay::ERR_error_string( Net::SSLeay::ERR_get_error() ) );
|
. Net::SSLeay::ERR_error_string( Net::SSLeay::ERR_get_error() ) );
|
||||||
|
|
||||||
#return PE_CERTIFICATE_INVALIDE;
|
#return PE_CERTIFICATE_INVALID;
|
||||||
return PE_RESETCERTIFICATE_INVALIDE;
|
return PE_RESETCERTIFICATE_INVALID;
|
||||||
}
|
}
|
||||||
$self->userLogger->debug("Certificate decoded successfully");
|
$self->userLogger->debug("Certificate decoded successfully");
|
||||||
$notAfter = Net::SSLeay::P_ASN1_TIME_get_isotime(
|
$notAfter = Net::SSLeay::P_ASN1_TIME_get_isotime(
|
||||||
|
@ -507,7 +507,7 @@ sub modifyCertificate {
|
||||||
$self->userLogger->debug(
|
$self->userLogger->debug(
|
||||||
"Your cettificate is no longer valid in $self->conf->{certificateValidityDelay}"
|
"Your cettificate is no longer valid in $self->conf->{certificateValidityDelay}"
|
||||||
);
|
);
|
||||||
return PE_RESETCERTIFICATE_INVALIDE;
|
return PE_RESETCERTIFICATE_INVALID;
|
||||||
|
|
||||||
#return PE_PASSWORD_MISMATCH;
|
#return PE_PASSWORD_MISMATCH;
|
||||||
}
|
}
|
||||||
|
@ -691,7 +691,7 @@ sub display {
|
||||||
|
|
||||||
# Display Certificate Reset form again if certificate invalid
|
# Display Certificate Reset form again if certificate invalid
|
||||||
elsif ($req->error == PE_RESETCERTIFICATE_FOREMPTY
|
elsif ($req->error == PE_RESETCERTIFICATE_FOREMPTY
|
||||||
|| $req->error == PE_RESETCERTIFICATE_INVALIDE )
|
|| $req->error == PE_RESETCERTIFICATE_INVALID )
|
||||||
{
|
{
|
||||||
$self->logger->debug('Display Certificate Reset form');
|
$self->logger->debug('Display Certificate Reset form');
|
||||||
$tplPrm{DISPLAY_CERTIF_FORM} = 1;
|
$tplPrm{DISPLAY_CERTIF_FORM} = 1;
|
||||||
|
|
|
@ -12,15 +12,14 @@ BEGIN {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my ( $res, $user );
|
||||||
my ($res, $user);
|
|
||||||
my $maintests = 6;
|
my $maintests = 6;
|
||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
eval
|
eval
|
||||||
'require Email::Sender::Simple; use GD::SecurityImage;use Image::Magick;';
|
'require Email::Sender::Simple; use GD::SecurityImage;use Image::Magick;';
|
||||||
if ($@) {
|
if ($@) {
|
||||||
skip 'Missing dependencies '.$@ , $maintests;
|
skip 'Missing dependencies ' . $@, $maintests;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,19 +42,21 @@ SKIP: {
|
||||||
captcha_mail_enabled => 0,
|
captcha_mail_enabled => 0,
|
||||||
portalDisplayCertificateResetByMail => 1,
|
portalDisplayCertificateResetByMail => 1,
|
||||||
certificateResetByMailCeaAttribute => 'description',
|
certificateResetByMailCeaAttribute => 'description',
|
||||||
certificateResetByMailCertificateAttribute => 'userCertificate;binary',
|
certificateResetByMailCertificateAttribute =>
|
||||||
certificateResetByMailStep1Body => 'Clique here <a href="$url"> to confirm your mail. It will expire $expMailDate',
|
'userCertificate;binary',
|
||||||
certificateResetByMailStep2Body => 'Certificate Reset sucessfully!',
|
certificateResetByMailStep1Body =>
|
||||||
|
'Click here <a href="$url"> to confirm your mail. It will expire $expMailDate',
|
||||||
|
certificateResetByMailStep2Body =>
|
||||||
|
'Certificate Reset sucessfully!',
|
||||||
certificateValidityDelay => 30
|
certificateValidityDelay => 30
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
# Test form
|
# Test form
|
||||||
# ------------------------
|
# ------------------------
|
||||||
ok( $res = $client->_get('/certificateReset', accept => 'text/html' ),
|
ok( $res = $client->_get( '/certificateReset', accept => 'text/html' ),
|
||||||
'Reset form', );
|
'Reset form', );
|
||||||
my ( $host, $url, $query ) = expectForm( $res, '#', undef, 'mail' );
|
my ( $host, $url, $query ) = expectForm( $res, '#', undef, 'mail' );
|
||||||
|
|
||||||
|
@ -69,25 +70,29 @@ SKIP: {
|
||||||
accept => 'text/html'
|
accept => 'text/html'
|
||||||
),
|
),
|
||||||
'Post mail'
|
'Post mail'
|
||||||
) ;
|
);
|
||||||
|
|
||||||
ok( mail() =~ m#a href="http://auth.example.com/certificateReset\?(.*?)"#,
|
ok( mail() =~ m#a href="http://auth.example.com/certificateReset\?(.*?)"#,
|
||||||
'Found link in mail' );
|
'Found link in mail' );
|
||||||
$query = $1;
|
$query = $1;
|
||||||
my $querymail = $query;
|
my $querymail = $query;
|
||||||
ok(
|
ok(
|
||||||
$res =
|
$res = $client->_get(
|
||||||
$client->_get( '/certificateReset', query => $query, accept => 'text/html' ),
|
'/certificateReset',
|
||||||
|
query => $query,
|
||||||
|
accept => 'text/html'
|
||||||
|
),
|
||||||
'Post mail token received by mail'
|
'Post mail token received by mail'
|
||||||
);
|
);
|
||||||
|
|
||||||
# print STDERR Dumper($res);
|
# print STDERR Dumper($res);
|
||||||
|
|
||||||
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
|
( $host, $url, $query ) = expectForm( $res, '#', undef, 'token' );
|
||||||
ok( $res->[2]->[0] =~ /certif/s, ' Ask for a new certificate file' );
|
ok( $res->[2]->[0] =~ /certif/s, ' Ask for a new certificate file' );
|
||||||
|
|
||||||
#print STDERR Dumper($query);
|
#print STDERR Dumper($query);
|
||||||
my %inputs = split( /[=&]/,$query );
|
my %inputs = split( /[=&]/, $query );
|
||||||
my %querytab = split( /[=&]/,$querymail );
|
my %querytab = split( /[=&]/, $querymail );
|
||||||
|
|
||||||
# Create the certificate file
|
# Create the certificate file
|
||||||
my $cert = "-----BEGIN CERTIFICATE-----
|
my $cert = "-----BEGIN CERTIFICATE-----
|
||||||
|
@ -116,56 +121,72 @@ lkRrWfQftwmLyNIu3HfSgXlgAZS30ymfbzBU
|
||||||
print {$FH2} "$cert";
|
print {$FH2} "$cert";
|
||||||
close $FH2;
|
close $FH2;
|
||||||
|
|
||||||
|
|
||||||
$res = $client->app->( {
|
$res = $client->app->( {
|
||||||
'plack.request.query' => bless( {
|
'plack.request.query' => bless( {
|
||||||
'skin' => $querytab{'skin'},
|
'skin' => $querytab{'skin'},
|
||||||
'mail_token' => $querytab{'mail_token'}
|
'mail_token' => $querytab{'mail_token'}
|
||||||
}, 'Hash::MultiValue' ),
|
},
|
||||||
|
'Hash::MultiValue'
|
||||||
|
),
|
||||||
'PATH_INFO' => '/certificateReset',
|
'PATH_INFO' => '/certificateReset',
|
||||||
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
|
'HTTP_ACCEPT' =>
|
||||||
|
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
|
||||||
'REQUEST_METHOD' => 'POST',
|
'REQUEST_METHOD' => 'POST',
|
||||||
'HTTP_ORIGIN' => 'http://auth.example.com',
|
'HTTP_ORIGIN' => 'http://auth.example.com',
|
||||||
'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
|
'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
|
||||||
'REQUEST_SCHEME' => 'http',
|
'REQUEST_SCHEME' => 'http',
|
||||||
'HTTP_CACHE_CONTROL' => 'max-age=0',
|
'HTTP_CACHE_CONTROL' => 'max-age=0',
|
||||||
|
|
||||||
|
|
||||||
'plack.request.merged' => bless( {
|
'plack.request.merged' => bless( {
|
||||||
'skin' => $querytab{'skin'},
|
'skin' => $querytab{'skin'},
|
||||||
'mail_token' => $querytab{'mail_token'},
|
'mail_token' => $querytab{'mail_token'},
|
||||||
'url' => '',
|
'url' => '',
|
||||||
'token' => $inputs{'token'}
|
'token' => $inputs{'token'}
|
||||||
}, 'Hash::MultiValue' ),
|
},
|
||||||
|
'Hash::MultiValue'
|
||||||
|
),
|
||||||
'REMOTE_PORT' => '36674',
|
'REMOTE_PORT' => '36674',
|
||||||
'QUERY_STRING' => $querymail,
|
'QUERY_STRING' => $querymail,
|
||||||
'SERVER_SIGNATURE' => '',
|
'SERVER_SIGNATURE' => '',
|
||||||
'psgix.input.buffered' => 1,
|
'psgix.input.buffered' => 1,
|
||||||
'HTTP_UPGRADE_INSECURE_REQUESTS' => '1',
|
'HTTP_UPGRADE_INSECURE_REQUESTS' => '1',
|
||||||
'CONTENT_TYPE' => 'multipart/form-data; boundary=----WebKitFormBoundarybabRY9u6K9tERoLr',
|
'CONTENT_TYPE' =>
|
||||||
|
'multipart/form-data; boundary=----WebKitFormBoundarybabRY9u6K9tERoLr',
|
||||||
'plack.request.upload' => bless( {
|
'plack.request.upload' => bless( {
|
||||||
'certif' => bless( {
|
'certif' => bless( {
|
||||||
'headers' => bless( {
|
'headers' => bless( {
|
||||||
'content-disposition' => 'form-data; name="certif"; filename="user.pem"',
|
'content-disposition' =>
|
||||||
'content-type' => 'application/x-x509-ca-cert',
|
'form-data; name="certif"; filename="user.pem"',
|
||||||
|
'content-type' =>
|
||||||
|
'application/x-x509-ca-cert',
|
||||||
'::std_case' => {
|
'::std_case' => {
|
||||||
'content-disposition' => 'Content-Disposition'
|
'content-disposition' =>
|
||||||
|
'Content-Disposition'
|
||||||
}
|
}
|
||||||
}, 'HTTP::Headers' ),
|
},
|
||||||
|
'HTTP::Headers'
|
||||||
|
),
|
||||||
'filename' => 'user.pem',
|
'filename' => 'user.pem',
|
||||||
'tempname' => '/tmp/v296ZJQ_kG',
|
'tempname' => '/tmp/v296ZJQ_kG',
|
||||||
'size' => 1261
|
'size' => 1261
|
||||||
}, 'Plack::Request::Upload' )
|
},
|
||||||
}, 'Hash::MultiValue' ),
|
'Plack::Request::Upload'
|
||||||
|
)
|
||||||
|
},
|
||||||
|
'Hash::MultiValue'
|
||||||
|
),
|
||||||
'psgi.streaming' => 1,
|
'psgi.streaming' => 1,
|
||||||
'plack.request.body' => bless( {
|
'plack.request.body' => bless( {
|
||||||
'skin' => 'bootstrap',
|
'skin' => 'bootstrap',
|
||||||
'url' => '',
|
'url' => '',
|
||||||
'token' => $inputs{'token'}
|
'token' => $inputs{'token'}
|
||||||
}, 'Hash::MultiValue' ),
|
},
|
||||||
|
'Hash::MultiValue'
|
||||||
|
),
|
||||||
'SCRIPT_URL' => '/certificateReset',
|
'SCRIPT_URL' => '/certificateReset',
|
||||||
'SERVER_NAME' => 'auth.example.com',
|
'SERVER_NAME' => 'auth.example.com',
|
||||||
'HTTP_REFERER' => 'http://auth.example.com/certificateReset?'.$querymail,
|
'HTTP_REFERER' => 'http://auth.example.com/certificateReset?'
|
||||||
|
. $querymail,
|
||||||
'HTTP_CONNECTION' => 'close',
|
'HTTP_CONNECTION' => 'close',
|
||||||
'CONTENT_LENGTH' => '1759',
|
'CONTENT_LENGTH' => '1759',
|
||||||
'SCRIPT_URI' => 'http://auth.example.com/certificateReset',
|
'SCRIPT_URI' => 'http://auth.example.com/certificateReset',
|
||||||
|
@ -176,19 +197,20 @@ lkRrWfQftwmLyNIu3HfSgXlgAZS30ymfbzBU
|
||||||
'SERVER_NAME' => 'auth.example.com',
|
'SERVER_NAME' => 'auth.example.com',
|
||||||
'SERVER_PROTOCOL' => 'HTTP/1.1',
|
'SERVER_PROTOCOL' => 'HTTP/1.1',
|
||||||
'SCRIPT_NAME' => '',
|
'SCRIPT_NAME' => '',
|
||||||
'HTTP_USER_AGENT' => 'Mozilla/5.0 (VAX-4000; rv:36.0) Gecko/20350101 Firefox',
|
'HTTP_USER_AGENT' =>
|
||||||
|
'Mozilla/5.0 (VAX-4000; rv:36.0) Gecko/20350101 Firefox',
|
||||||
'HTTP_COOKIE' => 'llnglanguage=fr',
|
'HTTP_COOKIE' => 'llnglanguage=fr',
|
||||||
'REMOTE_ADDR' => '127.0.0.1',
|
'REMOTE_ADDR' => '127.0.0.1',
|
||||||
'REQUEST_URI' => '/certificateReset?'.$querymail,
|
'REQUEST_URI' => '/certificateReset?' . $querymail,
|
||||||
'plack.cookie.string' => 'llnglanguage=fr',
|
'plack.cookie.string' => 'llnglanguage=fr',
|
||||||
'SERVER_ADDR' => '127.0.0.1',
|
'SERVER_ADDR' => '127.0.0.1',
|
||||||
'psgi.url_scheme' => 'http',
|
'psgi.url_scheme' => 'http',
|
||||||
'psgix.harakiri' => '',
|
'psgix.harakiri' => '',
|
||||||
'HTTP_HOST' => 'auth.example.com'
|
'HTTP_HOST' => 'auth.example.com'
|
||||||
});
|
}
|
||||||
|
);
|
||||||
ok( mail() =~ /Certificate Reset sucessfully/, 'Certificate was changed');
|
|
||||||
|
|
||||||
|
ok( mail() =~ /Certificate Reset sucessfully/, 'Certificate was changed' );
|
||||||
|
|
||||||
}
|
}
|
||||||
count($maintests);
|
count($maintests);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user