Allow wildcard with searching parameters (#1976) & Improve unit tests
This commit is contained in:
parent
554daba5fe
commit
846d6a3655
|
@ -83,6 +83,8 @@ sub defaultValues {
|
||||||
'facebookExportedVars' => {},
|
'facebookExportedVars' => {},
|
||||||
'facebookUserField' => 'id',
|
'facebookUserField' => 'id',
|
||||||
'failedLoginNumber' => 5,
|
'failedLoginNumber' => 5,
|
||||||
|
'findUserControl' => '^[\\w]+$',
|
||||||
|
'findUserWildcard' => '',
|
||||||
'formTimeout' => 120,
|
'formTimeout' => 120,
|
||||||
'githubAuthnLevel' => 1,
|
'githubAuthnLevel' => 1,
|
||||||
'githubScope' => 'user:email',
|
'githubScope' => 'user:email',
|
||||||
|
|
|
@ -1364,6 +1364,10 @@ qr/^(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-
|
||||||
'default' => 0,
|
'default' => 0,
|
||||||
'type' => 'bool'
|
'type' => 'bool'
|
||||||
},
|
},
|
||||||
|
'findUserControl' => {
|
||||||
|
'default' => '^[\\w]+$',
|
||||||
|
'type' => 'pcre'
|
||||||
|
},
|
||||||
'findUserExcludingAttributes' => {
|
'findUserExcludingAttributes' => {
|
||||||
'keyTest' => qr/^\S+$/,
|
'keyTest' => qr/^\S+$/,
|
||||||
'type' => 'keyTextContainer'
|
'type' => 'keyTextContainer'
|
||||||
|
@ -1372,6 +1376,10 @@ qr/^(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-
|
||||||
'keyTest' => qr/^\S+$/,
|
'keyTest' => qr/^\S+$/,
|
||||||
'type' => 'keyTextContainer'
|
'type' => 'keyTextContainer'
|
||||||
},
|
},
|
||||||
|
'findUserWildcard' => {
|
||||||
|
'default' => '',
|
||||||
|
'type' => 'text'
|
||||||
|
},
|
||||||
'forceGlobalStorageIssuerOTT' => {
|
'forceGlobalStorageIssuerOTT' => {
|
||||||
'type' => 'bool'
|
'type' => 'bool'
|
||||||
},
|
},
|
||||||
|
|
|
@ -544,6 +544,16 @@ sub attributes {
|
||||||
keyTest => qr/^\S+$/,
|
keyTest => qr/^\S+$/,
|
||||||
documentation => 'Attributes used for excluding accounts',
|
documentation => 'Attributes used for excluding accounts',
|
||||||
},
|
},
|
||||||
|
findUserWildcard => {
|
||||||
|
type => 'text',
|
||||||
|
default => '',
|
||||||
|
documentation => 'Character used as wildcard',
|
||||||
|
},
|
||||||
|
findUserControl => {
|
||||||
|
type => 'pcre',
|
||||||
|
default => '^[\w]+$',
|
||||||
|
documentation => 'Regular expression to validate parameters',
|
||||||
|
},
|
||||||
globalLogoutRule => {
|
globalLogoutRule => {
|
||||||
type => 'boolOrExpr',
|
type => 'boolOrExpr',
|
||||||
default => 0,
|
default => 0,
|
||||||
|
|
|
@ -789,6 +789,8 @@ sub tree {
|
||||||
help => 'finduser.html',
|
help => 'finduser.html',
|
||||||
nodes => [
|
nodes => [
|
||||||
'findUser',
|
'findUser',
|
||||||
|
'findUserWildcard',
|
||||||
|
'findUserControl',
|
||||||
'findUserSearchingAttributes',
|
'findUserSearchingAttributes',
|
||||||
'findUserExcludingAttributes'
|
'findUserExcludingAttributes'
|
||||||
]
|
]
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"الملف الذي ستحمله",
|
"fileToUpload":"الملف الذي ستحمله",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Search for user account",
|
"findUsers":"Search for user account",
|
||||||
"findUserSearchingAttributes":"Searching attributes",
|
"findUserControl":"Parameters control",
|
||||||
"findUserExcludingAttributes":"Excluding attributes",
|
"findUserExcludingAttributes":"Excluding attributes",
|
||||||
|
"findUserSearchingAttributes":"Searching attributes",
|
||||||
|
"findUserWildcard":"Character used as wildcard",
|
||||||
"forbidden":"لست مخولا بعرض هذه الصفحة",
|
"forbidden":"لست مخولا بعرض هذه الصفحة",
|
||||||
"forceSave":"فرض الحفظ",
|
"forceSave":"فرض الحفظ",
|
||||||
"format":"الصيغة",
|
"format":"الصيغة",
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"File to upload",
|
"fileToUpload":"File to upload",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Search for user account",
|
"findUsers":"Search for user account",
|
||||||
"findUserSearchingAttributes":"Searching attributes",
|
"findUserControl":"Parameters control",
|
||||||
"findUserExcludingAttributes":"Excluding attributes",
|
"findUserExcludingAttributes":"Excluding attributes",
|
||||||
|
"findUserSearchingAttributes":"Searching attributes",
|
||||||
|
"findUserWildcard":"Character used as wildcard",
|
||||||
"forbidden":"You're not authorized to show this page",
|
"forbidden":"You're not authorized to show this page",
|
||||||
"forceSave":"Force save",
|
"forceSave":"Force save",
|
||||||
"format":"Format",
|
"format":"Format",
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"File to upload",
|
"fileToUpload":"File to upload",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Search for user account",
|
"findUsers":"Search for user account",
|
||||||
"findUserSearchingAttributes":"Searching attributes",
|
"findUserControl":"Parameters control",
|
||||||
"findUserExcludingAttributes":"Excluding attributes",
|
"findUserExcludingAttributes":"Excluding attributes",
|
||||||
|
"findUserSearchingAttributes":"Searching attributes",
|
||||||
|
"findUserWildcard":"Character used as wildcard",
|
||||||
"forbidden":"You're not authorized to show this page",
|
"forbidden":"You're not authorized to show this page",
|
||||||
"forceSave":"Force save",
|
"forceSave":"Force save",
|
||||||
"format":"Format",
|
"format":"Format",
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"Fichero a cargar",
|
"fileToUpload":"Fichero a cargar",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Search for user account",
|
"findUsers":"Search for user account",
|
||||||
"findUserSearchingAttributes":"Searching attributes",
|
"findUserControl":"Parameters control",
|
||||||
"findUserExcludingAttributes":"Excluding attributes",
|
"findUserExcludingAttributes":"Excluding attributes",
|
||||||
|
"findUserSearchingAttributes":"Searching attributes",
|
||||||
|
"findUserWildcard":"Character used as wildcard",
|
||||||
"forbidden":"No está autorizado a mostrar esta página",
|
"forbidden":"No está autorizado a mostrar esta página",
|
||||||
"forceSave":"Forzar salvaguarda",
|
"forceSave":"Forzar salvaguarda",
|
||||||
"format":"Formato",
|
"format":"Formato",
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"Fichier à télécharger",
|
"fileToUpload":"Fichier à télécharger",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Recherche de compte",
|
"findUsers":"Recherche de compte",
|
||||||
"findUserSearchingAttributes":"Attributs de recherche",
|
"findUserControl":"Contrôle des paramètres",
|
||||||
"findUserExcludingAttributes":"Attributs d'exclusion",
|
"findUserExcludingAttributes":"Attributs d'exclusion",
|
||||||
|
"findUserSearchingAttributes":"Attributs de recherche",
|
||||||
|
"findUserWildcard":"Caractère utilisé comme joker",
|
||||||
"forbidden":"Vous n'êtes pas autorisé à visualiser cette page",
|
"forbidden":"Vous n'êtes pas autorisé à visualiser cette page",
|
||||||
"forceSave":"Forcer la sauvegarde",
|
"forceSave":"Forcer la sauvegarde",
|
||||||
"format":"Format",
|
"format":"Format",
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"File da caricare",
|
"fileToUpload":"File da caricare",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Search for user account",
|
"findUsers":"Search for user account",
|
||||||
"findUserSearchingAttributes":"Searching attributes",
|
"findUserControl":"Parameters control",
|
||||||
"findUserExcludingAttributes":"Excluding attributes",
|
"findUserExcludingAttributes":"Excluding attributes",
|
||||||
|
"findUserSearchingAttributes":"Searching attributes",
|
||||||
|
"findUserWildcard":"Character used as wildcard",
|
||||||
"forbidden":"Non sei autorizzato a mostrare questa pagina",
|
"forbidden":"Non sei autorizzato a mostrare questa pagina",
|
||||||
"forceSave":"Forza salvataggio",
|
"forceSave":"Forza salvataggio",
|
||||||
"format":"Formato",
|
"format":"Formato",
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"Plik do przesłania",
|
"fileToUpload":"Plik do przesłania",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Search for user account",
|
"findUsers":"Search for user account",
|
||||||
"findUserSearchingAttributes":"Searching attributes",
|
"findUserControl":"Parameters control",
|
||||||
"findUserExcludingAttributes":"Excluding attributes",
|
"findUserExcludingAttributes":"Excluding attributes",
|
||||||
|
"findUserSearchingAttributes":"Searching attributes",
|
||||||
|
"findUserWildcard":"Character used as wildcard",
|
||||||
"forbidden":"Nie masz uprawnień do wyświetlania tej strony",
|
"forbidden":"Nie masz uprawnień do wyświetlania tej strony",
|
||||||
"forceSave":"Wymuś zapis",
|
"forceSave":"Wymuś zapis",
|
||||||
"format":"Format",
|
"format":"Format",
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"Yüklenecek dosya",
|
"fileToUpload":"Yüklenecek dosya",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Search for user account",
|
"findUsers":"Search for user account",
|
||||||
"findUserSearchingAttributes":"Searching attributes",
|
"findUserControl":"Parameters control",
|
||||||
"findUserExcludingAttributes":"Excluding attributes",
|
"findUserExcludingAttributes":"Excluding attributes",
|
||||||
|
"findUserSearchingAttributes":"Searching attributes",
|
||||||
|
"findUserWildcard":"Character used as wildcard",
|
||||||
"forbidden":"Bu sayfayı görüntülemek için yetkili değilsiniz",
|
"forbidden":"Bu sayfayı görüntülemek için yetkili değilsiniz",
|
||||||
"forceSave":"Kaydetmeye zorla",
|
"forceSave":"Kaydetmeye zorla",
|
||||||
"format":"Biçim",
|
"format":"Biçim",
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"Tập tin để tải lên",
|
"fileToUpload":"Tập tin để tải lên",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Search for user account",
|
"findUsers":"Search for user account",
|
||||||
"findUserSearchingAttributes":"Searching attributes",
|
"findUserControl":"Parameters control",
|
||||||
"findUserExcludingAttributes":"Excluding attributes",
|
"findUserExcludingAttributes":"Excluding attributes",
|
||||||
|
"findUserSearchingAttributes":"Searching attributes",
|
||||||
|
"findUserWildcard":"Character used as wildcard",
|
||||||
"forbidden":"Bạn không được ủy quyền để hiển thị trang này",
|
"forbidden":"Bạn không được ủy quyền để hiển thị trang này",
|
||||||
"forceSave":"Bắt buộc lưu",
|
"forceSave":"Bắt buộc lưu",
|
||||||
"format":"Định dạng",
|
"format":"Định dạng",
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"上传的文件",
|
"fileToUpload":"上传的文件",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Search for user account",
|
"findUsers":"Search for user account",
|
||||||
"findUserSearchingAttributes":"Searching attributes",
|
"findUserControl":"Parameters control",
|
||||||
"findUserExcludingAttributes":"Excluding attributes",
|
"findUserExcludingAttributes":"Excluding attributes",
|
||||||
|
"findUserSearchingAttributes":"Searching attributes",
|
||||||
|
"findUserWildcard":"Character used as wildcard",
|
||||||
"forbidden":"You're not authorized to show this page",
|
"forbidden":"You're not authorized to show this page",
|
||||||
"forceSave":"强制保存",
|
"forceSave":"强制保存",
|
||||||
"format":"格式",
|
"format":"格式",
|
||||||
|
|
|
@ -331,8 +331,10 @@
|
||||||
"fileToUpload":"上傳失敗",
|
"fileToUpload":"上傳失敗",
|
||||||
"findUser":"Activation",
|
"findUser":"Activation",
|
||||||
"findUsers":"Search for user account",
|
"findUsers":"Search for user account",
|
||||||
"findUserSearchingAttributes":"Searching attributes",
|
"findUserControl":"Parameters control",
|
||||||
"findUserExcludingAttributes":"Excluding attributes",
|
"findUserExcludingAttributes":"Excluding attributes",
|
||||||
|
"findUserSearchingAttributes":"Searching attributes",
|
||||||
|
"findUserWildcard":"Character used as wildcard",
|
||||||
"forbidden":"您無權顯示此頁面",
|
"forbidden":"您無權顯示此頁面",
|
||||||
"forceSave":"強制儲存",
|
"forceSave":"強制儲存",
|
||||||
"format":"格式",
|
"format":"格式",
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -181,7 +181,17 @@ sub findUser {
|
||||||
|
|
||||||
$self->findUserFilter =~ /\bobjectClass=(\w+)\b/;
|
$self->findUserFilter =~ /\bobjectClass=(\w+)\b/;
|
||||||
my $filter = "(&(objectClass=$1)";
|
my $filter = "(&(objectClass=$1)";
|
||||||
$filter .= "($_->{key}=$_->{value})" foreach (@$searching);
|
my $wildcard = $self->conf->{findUserWildcard};
|
||||||
|
$self->logger->info("LDAP UserDB with wildcard ($wildcard)") if $wildcard;
|
||||||
|
foreach (@$searching) {
|
||||||
|
if ($wildcard) {
|
||||||
|
$_->{value} =~ s/\Q$wildcard\E+/*/;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$_->{value} =~ s/\Q*\E+//;
|
||||||
|
}
|
||||||
|
$filter .= "($_->{key}=$_->{value})";
|
||||||
|
}
|
||||||
$filter .= "(!($_->{key}=$_->{value}))" foreach (@$excluding);
|
$filter .= "(!($_->{key}=$_->{value}))" foreach (@$excluding);
|
||||||
$filter .= ')';
|
$filter .= ')';
|
||||||
$self->logger->debug("LDAP UserDB built filter: $filter");
|
$self->logger->debug("LDAP UserDB built filter: $filter");
|
||||||
|
|
|
@ -62,11 +62,14 @@ sub findUser {
|
||||||
|
|
||||||
my $table = $self->table;
|
my $table = $self->table;
|
||||||
my $pivot = $args{useMail} ? $self->mailField : $self->pivot;
|
my $pivot = $args{useMail} ? $self->mailField : $self->pivot;
|
||||||
my $request = "SELECT $pivot FROM $table WHERE ";
|
|
||||||
my @args;
|
my @args;
|
||||||
my $sth;
|
my $request = "SELECT $pivot FROM $table WHERE ";
|
||||||
|
my ( $iswc, $sth );
|
||||||
|
my $wildcard = $self->conf->{findUserWildcard};
|
||||||
|
$self->logger->info("DBI UserDB with wildcard ($wildcard)") if $wildcard;
|
||||||
foreach (@$searching) {
|
foreach (@$searching) {
|
||||||
$request .= "$_->{key} = ? AND ";
|
$iswc = $_->{value} =~ s/\Q$wildcard\E+/%/ if $wildcard;
|
||||||
|
$request .= $iswc ? "$_->{key} LIKE ? AND " : "$_->{key} = ? AND ";
|
||||||
push @args, $_->{value};
|
push @args, $_->{value};
|
||||||
}
|
}
|
||||||
foreach (@$excluding) {
|
foreach (@$excluding) {
|
||||||
|
|
|
@ -85,8 +85,23 @@ sub findUser {
|
||||||
eval { $self->p->_authentication->setSecurity($req) };
|
eval { $self->p->_authentication->setSecurity($req) };
|
||||||
return PE_OK unless scalar @$searching;
|
return PE_OK unless scalar @$searching;
|
||||||
|
|
||||||
|
my $iswc;
|
||||||
my $cond = '';
|
my $cond = '';
|
||||||
$cond .= '$' . $_->{key} . " eq '$_->{value}' && " foreach (@$searching);
|
my $wildcard = $self->conf->{findUserWildcard};
|
||||||
|
$self->logger->info("Demo UserDB with wildcard ($wildcard)") if $wildcard;
|
||||||
|
foreach (@$searching) {
|
||||||
|
if ($wildcard) {
|
||||||
|
$iswc = $_->{value} =~ s/\Q$wildcard\E+//;
|
||||||
|
my $val = $_->{value};
|
||||||
|
$cond .=
|
||||||
|
$iswc
|
||||||
|
? '( $' . $_->{key} . " =~ /$val/ ) && "
|
||||||
|
: '$' . $_->{key} . " eq '$_->{value}' && ";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$cond .= '$' . $_->{key} . " eq '$_->{value}' && ";
|
||||||
|
}
|
||||||
|
}
|
||||||
$cond .= '$' . $_->{key} . " ne '$_->{value}' && " foreach (@$excluding);
|
$cond .= '$' . $_->{key} . " ne '$_->{value}' && " foreach (@$excluding);
|
||||||
$cond =~ s/&&\s$//;
|
$cond =~ s/&&\s$//;
|
||||||
$self->logger->debug("Demo UserDB built condition: $cond");
|
$self->logger->debug("Demo UserDB built condition: $cond");
|
||||||
|
|
|
@ -5,7 +5,7 @@ use IO::String;
|
||||||
|
|
||||||
require 't/test-lib.pm';
|
require 't/test-lib.pm';
|
||||||
|
|
||||||
my $maintests = 46;
|
my $maintests = 54;
|
||||||
my $userdb = tempdb();
|
my $userdb = tempdb();
|
||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
|
@ -55,6 +55,7 @@ SKIP: {
|
||||||
useSafeJail => 1,
|
useSafeJail => 1,
|
||||||
requireToken => 0,
|
requireToken => 0,
|
||||||
findUser => 1,
|
findUser => 1,
|
||||||
|
findUserWildcard => '#',
|
||||||
impersonationRule => 1,
|
impersonationRule => 1,
|
||||||
findUserSearchingAttributes => {
|
findUserSearchingAttributes => {
|
||||||
uid => 'Login',
|
uid => 'Login',
|
||||||
|
@ -282,6 +283,38 @@ m%<input id="findUser_room" name="room" type="text" autocomplete="off" class="fo
|
||||||
or explain( $json, 'result => 1' );
|
or explain( $json, 'result => 1' );
|
||||||
ok( $json->{user} =~ /^(dwho|msmith|davros)$/, " Good user ($1)" )
|
ok( $json->{user} =~ /^(dwho|msmith|davros)$/, " Good user ($1)" )
|
||||||
or explain( $json, "user => ?" );
|
or explain( $json, "user => ?" );
|
||||||
|
|
||||||
|
$request = 'uid=d%';
|
||||||
|
ok(
|
||||||
|
$res = $client->_post(
|
||||||
|
'/finduser', IO::String->new($request),
|
||||||
|
accept => 'application/json',
|
||||||
|
length => length($request)
|
||||||
|
),
|
||||||
|
'Post FindFuser request with bad wildcard'
|
||||||
|
);
|
||||||
|
ok( $json = eval { from_json( $res->[2]->[0] ) }, 'Response is JSON' )
|
||||||
|
or print STDERR "$@\n" . Dumper($res);
|
||||||
|
ok( $json->{result} == 0, ' Good result' )
|
||||||
|
or explain( $json, 'result => 0' );
|
||||||
|
ok( $json->{error} == PE_USERNOTFOUND, ' No user found' )
|
||||||
|
or explain( $json, 'error => 4' );
|
||||||
|
|
||||||
|
$request = 'uid=d#';
|
||||||
|
ok(
|
||||||
|
$res = $client->_post(
|
||||||
|
'/finduser', IO::String->new($request),
|
||||||
|
accept => 'application/json',
|
||||||
|
length => length($request)
|
||||||
|
),
|
||||||
|
'Post FindFuser request with wildcard'
|
||||||
|
);
|
||||||
|
ok( $json = eval { from_json( $res->[2]->[0] ) }, 'Response is JSON' )
|
||||||
|
or print STDERR "$@\n" . Dumper($res);
|
||||||
|
ok( $json->{result} == 1, ' Good result' )
|
||||||
|
or explain( $json, 'result => 1' );
|
||||||
|
ok( $json->{user} =~ /^(dwho|davros)$/, " Good user ($1)" )
|
||||||
|
or explain( $json, "user => ?" );
|
||||||
}
|
}
|
||||||
count($maintests);
|
count($maintests);
|
||||||
done_testing( count() );
|
done_testing( count() );
|
||||||
|
|
|
@ -5,7 +5,7 @@ use IO::String;
|
||||||
|
|
||||||
require 't/test-lib.pm';
|
require 't/test-lib.pm';
|
||||||
|
|
||||||
my $maintests = 42;
|
my $maintests = 46;
|
||||||
|
|
||||||
my $res;
|
my $res;
|
||||||
my $json;
|
my $json;
|
||||||
|
@ -19,6 +19,7 @@ my $client = LLNG::Manager::Test->new( {
|
||||||
requireToken => 0,
|
requireToken => 0,
|
||||||
findUser => 1,
|
findUser => 1,
|
||||||
impersonationRule => 1,
|
impersonationRule => 1,
|
||||||
|
findUserWildcard => '*',
|
||||||
findUserSearchingAttributes =>
|
findUserSearchingAttributes =>
|
||||||
{ uid => 'Login', guy => 'Kind', cn => 'Name' },
|
{ uid => 'Login', guy => 'Kind', cn => 'Name' },
|
||||||
findUserExcludingAttributes =>
|
findUserExcludingAttributes =>
|
||||||
|
@ -221,5 +222,21 @@ ok( $json->{result} == 0, ' Good result' )
|
||||||
ok( $json->{error} == PE_USERNOTFOUND, ' No user found' )
|
ok( $json->{error} == PE_USERNOTFOUND, ' No user found' )
|
||||||
or explain( $json, 'error => 4' );
|
or explain( $json, 'error => 4' );
|
||||||
|
|
||||||
|
$request = 'uid=d*';
|
||||||
|
ok(
|
||||||
|
$res = $client->_post(
|
||||||
|
'/finduser', IO::String->new($request),
|
||||||
|
accept => 'application/json',
|
||||||
|
length => length($request)
|
||||||
|
),
|
||||||
|
'Post FindFuser request with wildcard'
|
||||||
|
);
|
||||||
|
ok( $json = eval { from_json( $res->[2]->[0] ) }, 'Response is JSON' )
|
||||||
|
or print STDERR "$@\n" . Dumper($res);
|
||||||
|
ok( $json->{result} == 1, ' Good result' )
|
||||||
|
or explain( $json, 'result => 1' );
|
||||||
|
ok( $json->{user} =~ /^(dwho|davros)$/, " Good user ($1)" )
|
||||||
|
or explain( $json, "user => ?" );
|
||||||
|
|
||||||
count($maintests);
|
count($maintests);
|
||||||
done_testing( count() );
|
done_testing( count() );
|
||||||
|
|
|
@ -8,7 +8,7 @@ require 't/test-lib.pm';
|
||||||
my $res;
|
my $res;
|
||||||
my $json;
|
my $json;
|
||||||
my $request;
|
my $request;
|
||||||
my $maintests = 42;
|
my $maintests = 46;
|
||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip 'LLNGTESTLDAP is not set', $maintests unless ( $ENV{LLNGTESTLDAP} );
|
skip 'LLNGTESTLDAP is not set', $maintests unless ( $ENV{LLNGTESTLDAP} );
|
||||||
|
@ -35,6 +35,7 @@ SKIP: {
|
||||||
requireToken => 0,
|
requireToken => 0,
|
||||||
findUser => 1,
|
findUser => 1,
|
||||||
impersonationRule => 1,
|
impersonationRule => 1,
|
||||||
|
findUserWildcard => '#',
|
||||||
findUserSearchingAttributes =>
|
findUserSearchingAttributes =>
|
||||||
{ uid => 'Login', roomNumber => 'Room', cn => 'Name' },
|
{ uid => 'Login', roomNumber => 'Room', cn => 'Name' },
|
||||||
findUserExcludingAttributes =>
|
findUserExcludingAttributes =>
|
||||||
|
@ -238,6 +239,22 @@ m%<input id="findUser_cn" name="cn" type="text" autocomplete="off" class="form-c
|
||||||
ok( $json->{error} == PE_USERNOTFOUND, ' No user found' )
|
ok( $json->{error} == PE_USERNOTFOUND, ' No user found' )
|
||||||
or explain( $json, 'error => 4' );
|
or explain( $json, 'error => 4' );
|
||||||
|
|
||||||
|
$request = 'uid=r#';
|
||||||
|
ok(
|
||||||
|
$res = $client->_post(
|
||||||
|
'/finduser', IO::String->new($request),
|
||||||
|
accept => 'application/json',
|
||||||
|
length => length($request)
|
||||||
|
),
|
||||||
|
'Post FindFuser request with wildcard'
|
||||||
|
);
|
||||||
|
ok( $json = eval { from_json( $res->[2]->[0] ) }, 'Response is JSON' )
|
||||||
|
or print STDERR "$@\n" . Dumper($res);
|
||||||
|
ok( $json->{result} == 1, ' Good result' )
|
||||||
|
or explain( $json, 'result => 1' );
|
||||||
|
ok( $json->{user} =~ /^(reset|rtyler)$/, " Good user ($1)" )
|
||||||
|
or explain( $json, "user => ?" );
|
||||||
|
|
||||||
clean_sessions();
|
clean_sessions();
|
||||||
}
|
}
|
||||||
count($maintests);
|
count($maintests);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user