2 # patron_enable: test Patron Enable Response
10 use C4
::SIP
::Sip
::Constants
qw(:all);
12 use SIPtest
qw(:basic :user1);
14 my $patron_enable_test_template = {
15 id
=> 'Patron Enable: valid patron',
16 msg
=> "2520060102 084238AOUWOLS|AA$user_barcode|",
17 pat
=> qr/^26 {4}[ Y]{10}000$datepat/,
19 $SIPtest::field_specs
{(FID_INST_ID
)},
20 $SIPtest::field_specs
{(FID_SCREEN_MSG
)},
21 $SIPtest::field_specs
{(FID_PRINT_LINE
)},
22 { field
=> FID_PATRON_ID
,
23 pat
=> qr/^$user_barcode$/,
25 { field
=> FID_PERSONAL_NAME
,
26 pat
=> qr/^$user_fullname$/,
28 { field
=> FID_VALID_PATRON
,
30 # Not required by the spec, but by the test
34 # We need to disable the valid patron before we can
35 # ensure that they were properly enabled.
36 my $patron_disable_test_template = {
37 id
=> 'Patron Enable: block patron (prep to test enabling)',
38 msg
=> "01N20060102 084238AO$instid|ALBlocked patron for SIP test.|AA$user_barcode|",
39 # response to block patron is a patron status message
40 pat
=> qr/^24Y{4}[ Y]{10}000$datepat/,
42 $SIPtest::field_specs
{(FID_INST_ID
)},
43 { field
=> FID_PATRON_ID
,
44 pat
=> qr/^$user_barcode$/,
46 { field
=> FID_PERSONAL_NAME
,
47 pat
=> qr/^$user_fullname$/,
49 { field
=> FID_VALID_PATRON
,
51 # Not required by the spec, but by the test
57 $SIPtest::sc_status_test
,
58 $patron_disable_test_template,
59 clone
($patron_enable_test_template),
64 # Valid patron, valid password
65 $test = clone
($patron_enable_test_template);
66 $test->{id
} = "Patron Enable: valid patron, valid password";
67 $test->{msg
} .= FID_PATRON_PWD
. "$user_pin|";
68 $test->{pat
} = qr/^26 {4}[ Y]{10}000$datepat/;
69 delete $test->{fields
};
71 $SIPtest::field_specs
{(FID_INST_ID
)},
72 $SIPtest::field_specs
{(FID_SCREEN_MSG
)},
73 $SIPtest::field_specs
{(FID_PRINT_LINE
)},
74 { field
=> FID_PATRON_ID
,
75 pat
=> qr/^$user_barcode$/,
77 { field
=> FID_PERSONAL_NAME
,
78 pat
=> qr/^$user_fullname$/,
80 { field
=> FID_VALID_PATRON
,
82 # Not required by the spec, but by the test
84 { field
=> FID_VALID_PATRON_PWD
,
89 push @tests, $patron_disable_test_template, $test;
91 # Valid patron, invalid password
92 $test = clone
($patron_enable_test_template);
93 $test->{id
} = "Patron Enable: valid patron, invalid password";
94 $test->{msg
} .= FID_PATRON_PWD
. 'bad password|';
95 $test->{pat
} = qr/^26[ Y]{14}000$datepat/;
96 delete $test->{fields
};
98 $SIPtest::field_specs
{(FID_INST_ID
)},
99 $SIPtest::field_specs
{(FID_SCREEN_MSG
)},
100 $SIPtest::field_specs
{(FID_PRINT_LINE
)},
101 { field
=> FID_PATRON_ID
,
102 pat
=> qr/^$user_barcode$/,
104 { field
=> FID_PERSONAL_NAME
,
105 pat
=> qr/^$user_fullname$/,
107 { field
=> FID_VALID_PATRON
,
109 # Not required by the spec, but by the test
111 { field
=> FID_VALID_PATRON_PWD
,
116 push @tests, $patron_disable_test_template, $test;
117 # After this test, the patron is left disabled, so re-enable
118 push @tests, $patron_enable_test_template;
121 $test = clone
($patron_enable_test_template);
122 $test->{id
} =~ s/valid/invalid/;
123 $test->{msg
} =~ s/AA$user_barcode\|/AAbad_barcode|/;
124 $test->{pat
} = qr/^26Y{4}[ Y]{10}000$datepat/;
125 delete $test->{fields
};
127 $SIPtest::field_specs
{(FID_INST_ID
)},
128 $SIPtest::field_specs
{(FID_SCREEN_MSG
)},
129 $SIPtest::field_specs
{(FID_PRINT_LINE
)},
130 { field
=> FID_PATRON_ID
,
131 pat
=> qr/^bad_barcode$/,
133 { field
=> FID_PERSONAL_NAME
,
136 { field
=> FID_VALID_PATRON
,
138 # Not required by the spec, but by the test
144 SIPtest
::run_sip_tests
(@tests);