Lines 155-161
subtest "get_login_shib tests" => sub {
Link Here
|
155 |
}; |
155 |
}; |
156 |
|
156 |
|
157 |
subtest "checkpw_shib tests" => sub { |
157 |
subtest "checkpw_shib tests" => sub { |
158 |
plan tests => 33; |
158 |
|
|
|
159 |
plan tests => 52; |
159 |
|
160 |
|
160 |
# Test borrower data |
161 |
# Test borrower data |
161 |
my $test_borrowers = [ |
162 |
my $test_borrowers = [ |
Lines 169-187
subtest "checkpw_shib tests" => sub {
Link Here
|
169 |
|
170 |
|
170 |
# good user |
171 |
# good user |
171 |
my $shib_login = "test1234"; |
172 |
my $shib_login = "test1234"; |
172 |
my ( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login); |
173 |
my ( $retval, $retcard, $retuserid, $retpatron ) = checkpw_shib($shib_login); |
173 |
is( $logger->count(), 2, "Two debugging entries"); |
174 |
is( $logger->count(), 2, "Two debugging entries" ); |
174 |
is( $retval, "1", "user authenticated" ); |
175 |
is( $retval, 1, "user authenticated" ); |
175 |
is( $retcard, "testcardnumber", "expected cardnumber returned" ); |
176 |
is( $retcard, "testcardnumber", "expected cardnumber returned" ); |
176 |
is( $retuserid, "test1234", "expected userid returned" ); |
177 |
is( $retuserid, "test1234", "expected userid returned" ); |
|
|
178 |
is( ref($retpatron), 'Koha::Patron', "expected Koha::Patron object returned" ); |
179 |
|
177 |
$logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") |
180 |
$logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") |
178 |
->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info") |
181 |
->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info") |
179 |
->clear(); |
182 |
->clear(); |
180 |
|
183 |
|
181 |
# bad user |
184 |
# bad user |
182 |
$shib_login = 'martin'; |
185 |
$shib_login = 'martin'; |
183 |
( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login); |
186 |
( $retval, $retcard, $retuserid, $retpatron ) = checkpw_shib($shib_login); |
184 |
is( $retval, "0", "user not authenticated" ); |
187 |
is( $retval, 0, "user not authenticated" ); |
|
|
188 |
is( $retcard, undef ); |
189 |
is( $retuserid, undef ); |
190 |
is( $retpatron, undef ); |
185 |
$logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") |
191 |
$logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") |
186 |
->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info") |
192 |
->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info") |
187 |
->clear(); |
193 |
->clear(); |
Lines 189-201
subtest "checkpw_shib tests" => sub {
Link Here
|
189 |
# duplicated matchpoint |
195 |
# duplicated matchpoint |
190 |
change_config({ matchpoint => 'email', mapping => { email => { is => 'email' }} }); |
196 |
change_config({ matchpoint => 'email', mapping => { email => { is => 'email' }} }); |
191 |
$shib_login = 'kid@clamp.io'; |
197 |
$shib_login = 'kid@clamp.io'; |
192 |
( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login); |
198 |
( $retval, $retcard, $retuserid, $retpatron ) = checkpw_shib($shib_login); |
193 |
is( $retval, "0", "user not authenticated if duplicated matchpoint" ); |
199 |
is( $retval, 0, "user not authenticated if duplicated matchpoint" ); |
|
|
200 |
is( $retcard, undef ); |
201 |
is( $retuserid, undef ); |
202 |
is( $retpatron, undef ); |
194 |
$logger->debug_is("koha borrower field to match: email", "borrower match field debug info") |
203 |
$logger->debug_is("koha borrower field to match: email", "borrower match field debug info") |
195 |
->debug_is("shibboleth attribute to match: email", "shib match attribute debug info") |
204 |
->debug_is("shibboleth attribute to match: email", "shib match attribute debug info") |
196 |
->clear(); |
205 |
->clear(); |
197 |
|
206 |
|
198 |
( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login); |
207 |
( $retval, $retcard, $retuserid, $retpatron ) = checkpw_shib($shib_login); |
|
|
208 |
is( $retval, 0 ); |
209 |
is( $retcard, undef ); |
210 |
is( $retuserid, undef ); |
211 |
is( $retpatron, undef ); |
199 |
$logger->debug_is("koha borrower field to match: email", "borrower match field debug info") |
212 |
$logger->debug_is("koha borrower field to match: email", "borrower match field debug info") |
200 |
->debug_is("shibboleth attribute to match: email", "shib match attribute debug info") |
213 |
->debug_is("shibboleth attribute to match: email", "shib match attribute debug info") |
201 |
->warn_is('There are several users with email of kid@clamp.io, matchpoints must be unique', "duplicated matchpoint warned with debug") |
214 |
->warn_is('There are several users with email of kid@clamp.io, matchpoints must be unique', "duplicated matchpoint warned with debug") |
Lines 214-220
subtest "checkpw_shib tests" => sub {
Link Here
|
214 |
$ENV{branchcode} = $library->branchcode; # needed since T::D::C does no longer hides the FK constraint |
227 |
$ENV{branchcode} = $library->branchcode; # needed since T::D::C does no longer hides the FK constraint |
215 |
|
228 |
|
216 |
warnings_are { |
229 |
warnings_are { |
217 |
( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login); |
230 |
( $retval, $retcard, $retuserid, $retpatron ) = checkpw_shib($shib_login); |
218 |
} |
231 |
} |
219 |
[ |
232 |
[ |
220 |
'GetPreparedLetter called', |
233 |
'GetPreparedLetter called', |
Lines 222-229
subtest "checkpw_shib tests" => sub {
Link Here
|
222 |
'SendQueuedMessages called with message_id: 42' |
235 |
'SendQueuedMessages called with message_id: 42' |
223 |
], |
236 |
], |
224 |
"WELCOME notice Prepared, Enqueued and Send"; |
237 |
"WELCOME notice Prepared, Enqueued and Send"; |
225 |
is( $retval, "1", "user authenticated" ); |
238 |
is( $retval, "1", "user authenticated" ); |
226 |
is( $retuserid, "test4321", "expected userid returned" ); |
239 |
is( $retuserid, "test4321", "expected userid returned" ); |
|
|
240 |
is( ref($retpatron), 'Koha::Patron', "expected Koha::Patron object returned" ); |
227 |
$logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") |
241 |
$logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") |
228 |
->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info") |
242 |
->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info") |
229 |
->clear(); |
243 |
->clear(); |
Lines 238-244
subtest "checkpw_shib tests" => sub {
Link Here
|
238 |
# sync user |
252 |
# sync user |
239 |
$shibboleth->{sync} = 1; |
253 |
$shibboleth->{sync} = 1; |
240 |
$ENV{'city'} = 'AnotherCity'; |
254 |
$ENV{'city'} = 'AnotherCity'; |
241 |
( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login); |
255 |
( $retval, $retcard, $retuserid, $retpatron ) = checkpw_shib($shib_login); |
|
|
256 |
is( $retval, 1, "user authenticated" ); |
257 |
is( $retuserid, $shib_login, "expected userid returned" ); |
258 |
is( ref($retpatron), 'Koha::Patron', "expected Koha::Patron object returned" ); |
242 |
$logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") |
259 |
$logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") |
243 |
->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info") |
260 |
->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info") |
244 |
->clear(); |
261 |
->clear(); |
Lines 254-271
subtest "checkpw_shib tests" => sub {
Link Here
|
254 |
|
271 |
|
255 |
# good user |
272 |
# good user |
256 |
$shib_login = "test1234"; |
273 |
$shib_login = "test1234"; |
257 |
( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login); |
274 |
( $retval, $retcard, $retuserid, $retpatron ) = checkpw_shib($shib_login); |
258 |
is( $retval, "1", "user authenticated" ); |
275 |
is( $retval, "1", "user authenticated" ); |
259 |
is( $retcard, "testcardnumber", "expected cardnumber returned" ); |
276 |
is( $retcard, "testcardnumber", "expected cardnumber returned" ); |
260 |
is( $retuserid, "test1234", "expected userid returned" ); |
277 |
is( $retuserid, "test1234", "expected userid returned" ); |
|
|
278 |
is( ref($retpatron), 'Koha::Patron', "expected Koha::Patron object returned" ); |
261 |
$logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") |
279 |
$logger->debug_is("koha borrower field to match: userid", "borrower match field debug info") |
262 |
->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info") |
280 |
->debug_is("shibboleth attribute to match: uid", "shib match attribute debug info") |
263 |
->clear(); |
281 |
->clear(); |
264 |
|
282 |
|
265 |
# bad user |
283 |
# bad user |
266 |
$shib_login = "martin"; |
284 |
$shib_login = "martin"; |
267 |
( $retval, $retcard, $retuserid ) = checkpw_shib($shib_login); |
285 |
( $retval, $retcard, $retuserid, $retpatron ) = checkpw_shib($shib_login); |
268 |
is( $retval, "0", "user not authenticated" ); |
286 |
is( $retval, 0, "user not authenticated" ); |
|
|
287 |
is( $retcard, undef ); |
288 |
is( $retuserid, undef ); |
289 |
is( $retpatron, undef ); |
269 |
$logger->info_is("No users with userid of martin found and autocreate is disabled", "Missing matchpoint warned to info"); |
290 |
$logger->info_is("No users with userid of martin found and autocreate is disabled", "Missing matchpoint warned to info"); |
270 |
}; |
291 |
}; |
271 |
|
292 |
|
272 |
- |
|
|