Browse Source

Bug 29926: (QA follow-up) Date format missing in spec

On fixing the spec to have `format: date` I noticed the tests were
expecting explosions because of date handling not being done. The
OpenAPI plugin does this correctly when you set the format right.

So, I adapted the tests so they expect 400 and return the type error.

We don't usually add such tests (i.e. test the plugin does its job
correctly) but it doesn't hurt to keep them just in case something
really changes badly there (plugin bug?).

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
22.05.x
Tomás Cohen Arazi 2 years ago
committed by Fridolin Somers
parent
commit
a3aaf10e59
  1. 1
      api/v1/swagger/paths/patrons_password.yaml
  2. 11
      t/db_dependent/api/v1/patrons_password_expiration.t

1
api/v1/swagger/paths/patrons_password.yaml

@ -77,6 +77,7 @@
expiration_date:
description: Date to expire password
type: string
format: date
required:
- expiration_date
additionalProperties: false

11
t/db_dependent/api/v1/patrons_password_expiration.t

@ -52,8 +52,6 @@ subtest 'basic tests' => sub {
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
t::lib::Mocks::mock_preference( 'dateformat','us' );
my $new_password = 'abc';
$t->put_ok( "//$userid:$password@/api/v1/patrons/"
@ -66,16 +64,13 @@ subtest 'basic tests' => sub {
. $patron->id
. "/password/expiration_date" => json =>
{ expiration_date => '01/13/2021' } )
->status_is(200)->json_is('');
->status_is(400)->json_is('/errors/0/message' => 'Does not match date format.');
$t->put_ok( "//$userid:$password@/api/v1/patrons/"
. $patron->id
. "/password/expiration_date" => json =>
{ expiration_date => '13/01/2021' } )
->status_is(500)->json_is({
error => 'Something went wrong, check Koha logs for details.',
error_code => "internal_server_error"
});
->status_is(400)->json_is('/errors/0/message' => 'Does not match date format.');
$privileged_patron->flags(0)->store();
@ -90,7 +85,5 @@ subtest 'basic tests' => sub {
}
});
$schema->storage->txn_rollback;
};

Loading…
Cancel
Save