Bugzilla – Attachment 105182 Details for
Bug 24229
/items API tests fail on Ubuntu 18.04
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24229: Avoid fetching ALL items in test
Bug-24229-Avoid-fetching-ALL-items-in-test.patch (text/plain), 2.01 KB, created by
Jonathan Druart
on 2020-05-21 12:41:30 UTC
(
hide
)
Description:
Bug 24229: Avoid fetching ALL items in test
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-05-21 12:41:30 UTC
Size:
2.01 KB
patch
obsolete
>From 492c34e62b622c05358998f64bb8b508341ca176 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 20 May 2020 19:04:24 -0300 >Subject: [PATCH] Bug 24229: Avoid fetching ALL items in test > >I'm not sure what we need to test here, besides we get results. I'm >pretty sure we shouldn't allow a plain GET return all objects because it >could cause a DOS very easily. But it certainly belongs to a separate >bug/discussion. > >In this case, I put a constraint on the items domain (by using >_per_page=10 in the query params) so it won't happen that under certain >conditions the user agent used by Test::Mojo time outs. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/api/v1/items.t | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/api/v1/items.t b/t/db_dependent/api/v1/items.t >index 9eb623b96c..a4c62aa0a2 100644 >--- a/t/db_dependent/api/v1/items.t >+++ b/t/db_dependent/api/v1/items.t >@@ -51,6 +51,11 @@ subtest 'list() tests' => sub { > } > ); > >+ # Make sure we have at least 10 items >+ for ( 1..10 ) { >+ $builder->build_object({ class => 'Koha::Items' }); >+ } >+ > my $nonprivilegedpatron = $builder->build_object( > { > class => 'Koha::Patrons', >@@ -72,13 +77,12 @@ subtest 'list() tests' => sub { > $patron->set_password( { password => $password, skip_validation => 1 } ); > $userid = $patron->userid; > >- $t->get_ok( "//$userid:$password@/api/v1/items" ) >+ $t->get_ok( "//$userid:$password@/api/v1/items?_per_page=10" ) > ->status_is( 200, 'SWAGGER3.2.2' ); > >- my $items_count = Koha::Items->search->count; > my $response_count = scalar @{ $t->tx->res->json }; > >- is( $items_count, $response_count, 'The API returns all the items' ); >+ is( $response_count, 10, 'The API returns 10 items' ); > > $t->get_ok( "//$userid:$password@/api/v1/items?external_id=" . $item->barcode ) > ->status_is(200) >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24229
:
105163
|
105182
|
105193