Bugzilla – Attachment 67956 Details for
Bug 16694
Limit SIP2 auth by patron attribute
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16694 - Add tests to t/db_dependent/SIP/Message.t
Bug-16694---Add-tests-to-tdbdependentSIPMessaget.patch (text/plain), 4.11 KB, created by
Owen Leonard
on 2017-10-11 13:47:40 UTC
(
hide
)
Description:
Bug 16694 - Add tests to t/db_dependent/SIP/Message.t
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2017-10-11 13:47:40 UTC
Size:
4.11 KB
patch
obsolete
>From 1c635ca38828e28537d85ceb43c6cc9f7a97d9d8 Mon Sep 17 00:00:00 2001 >From: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no> >Date: Tue, 5 Sep 2017 14:16:50 +0200 >Subject: [PATCH] Bug 16694 - Add tests to t/db_dependent/SIP/Message.t > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Test passes with no errors >--- > t/db_dependent/SIP/Message.t | 70 +++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 69 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t >index 12019c2..5fd0214 100755 >--- a/t/db_dependent/SIP/Message.t >+++ b/t/db_dependent/SIP/Message.t >@@ -21,7 +21,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 3; >+use Test::More tests => 4; > use Test::MockObject; > use Test::MockModule; > use Test::Warn; >@@ -36,6 +36,8 @@ use Koha::Items; > use Koha::Checkouts; > use Koha::Old::Checkouts; > use Koha::Patrons; >+use Koha::Patron::Attribute; >+use Koha::Patron::Attributes; > > use C4::SIP::ILS; > use C4::SIP::ILS::Patron; >@@ -64,6 +66,15 @@ subtest 'Testing Patron Info Request V2' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'Testing Patron Info With Validate Patron Attribute' => sub { >+ my $schema = Koha::Database->new->schema; >+ $schema->storage->txn_begin; >+ plan tests => 6; >+ $C4::SIP::Sip::protocol_version = 2; >+ test_request_patron_info_with_validate_patron_attribute(); >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'Checkin V2' => sub { > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -232,6 +243,63 @@ sub test_request_patron_info_v2 { > check_field( $respcode, $response, FID_SCREEN_MSG, '.+', 'But we have a screen msg', 'regex' ); > } > >+sub test_request_patron_info_with_validate_patron_attribute { >+ my $builder = t::lib::TestBuilder->new(); >+ my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; >+ my ( $response, $findpatron ); >+ my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); >+ >+ my $patron = $builder->build({ >+ source => 'Borrower', >+ value => { >+ password => hash_password( PATRON_PW ), >+ }, >+ }); >+ my $card = $patron->{cardnumber}; >+ my $sip_patron = C4::SIP::ILS::Patron->new( $card ); >+ $findpatron = $sip_patron; >+ >+ my $attr_type = $builder->build( { source => 'BorrowerAttributeType' } ); >+ >+ my $siprequest = PATRON_INFO. 'engYYYYMMDDZZZZHHMMSS'.'Y '. >+ FID_INST_ID. $branchcode. '|'. >+ FID_PATRON_ID. $card. '|'. >+ FID_PATRON_PWD. PATRON_PW. '|'; >+ my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); >+ >+ my $server = { ils => $mocks->{ils} }; >+ $server->{account}->{validate_patron_attribute} = $attr_type->{code}; >+ >+ # patron with no patron attribyte should be denied (charge->ok = 0) >+ undef $response; >+ $msg->handle_patron_info( $server ); >+ my $charge_ok = substr( $response, 2, 1 ); >+ is( $charge_ok, 'Y', 'charge denied' ); >+ check_field( '64', $response, FID_PERSONAL_NAME, $patron->{surname}, 'Verified patron name', 'contains' ); >+ check_field( '64', $response, FID_VALID_PATRON, 'Y', 'Verified code BL' ); >+ check_field( '64', $response, FID_VALID_PATRON_PWD, 'Y', 'Verified code CQ' ); >+ >+ # patron with anything but 1 as attribute value should be denied (charge->ok = 0) >+ undef $response; >+ my $attribute = Koha::Patron::Attribute->new( >+ { borrowernumber => $patron->{borrowernumber}, >+ code => $attr_type->{code}, >+ attribute => "Foo", >+ } >+ ); >+ $msg->handle_patron_info( $server ); >+ $charge_ok = substr( $response, 2, 1 ); >+ is( $charge_ok, 'Y', 'charge denied' ); >+ >+ # patron with 1 as proper attribute should be allowed >+ undef $response; >+ $attribute->set({ attribute => 1 })->store; >+ $msg->handle_patron_info( $server ); >+ $charge_ok = substr( $response, 2, 1 ); >+ is( $charge_ok, ' ', 'charge allowed' ); >+} >+ >+ > sub test_checkin_v2 { > my $builder = t::lib::TestBuilder->new(); > my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; >-- >2.1.4
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 16694
:
54920
|
56068
|
56442
|
56579
|
66845
|
66846
|
66847
|
66848
|
66849
| 67956 |
80702
|
80703