d85f757ce7
For historical reasons the SIPServer and SIP modules have used an extra module path in addition to the standard Koha one. This has caused numerous irritants in attempting to set up scripts and basic tests. It does not help in attempting to modify or debug this code This patch changes the package value in the modules under the C4/SIP directory and makes calls to them use the full package name. Where the export mechanism was being short circuited routines have been explicitly exported and imported declarations of 'use ILS' when that module was not being used and which only generated warnings have been removed. As a lot of the changes affect lines where an object is instantiated with new. The opportunity has been taken to replace the ambiguous indirect syntax with the preferred direct call In intializing ILS the full path is added as this will not require any changes to existing configs. I suspect this feature is unused, and adds obfuscation rather than flexibility but have kept the feature as we need this change in order to rationalize and extend the testing of the server. The visible difference is that with the normal Koha PERL5LIB setting. Compilation of Modules under C4/SIP should be successful and not fail with unlocated modules, allowing developers to see any perl warnings All the SIP modules can now be run through the tests in t/00-load.t now except for SIPServer itself Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
146 lines
4.5 KiB
Perl
146 lines
4.5 KiB
Perl
#!/usr/bin/perl
|
|
# patron_enable: test Patron Enable Response
|
|
|
|
use strict;
|
|
use warnings;
|
|
use FindBin qw($Bin);
|
|
use lib "$Bin";
|
|
use Clone qw(clone);
|
|
|
|
use C4::SIP::Sip::Constants qw(:all);
|
|
|
|
use SIPtest qw(:basic :user1);
|
|
|
|
my $patron_enable_test_template = {
|
|
id => 'Patron Enable: valid patron',
|
|
msg => "2520060102 084238AOUWOLS|AA$user_barcode|",
|
|
pat => qr/^26 {4}[ Y]{10}000$datepat/,
|
|
fields => [
|
|
$SIPtest::field_specs{(FID_INST_ID)},
|
|
$SIPtest::field_specs{(FID_SCREEN_MSG)},
|
|
$SIPtest::field_specs{(FID_PRINT_LINE)},
|
|
{ field => FID_PATRON_ID,
|
|
pat => qr/^$user_barcode$/,
|
|
required => 1, },
|
|
{ field => FID_PERSONAL_NAME,
|
|
pat => qr/^$user_fullname$/,
|
|
required => 1, },
|
|
{ field => FID_VALID_PATRON,
|
|
pat => qr/^Y$/,
|
|
# Not required by the spec, but by the test
|
|
required => 1, },
|
|
], };
|
|
|
|
# We need to disable the valid patron before we can
|
|
# ensure that he was properly enabled.
|
|
my $patron_disable_test_template = {
|
|
id => 'Patron Enable: block patron (prep to test enabling)',
|
|
msg => "01N20060102 084238AO$instid|ALBlocked patron for SIP test.|AA$user_barcode|",
|
|
# response to block patron is a patron status message
|
|
pat => qr/^24Y{4}[ Y]{10}000$datepat/,
|
|
fields => [
|
|
$SIPtest::field_specs{(FID_INST_ID)},
|
|
{ field => FID_PATRON_ID,
|
|
pat => qr/^$user_barcode$/,
|
|
required => 1, },
|
|
{ field => FID_PERSONAL_NAME,
|
|
pat => qr/^$user_fullname$/,
|
|
required => 1, },
|
|
{ field => FID_VALID_PATRON,
|
|
pat => qr/^Y$/,
|
|
# Not required by the spec, but by the test
|
|
required => 1, },
|
|
], };
|
|
|
|
my @tests = (
|
|
$SIPtest::login_test,
|
|
$SIPtest::sc_status_test,
|
|
$patron_disable_test_template,
|
|
clone($patron_enable_test_template),
|
|
);
|
|
|
|
my $test;
|
|
|
|
# Valid patron, valid password
|
|
$test = clone($patron_enable_test_template);
|
|
$test->{id} = "Patron Enable: valid patron, valid password";
|
|
$test->{msg} .= FID_PATRON_PWD . "$user_pin|";
|
|
$test->{pat} = qr/^26 {4}[ Y]{10}000$datepat/;
|
|
delete $test->{fields};
|
|
$test->{fields} = [
|
|
$SIPtest::field_specs{(FID_INST_ID)},
|
|
$SIPtest::field_specs{(FID_SCREEN_MSG)},
|
|
$SIPtest::field_specs{(FID_PRINT_LINE)},
|
|
{ field => FID_PATRON_ID,
|
|
pat => qr/^$user_barcode$/,
|
|
required => 1, },
|
|
{ field => FID_PERSONAL_NAME,
|
|
pat => qr/^$user_fullname$/,
|
|
required => 1, },
|
|
{ field => FID_VALID_PATRON,
|
|
pat => qr/^Y$/,
|
|
# Not required by the spec, but by the test
|
|
required => 1, },
|
|
{ field => FID_VALID_PATRON_PWD,
|
|
pat => qr/^Y$/,
|
|
required => 1, },
|
|
];
|
|
|
|
push @tests, $patron_disable_test_template, $test;
|
|
|
|
# Valid patron, invalid password
|
|
$test = clone($patron_enable_test_template);
|
|
$test->{id} = "Patron Enable: valid patron, invalid password";
|
|
$test->{msg} .= FID_PATRON_PWD . 'bad password|';
|
|
$test->{pat} = qr/^26[ Y]{14}000$datepat/;
|
|
delete $test->{fields};
|
|
$test->{fields} = [
|
|
$SIPtest::field_specs{(FID_INST_ID)},
|
|
$SIPtest::field_specs{(FID_SCREEN_MSG)},
|
|
$SIPtest::field_specs{(FID_PRINT_LINE)},
|
|
{ field => FID_PATRON_ID,
|
|
pat => qr/^$user_barcode$/,
|
|
required => 1, },
|
|
{ field => FID_PERSONAL_NAME,
|
|
pat => qr/^$user_fullname$/,
|
|
required => 1, },
|
|
{ field => FID_VALID_PATRON,
|
|
pat => qr/^Y$/,
|
|
# Not required by the spec, but by the test
|
|
required => 1, },
|
|
{ field => FID_VALID_PATRON_PWD,
|
|
pat => qr/^N$/,
|
|
required => 1, },
|
|
];
|
|
|
|
push @tests, $patron_disable_test_template, $test;
|
|
# After this test, the patron is left disabled, so re-enable
|
|
push @tests, $patron_enable_test_template;
|
|
|
|
# Invalid patron
|
|
$test = clone($patron_enable_test_template);
|
|
$test->{id} =~ s/valid/invalid/;
|
|
$test->{msg} =~ s/AA$user_barcode\|/AAbad_barcode|/;
|
|
$test->{pat} = qr/^26Y{4}[ Y]{10}000$datepat/;
|
|
delete $test->{fields};
|
|
$test->{fields} = [
|
|
$SIPtest::field_specs{(FID_INST_ID)},
|
|
$SIPtest::field_specs{(FID_SCREEN_MSG)},
|
|
$SIPtest::field_specs{(FID_PRINT_LINE)},
|
|
{ field => FID_PATRON_ID,
|
|
pat => qr/^bad_barcode$/,
|
|
required => 1, },
|
|
{ field => FID_PERSONAL_NAME,
|
|
pat => qr/^$/,
|
|
required => 1, },
|
|
{ field => FID_VALID_PATRON,
|
|
pat => qr/^N$/,
|
|
# Not required by the spec, but by the test
|
|
required => 1, },
|
|
];
|
|
|
|
push @tests, $test;
|
|
|
|
SIPtest::run_sip_tests(@tests);
|
|
|
|
1;
|