Append unit test (#1956)
This commit is contained in:
parent
f188426f8b
commit
c312955603
File diff suppressed because one or more lines are too long
|
@ -262,6 +262,7 @@ site/htdocs/static/common/fr.png
|
|||
site/htdocs/static/common/icons/application_cascade.png
|
||||
site/htdocs/static/common/icons/arrow_refresh.png
|
||||
site/htdocs/static/common/icons/calendar.png
|
||||
site/htdocs/static/common/icons/decryptValue.png
|
||||
site/htdocs/static/common/icons/door_out.png
|
||||
site/htdocs/static/common/icons/key.png
|
||||
site/htdocs/static/common/icons/oidc.png
|
||||
|
@ -481,6 +482,7 @@ t/30-Auth-SAML-with-choice.t
|
|||
t/30-CDC.t
|
||||
t/30-SAML-Head-to-Tail-POST.t
|
||||
t/30-SAML-POST-Logout-when-expired.t
|
||||
t/30-SAML-POST-with-2F-and-Notification.t
|
||||
t/30-SAML-POST-with-Notification.t
|
||||
t/30-SAML-ReAuth-with-choice.t
|
||||
t/30-SAML-ReAuth.t
|
||||
|
@ -559,6 +561,8 @@ t/43-MailPasswordReset-with-captcha.t
|
|||
t/43-MailPasswordReset-with-token.t
|
||||
t/43-MailPasswordReset.t
|
||||
t/50-IssuerGet.t
|
||||
t/58-DecryptValue-with-custom-function.t
|
||||
t/58-DecryptValue-with-internal-function.t
|
||||
t/59-Double-cookies-for-a-Single-session.t
|
||||
t/59-Double-cookies-for-Double-sessions.t
|
||||
t/59-Double-cookies-Refresh-and-Logout.t
|
||||
|
@ -629,6 +633,7 @@ t/lib/Apache/Session/Timeout.pm
|
|||
t/lib/Lemonldap/NG/Common/Conf/Backends/Timeout.pm
|
||||
t/lib/Lemonldap/NG/Handler/Test.pm
|
||||
t/lib/Lemonldap/NG/Portal/Auth/LDAPPolicy.pm
|
||||
t/lib/Lemonldap/NG/Portal/Custom.pm
|
||||
t/lmConf-1.json
|
||||
t/pdata.pm
|
||||
t/README.md
|
||||
|
|
97
lemonldap-ng-portal/t/58-DecryptValue-with-custom-function.t
Normal file
97
lemonldap-ng-portal/t/58-DecryptValue-with-custom-function.t
Normal file
|
@ -0,0 +1,97 @@
|
|||
use Test::More;
|
||||
use strict;
|
||||
use IO::String;
|
||||
use lib 't/lib';
|
||||
|
||||
BEGIN {
|
||||
require 't/test-lib.pm';
|
||||
}
|
||||
|
||||
my $res;
|
||||
|
||||
my $client = LLNG::Manager::Test->new( {
|
||||
ini => {
|
||||
logLevel => 'error',
|
||||
authentication => 'Demo',
|
||||
userDB => 'Same',
|
||||
loginHistoryEnabled => 0,
|
||||
brutForceProtection => 0,
|
||||
requireToken => 0,
|
||||
decryptValueRule => 1,
|
||||
decryptValueFunctions =>
|
||||
'Custom::empty Custom::test_uc Custom::undefined',
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
## Try to authenticate
|
||||
ok( $res = $client->_get( '/', accept => 'text/html' ), 'Get Menu', );
|
||||
count(1);
|
||||
my ( $host, $url, $query ) = expectForm( $res, '#', undef, 'user', 'password' );
|
||||
|
||||
$query = 'user=dwho&password=dwho';
|
||||
ok(
|
||||
$res = $client->_post(
|
||||
'/',
|
||||
IO::String->new($query),
|
||||
length => length($query),
|
||||
accept => 'text/html',
|
||||
),
|
||||
'Auth query'
|
||||
);
|
||||
|
||||
my $id = expectCookie($res);
|
||||
expectRedirection( $res, 'http://auth.example.com/' );
|
||||
ok(
|
||||
$res = $client->_get(
|
||||
'/',
|
||||
cookie => "lemonldap=$id",
|
||||
accept => 'text/html'
|
||||
),
|
||||
'CheckUser form',
|
||||
);
|
||||
ok( $res->[2]->[0] =~ m%<img src="/static/common/icons/decryptValue\.png"%,
|
||||
'Found decryptValue.png' )
|
||||
or explain( $res->[2]->[0], 'decryptValue.png' );
|
||||
count(3);
|
||||
|
||||
# CheckUser form
|
||||
# ------------------------
|
||||
ok(
|
||||
$res = $client->_get(
|
||||
'/decryptvalue',
|
||||
cookie => "lemonldap=$id",
|
||||
accept => 'text/html'
|
||||
),
|
||||
'DecryptValue form',
|
||||
);
|
||||
( $host, $url, $query ) =
|
||||
expectForm( $res, undef, '/decryptvalue', 'cipheredValue' );
|
||||
ok( $res->[2]->[0] =~ m%<span trspan="decryptCipheredValue">%,
|
||||
'Found trspan="decryptCipheredValue"' )
|
||||
or explain( $res->[2]->[0], 'trspan="decryptCipheredValue"' );
|
||||
count(2);
|
||||
|
||||
# Valid ciphered value
|
||||
$query =~
|
||||
s%cipheredValue=%cipheredValue=lowercase%;
|
||||
ok(
|
||||
$res = $client->_post(
|
||||
'/decryptvalue',
|
||||
IO::String->new($query),
|
||||
cookie => "lemonldap=$id",
|
||||
length => length($query),
|
||||
accept => 'text/html',
|
||||
),
|
||||
'POST decryptvalue with valid value'
|
||||
);
|
||||
ok( $res->[2]->[0] =~ m%<span trspan="LOWERCASE"></span>%, 'Found decryted value' )
|
||||
or explain( $res->[2]->[0], 'Decryted value NOT found' );
|
||||
count(2);
|
||||
( $host, $url, $query ) =
|
||||
expectForm( $res, undef, '/decryptvalue', 'cipheredValue' );
|
||||
|
||||
$client->logout($id);
|
||||
clean_sessions();
|
||||
|
||||
done_testing( count() );
|
15
lemonldap-ng-portal/t/lib/Lemonldap/NG/Portal/Custom.pm
Normal file
15
lemonldap-ng-portal/t/lib/Lemonldap/NG/Portal/Custom.pm
Normal file
|
@ -0,0 +1,15 @@
|
|||
package Custom;
|
||||
|
||||
sub empty {
|
||||
return '';
|
||||
}
|
||||
|
||||
sub undefined {
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub test_uc {
|
||||
return uc $_[0];
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user