Bug 34893: Add unit tests
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
3584cd7edb
commit
795387f519
1 changed files with 48 additions and 1 deletions
|
@ -19,7 +19,7 @@ use Modern::Perl;
|
|||
|
||||
use CGI qw ( -utf8 );
|
||||
|
||||
use Test::More tests => 13;
|
||||
use Test::More tests => 14;
|
||||
use Test::MockModule;
|
||||
use t::lib::Mocks;
|
||||
use t::lib::TestBuilder;
|
||||
|
@ -1043,3 +1043,50 @@ subtest 'GetAvailability itemcallnumber' => sub {
|
|||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'Bug 34893: ILS-DI can return the wrong patron for AuthenticatePatron' => sub {
|
||||
|
||||
plan tests => 2;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $plain_password = 'tomasito';
|
||||
|
||||
$builder->build({
|
||||
source => 'Borrower',
|
||||
value => {
|
||||
cardnumber => undef,
|
||||
}
|
||||
});
|
||||
|
||||
my $borrower0 = $builder->build({
|
||||
source => 'Borrower',
|
||||
value => {
|
||||
cardnumber => "cardnumber1",
|
||||
userid => undef,
|
||||
password => Koha::AuthUtils::hash_password( $plain_password ),
|
||||
lastseen => "2001-01-01 12:34:56"
|
||||
}
|
||||
});
|
||||
|
||||
my $borrower = $builder->build({
|
||||
source => 'Borrower',
|
||||
value => {
|
||||
cardnumber => "cardnumber2",
|
||||
userid => undef,
|
||||
password => Koha::AuthUtils::hash_password( $plain_password ),
|
||||
lastseen => "2001-01-01 12:34:56"
|
||||
}
|
||||
});
|
||||
|
||||
my $query = CGI->new;
|
||||
$query->param( 'username', $borrower->{cardnumber});
|
||||
$query->param( 'password', $plain_password);
|
||||
|
||||
my $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
|
||||
is( $reply->{id}, $borrower->{borrowernumber}, "userid and password - Patron authenticated" );
|
||||
is( $reply->{code}, undef, "Error code undef");
|
||||
my $seen_patron = Koha::Patrons->find({ borrowernumber => $reply->{id} });
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue