Bug 18578: Use subdirectory in /tmp for session storage during installation
[koha.git] / C4 / SIP / t / 04patron_status.t
blob8c6ac49915a220e4a370f62e090089ae67e8bb72
1 #!/usr/bin/perl
2 # patron_status: test Patron Status Response
4 use strict;
5 use warnings;
6 use FindBin qw($Bin);
7 use lib "$Bin";
8 use Clone qw(clone);
10 use C4::SIP::Sip::Constants qw(:all);
11 use SIPtest qw(:user1 :basic);
13 my $patron_status_test_template = {
14 id => 'Patron Status: valid patron, no patron password',
15 msg => "2300120060101 084237AO$instid|AA$user_barcode|AC$password|",
16 pat => qr/^24[ Y]{14}001$datepat/,
17 fields => [
18 $SIPtest::field_specs{(FID_INST_ID)},
19 $SIPtest::field_specs{(FID_SCREEN_MSG)},
20 $SIPtest::field_specs{(FID_PRINT_LINE)},
21 { field => FID_PATRON_ID,
22 pat => qr/^$user_barcode$/,
23 required => 1, },
24 { field => FID_PERSONAL_NAME,
25 pat => qr/^$user_fullname$/,
26 required => 1, },
27 { field => FID_VALID_PATRON,
28 pat => qr/^Y$/,
29 # Not required by the spec, but by the test
30 required => 1, },
31 $SIPtest::field_specs{(FID_CURRENCY)},
32 { field => FID_FEE_AMT,
33 pat => $textpat,
34 required => 0, },
35 ], };
37 my @tests = (
38 $SIPtest::login_test,
39 $SIPtest::sc_status_test,
40 clone($patron_status_test_template),
43 # Invalid patron
44 my $test = clone($patron_status_test_template);
46 $test->{id} = 'Patron Status: invalid id';
47 $test->{msg} =~ s/AA$user_barcode\|/AAbad_userid|/;
49 # The test assumes that the language sent by the terminal is
50 # just echoed back for invalid patrons.
51 $test->{pat} = qr/^24Y[ Y]{13}001$datepat/;
53 delete $test->{fields};
54 $test->{fields} = [
55 $SIPtest::field_specs{(FID_INST_ID)},
56 $SIPtest::field_specs{(FID_SCREEN_MSG)},
57 $SIPtest::field_specs{(FID_PRINT_LINE)},
58 { field => FID_PATRON_ID,
59 pat => qr/^bad_userid$/,
60 required => 1, },
61 { field => FID_PERSONAL_NAME,
62 pat => qr/^$/,
63 required => 1, },
64 { field => FID_VALID_PATRON,
65 pat => qr/^N$/,
66 required => 1, },
69 push @tests, $test;
71 # Valid patron, invalid patron password
72 $test = clone($patron_status_test_template);
73 $test->{id} = 'Patron Status: Valid patron, invalid patron password';
74 $test->{msg} .= (FID_PATRON_PWD) . 'badpwd|';
75 delete $test->{fields};
76 $test->{fields} = [
77 $SIPtest::field_specs{(FID_INST_ID)},
78 $SIPtest::field_specs{(FID_SCREEN_MSG)},
79 $SIPtest::field_specs{(FID_PRINT_LINE)},
80 { field => FID_PATRON_ID,
81 pat => qr/^$user_barcode$/,
82 required => 1, },
83 { field => FID_PERSONAL_NAME,
84 pat => qr/^$user_fullname$/,
85 required => 1, },
86 { field => FID_VALID_PATRON,
87 pat => qr/^Y$/,
88 required => 1, },
89 { field => FID_VALID_PATRON_PWD,
90 pat => qr/^N$/,
91 required => 1, },
93 push @tests, $test;
95 # TODO: Need multiple patrons to test each individual
96 # status field
98 SIPtest::run_sip_tests(@tests);