|
Lines 28-33
use C4::Items qw( ModItemTransfer );
Link Here
|
| 28 |
use C4::Circulation qw( AddIssue ); |
28 |
use C4::Circulation qw( AddIssue ); |
| 29 |
|
29 |
|
| 30 |
use Koha::AuthUtils; |
30 |
use Koha::AuthUtils; |
|
|
31 |
use Koha::DateUtils; |
| 31 |
|
32 |
|
| 32 |
BEGIN { |
33 |
BEGIN { |
| 33 |
use_ok('C4::ILSDI::Services', qw( AuthenticatePatron GetPatronInfo LookupPatron HoldTitle HoldItem GetRecords RenewLoan )); |
34 |
use_ok('C4::ILSDI::Services', qw( AuthenticatePatron GetPatronInfo LookupPatron HoldTitle HoldItem GetRecords RenewLoan )); |
|
Lines 39-45
my $builder = t::lib::TestBuilder->new;
Link Here
|
| 39 |
|
40 |
|
| 40 |
subtest 'AuthenticatePatron test' => sub { |
41 |
subtest 'AuthenticatePatron test' => sub { |
| 41 |
|
42 |
|
| 42 |
plan tests => 14; |
43 |
plan tests => 16; |
| 43 |
|
44 |
|
| 44 |
$schema->storage->txn_begin; |
45 |
$schema->storage->txn_begin; |
| 45 |
|
46 |
|
|
Lines 56-62
subtest 'AuthenticatePatron test' => sub {
Link Here
|
| 56 |
source => 'Borrower', |
57 |
source => 'Borrower', |
| 57 |
value => { |
58 |
value => { |
| 58 |
cardnumber => undef, |
59 |
cardnumber => undef, |
| 59 |
password => Koha::AuthUtils::hash_password( $plain_password ) |
60 |
password => Koha::AuthUtils::hash_password( $plain_password ), |
|
|
61 |
lastseen => "2001-01-01" |
| 60 |
} |
62 |
} |
| 61 |
}); |
63 |
}); |
| 62 |
|
64 |
|
|
Lines 64-72
subtest 'AuthenticatePatron test' => sub {
Link Here
|
| 64 |
$query->param( 'username', $borrower->{userid}); |
66 |
$query->param( 'username', $borrower->{userid}); |
| 65 |
$query->param( 'password', $plain_password); |
67 |
$query->param( 'password', $plain_password); |
| 66 |
|
68 |
|
|
|
69 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '' ); |
| 67 |
my $reply = C4::ILSDI::Services::AuthenticatePatron( $query ); |
70 |
my $reply = C4::ILSDI::Services::AuthenticatePatron( $query ); |
| 68 |
is( $reply->{id}, $borrower->{borrowernumber}, "userid and password - Patron authenticated" ); |
71 |
is( $reply->{id}, $borrower->{borrowernumber}, "userid and password - Patron authenticated" ); |
| 69 |
is( $reply->{code}, undef, "Error code undef"); |
72 |
is( $reply->{code}, undef, "Error code undef"); |
|
|
73 |
my $seen_patron = Koha::Patrons->find({ borrowernumber => $reply->{id} }); |
| 74 |
is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({str => '2001-01-01', dateonly => 1}),'Last seen not updated if not tracking patrons'); |
| 70 |
|
75 |
|
| 71 |
$query->param('password','ilsdi-passworD'); |
76 |
$query->param('password','ilsdi-passworD'); |
| 72 |
$reply = C4::ILSDI::Services::AuthenticatePatron( $query ); |
77 |
$reply = C4::ILSDI::Services::AuthenticatePatron( $query ); |
|
Lines 79-88
subtest 'AuthenticatePatron test' => sub {
Link Here
|
| 79 |
is( $reply->{code}, 'PatronNotFound', "non-existing userid - PatronNotFound" ); |
84 |
is( $reply->{code}, 'PatronNotFound', "non-existing userid - PatronNotFound" ); |
| 80 |
is( $reply->{id}, undef, "id undef"); |
85 |
is( $reply->{id}, undef, "id undef"); |
| 81 |
|
86 |
|
|
|
87 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' ); |
| 82 |
$query->param( 'username', uc( $borrower->{userid} )); |
88 |
$query->param( 'username', uc( $borrower->{userid} )); |
| 83 |
$reply = C4::ILSDI::Services::AuthenticatePatron( $query ); |
89 |
$reply = C4::ILSDI::Services::AuthenticatePatron( $query ); |
| 84 |
is( $reply->{id}, $borrower->{borrowernumber}, "userid is not case sensitive - Patron authenticated" ); |
90 |
is( $reply->{id}, $borrower->{borrowernumber}, "userid is not case sensitive - Patron authenticated" ); |
| 85 |
is( $reply->{code}, undef, "Error code undef"); |
91 |
is( $reply->{code}, undef, "Error code undef"); |
|
|
92 |
$seen_patron = Koha::Patrons->find({ borrowernumber => $reply->{id} }); |
| 93 |
is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({dt => dt_from_string(), dateonly => 1}),'Last seen updated to today if tracking patrons'); |
| 86 |
|
94 |
|
| 87 |
$query->param( 'username', $borrower->{cardnumber} ); |
95 |
$query->param( 'username', $borrower->{cardnumber} ); |
| 88 |
$reply = C4::ILSDI::Services::AuthenticatePatron( $query ); |
96 |
$reply = C4::ILSDI::Services::AuthenticatePatron( $query ); |
| 89 |
- |
|
|