Bugzilla – Attachment 20884 Details for
Bug 10667
ILS-DI: AuthenticatePatron should also work with cardnumber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10667: Add unit tests for ILSDI::Services::AuthenticatePatron
Bug-10667-Add-unit-tests-for-ILSDIServicesAuthenti.patch (text/plain), 4.47 KB, created by
Katrin Fischer
on 2013-09-08 19:49:16 UTC
(
hide
)
Description:
Bug 10667: Add unit tests for ILSDI::Services::AuthenticatePatron
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2013-09-08 19:49:16 UTC
Size:
4.47 KB
patch
obsolete
>From 807131e5175c5d633d1be8ae95ead026b0ea4cee Mon Sep 17 00:00:00 2001 >From: Katrin Fischer <Katrin.Fischer.83@web.de> >Date: Sun, 8 Sep 2013 21:34:37 +0200 >Subject: [PATCH] Bug 10667: Add unit tests for > ILSDI::Services::AuthenticatePatron > >This patch adds unit tests for Authenticate patron. > >To test: >- Run perl t/db_dependent/ILSDI_Services.t >- Verify all tests pass > >Note: there are some tests marked as TODO. > >Rewriting AuthenticatePatron to make cardnumber and userid >work for authenticating a patron will be implemented in the >next patch. Tests related to this are currently showing as >'not ok', but are still passing. >--- > C4/ILSDI/Services.pm | 1 + > t/db_dependent/ILSDI_Services.t | 94 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 95 insertions(+) > create mode 100644 t/db_dependent/ILSDI_Services.t > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index dd43743..eff483d 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -34,6 +34,7 @@ use XML::Simple; > use HTML::Entities; > use CGI; > use DateTime; >+use C4::Auth; > > =head1 NAME > >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >new file mode 100644 >index 0000000..5ceebaa >--- /dev/null >+++ b/t/db_dependent/ILSDI_Services.t >@@ -0,0 +1,94 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use C4::Members qw/AddMember GetMember GetBorrowercategory/; >+use C4::Branch; >+use CGI; >+ >+use Test::More tests => 15; >+ >+BEGIN { >+ use_ok('C4::ILSDI::Services'); >+} >+ >+my $dbh = C4::Context->dbh; >+ >+# Start transaction >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+# Create patron >+my %data = ( >+ firstname => 'my firstname', >+ surname => 'my surname', >+ categorycode => 'UT', >+ branchcode => 'UT', >+ cardnumber => 'ilsdi-cardnumber', >+ userid => 'ilsdi-userid', >+ password => 'ilsdi-password', >+); >+ >+# Crate patron category >+unless ( GetBorrowercategory('UT') ) { >+ $dbh->do("INSERT INTO categories >+ (categorycode,description,enrolmentperiod,upperagelimit,enrolmentfee,overduenoticerequired,reservefee,category_type) >+ VALUES >+ ('UT','Unit tester',99,99,0.000000,1,0.000000,'C');"); >+} >+ >+# Create branch >+unless ( GetBranchDetail('DEMO') ) { >+ $dbh->do("INSERT INTO branches (branchcode,branchname) VALUES ('UT','Unit test library');"); >+} >+ >+ >+my $borrowernumber = AddMember(%data); >+my $borrower = GetMember( borrowernumber => $borrowernumber ); >+ >+{ # AuthenticatePatron test >+ >+ my $query = new CGI; >+ $query->param('username',$borrower->{'userid'}); >+ $query->param('password','ilsdi-password'); >+ >+ my $reply = C4::ILSDI::Services::AuthenticatePatron($query); >+ is($reply->{'id'}, $borrowernumber, "userid and password - Patron authenticated"); >+ is($reply->{'code'}, undef, "Error code undef"); >+ >+ $query->param('password','ilsdi-passworD'); >+ $reply = C4::ILSDI::Services::AuthenticatePatron($query); >+ is($reply->{'code'}, 'PatronNotFound', "userid and wrong password - PatronNotFound"); >+ is($reply->{'id'}, undef, "id undef"); >+ >+ $query->param('password','ilsdi-password'); >+ $query->param('username','wrong-ilsdi-useriD'); >+ $reply = C4::ILSDI::Services::AuthenticatePatron($query); >+ is($reply->{'code'}, 'PatronNotFound', "non-existing userid - PatronNotFound"); >+ is($reply->{'id'}, undef, "id undef"); >+ >+ $query->param('username',uc($borrower->{'userid'})); >+ $reply = C4::ILSDI::Services::AuthenticatePatron($query); >+ is($reply->{'id'}, $borrowernumber, "userid is not case sensitive - Patron authenticated"); >+ is($reply->{'code'}, undef, "Error code undef"); >+ >+TODO: { local: $TODO = "Can't use cardnumber for authentication with ILS-DI yet."; >+ $query->param('username',$borrower->{'cardnumber'}); >+ $reply = C4::ILSDI::Services::AuthenticatePatron($query); >+ is($reply->{'id'}, $borrowernumber, "cardnumber and password - Patron authenticated"); >+ is($reply->{'code'}, undef, "Error code undef"); >+ >+ $query->param('password','ilsdi-passworD'); >+ $reply = C4::ILSDI::Services::AuthenticatePatron($query); >+ is($reply->{'code'}, 'PatronNotFound', "cardnumber and wrong password - PatronNotFount"); >+ is($reply->{'id'}, undef, "id undef"); >+ >+ $query->param('username','randomcardnumber1234'); >+ $query->param('password','ilsdi-password'); >+ $reply = C4::ILSDI::Services::AuthenticatePatron($query); >+ is($reply->{'code'}, 'PatronNotFound', "non-existing cardnumer/userid - PatronNotFound"); >+ is($reply->{'id'}, undef, "id undef"); >+ } >+ >+} >+ >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10667
:
20884
|
20885
|
20888
|
20889
|
20998
|
21007
|
21064
|
21065
|
21067