View | Details | Raw Unified | Return to bug 34287
Collapse All | Expand All

(-)a/t/db_dependent/api/v1/checkouts.t (-10 / +20 lines)
Lines 336-353 subtest 'get_availability' => sub { Link Here
336
    %needsconfirmation = ();
336
    %needsconfirmation = ();
337
337
338
    subtest 'public availability' => sub {
338
    subtest 'public availability' => sub {
339
        plan tests => 18;
339
        plan tests => 22;
340
340
341
        # Available, Not authentication required
341
        # Authentication required
342
        $t->get_ok("/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id")->status_is(200)
342
        $t->get_ok("/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id")->status_is(401);
343
            ->json_is( '/blockers' => {} )->json_is( '/confirms' => {} )->json_is( '/warnings' => {} )
343
344
        # Only allow availability lookup for self
345
        $t->get_ok(
346
            "//$userid:$password@/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id"
347
        )->status_is(403);
348
349
        # All ok
350
        $t->get_ok(
351
            "//$unauth_userid:$unauth_password@/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id"
352
        )->status_is(200)->json_is( '/blockers' => {} )->json_is( '/confirms' => {} )->json_is( '/warnings' => {} )
344
            ->json_has('/confirmation_token');
353
            ->json_has('/confirmation_token');
345
354
346
        # Needs confirmation upgrade to blocker
355
        # Needs confirmation upgrade to blocker
347
        %needsconfirmation = ( TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 );
356
        %needsconfirmation = ( TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 );
348
        $t->get_ok("/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id")->status_is(200)
357
        $t->get_ok(
349
            ->json_is( '/blockers' => { TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 } )->json_is( '/confirms' => {} )
358
            "//$unauth_userid:$unauth_password@/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id"
350
            ->json_is( '/warnings' => {} )->json_has('/confirmation_token');
359
        )->status_is(200)->json_is( '/blockers' => { TOO_MANY => 1, ISSUED_TO_ANOTHER => 1 } )
360
            ->json_is( '/confirms' => {} )->json_is( '/warnings' => {} )->json_has('/confirmation_token');
351
        %needsconfirmation = ();
361
        %needsconfirmation = ();
352
362
353
        # Remove personal information from public endpoint
363
        # Remove personal information from public endpoint
Lines 394-401 subtest 'get_availability' => sub { Link Here
394
            ressurname            => 'private',
404
            ressurname            => 'private',
395
            item_notforloan       => 'private'
405
            item_notforloan       => 'private'
396
        );
406
        );
397
        $t->get_ok("/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id")->status_is(200)
407
        $t->get_ok(
398
            ->json_is( '/blockers' => {} )->json_is( '/confirms' => {} )->json_is( '/warnings' => {} )
408
            "//$unauth_userid:$unauth_password@/api/v1/public/checkouts/availability?item_id=$item1_id&patron_id=$patron_id"
409
        )->status_is(200)->json_is( '/blockers' => {} )->json_is( '/confirms' => {} )->json_is( '/warnings' => {} )
399
            ->json_has('/confirmation_token');
410
            ->json_has('/confirmation_token');
400
        %issuingimpossible = ();
411
        %issuingimpossible = ();
401
        %alerts            = ();
412
        %alerts            = ();
402
- 

Return to bug 34287