Browse Source

Bug 13895: Change renewal endpoint

Instead of PUT on /checkout/{checkout_id} endpoint, you should now call
POST on /checkouts/{checkout_id}/renewal

Test plan:
prove t/db_dependent/api/v1/checkouts.t

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Josef Moravec 4 years ago
committed by Nick Clemens
parent
commit
95d23bc3c3
  1. 3
      api/v1/swagger/paths.json
  2. 6
      api/v1/swagger/paths/checkouts.json
  3. 8
      t/db_dependent/api/v1/checkouts.t

3
api/v1/swagger/paths.json

@ -17,6 +17,9 @@
"/checkouts/{checkout_id}": {
"$ref": "paths/checkouts.json#/~1checkouts~1{checkout_id}"
},
"/checkouts/{checkout_id}/renewal": {
"$ref": "paths/checkouts.json#/~1checkouts~1{checkout_id}~1renewal"
},
"/cities": {
"$ref": "paths/cities.json#/~1cities"
},

6
api/v1/swagger/paths/checkouts.json

@ -61,8 +61,10 @@
"circulate": "circulate_remaining_permissions"
}
}
},
"put": {
}
},
"/checkouts/{checkout_id}/renewal": {
"post": {
"x-mojo-to": "Checkout#renew",
"operationId": "renewCheckout",
"tags": ["patrons", "checkouts"],

8
t/db_dependent/api/v1/checkouts.t

@ -136,21 +136,21 @@ $dbh->do(q{
}, {}, '*', '*', '*', 7, 1);
my $expected_datedue = DateTime->now->add(days => 14)->set(hour => 23, minute => 59, second => 0);
$t->put_ok ( "//$userid:$password@/api/v1/checkouts/" . $issue1->issue_id)
$t->post_ok ( "//$userid:$password@/api/v1/checkouts/" . $issue1->issue_id . "/renewal" )
->status_is(200)
->json_is('/due_date' => output_pref( { dateformat => "rfc3339", dt => $expected_datedue }) );
$t->put_ok( "//$unauth_userid:$unauth_password@/api/v1/checkouts/" . $issue3->issue_id)
$t->post_ok( "//$unauth_userid:$unauth_password@/api/v1/checkouts/" . $issue3->issue_id . "/renewal" )
->status_is(403)
->json_is({ error => "Authorization failure. Missing required permission(s).",
required_permissions => { circulate => "circulate_remaining_permissions" }
});
$t->put_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id)
$t->post_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id . "/renewal" )
->status_is(200)
->json_is('/due_date' => output_pref({ dateformat => "rfc3339", dt => $expected_datedue}) );
$t->put_ok( "//$userid:$password@/api/v1/checkouts/" . $issue1->issue_id)
$t->post_ok( "//$userid:$password@/api/v1/checkouts/" . $issue1->issue_id . "/renewal" )
->status_is(403)
->json_is({ error => 'Renewal not authorized (too_many)' });

Loading…
Cancel
Save