From a3aaf10e59ff44c8c8dbef6dcd5f28aba2fb8d2d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 26 Apr 2022 10:09:04 -0300 Subject: [PATCH] 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 Signed-off-by: Fridolin Somers --- api/v1/swagger/paths/patrons_password.yaml | 1 + t/db_dependent/api/v1/patrons_password_expiration.t | 11 ++--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/api/v1/swagger/paths/patrons_password.yaml b/api/v1/swagger/paths/patrons_password.yaml index 20c23db0e5..393dfa6e91 100644 --- a/api/v1/swagger/paths/patrons_password.yaml +++ b/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 diff --git a/t/db_dependent/api/v1/patrons_password_expiration.t b/t/db_dependent/api/v1/patrons_password_expiration.t index 603d8d9c11..9e444acbf0 100755 --- a/t/db_dependent/api/v1/patrons_password_expiration.t +++ b/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; }; -- 2.20.1