2 # patron_enable: test Patron Enable Response
8 use Sip::Constants qw(:all);
10 use SIPtest qw(:basic :user1);
12 my $patron_enable_test_template = {
13 id => 'Patron Enable: valid patron',
14 msg => "2520060102 084238AOUWOLS|AA$user_barcode|",
15 pat => qr/^26 {4}[ Y]{10}000$datepat/,
17 $SIPtest::field_specs{(FID_INST_ID)},
18 $SIPtest::field_specs{(FID_SCREEN_MSG)},
19 $SIPtest::field_specs{(FID_PRINT_LINE)},
20 { field => FID_PATRON_ID,
21 pat => qr/^$user_barcode$/,
23 { field => FID_PERSONAL_NAME,
24 pat => qr/^$user_fullname$/,
26 { field => FID_VALID_PATRON,
28 # Not required by the spec, but by the test
32 # We need to disable the valid patron before we can
33 # ensure that he was properly enabled.
34 my $patron_disable_test_template = {
35 id => 'Patron Enable: block patron (prep to test enabling)',
36 msg => "01N20060102 084238AO$instid|ALBlocked patron for SIP test.|AA$user_barcode|",
37 # response to block patron is a patron status message
38 pat => qr/^24Y{4}[ Y]{10}000$datepat/,
40 $SIPtest::field_specs{(FID_INST_ID)},
41 { field => FID_PATRON_ID,
42 pat => qr/^$user_barcode$/,
44 { field => FID_PERSONAL_NAME,
45 pat => qr/^$user_fullname$/,
47 { field => FID_VALID_PATRON,
49 # Not required by the spec, but by the test
55 $SIPtest::sc_status_test,
56 $patron_disable_test_template,
57 clone($patron_enable_test_template),
62 # Valid patron, valid password
63 $test = clone($patron_enable_test_template);
64 $test->{id} = "Patron Enable: valid patron, valid password";
65 $test->{msg} .= FID_PATRON_PWD . "$user_pin|";
66 $test->{pat} = qr/^26 {4}[ Y]{10}000$datepat/;
67 delete $test->{fields};
69 $SIPtest::field_specs{(FID_INST_ID)},
70 $SIPtest::field_specs{(FID_SCREEN_MSG)},
71 $SIPtest::field_specs{(FID_PRINT_LINE)},
72 { field => FID_PATRON_ID,
73 pat => qr/^$user_barcode$/,
75 { field => FID_PERSONAL_NAME,
76 pat => qr/^$user_fullname$/,
78 { field => FID_VALID_PATRON,
80 # Not required by the spec, but by the test
82 { field => FID_VALID_PATRON_PWD,
87 push @tests, $patron_disable_test_template, $test;
89 # Valid patron, invalid password
90 $test = clone($patron_enable_test_template);
91 $test->{id} = "Patron Enable: valid patron, invalid password";
92 $test->{msg} .= FID_PATRON_PWD . 'bad password|';
93 $test->{pat} = qr/^26[ Y]{14}000$datepat/;
94 delete $test->{fields};
96 $SIPtest::field_specs{(FID_INST_ID)},
97 $SIPtest::field_specs{(FID_SCREEN_MSG)},
98 $SIPtest::field_specs{(FID_PRINT_LINE)},
99 { field => FID_PATRON_ID,
100 pat => qr/^$user_barcode$/,
102 { field => FID_PERSONAL_NAME,
103 pat => qr/^$user_fullname$/,
105 { field => FID_VALID_PATRON,
107 # Not required by the spec, but by the test
109 { field => FID_VALID_PATRON_PWD,
114 push @tests, $patron_disable_test_template, $test;
115 # After this test, the patron is left disabled, so re-enable
116 push @tests, $patron_enable_test_template;
119 $test = clone($patron_enable_test_template);
120 $test->{id} =~ s/valid/invalid/;
121 $test->{msg} =~ s/AA$user_barcode\|/AAbad_barcode|/;
122 $test->{pat} = qr/^26Y{4}[ Y]{10}000$datepat/;
123 delete $test->{fields};
125 $SIPtest::field_specs{(FID_INST_ID)},
126 $SIPtest::field_specs{(FID_SCREEN_MSG)},
127 $SIPtest::field_specs{(FID_PRINT_LINE)},
128 { field => FID_PATRON_ID,
129 pat => qr/^bad_barcode$/,
131 { field => FID_PERSONAL_NAME,
134 { field => FID_VALID_PATRON,
136 # Not required by the spec, but by the test
142 SIPtest::run_sip_tests(@tests);