Bugzilla – Attachment 134479 Details for
Bug 30536
Embeds should be defined in a single place
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30536: Unit tests
Bug-30536-Unit-tests.patch (text/plain), 2.29 KB, created by
Martin Renvoize (ashimema)
on 2022-05-03 07:10:11 UTC
(
hide
)
Description:
Bug 30536: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-05-03 07:10:11 UTC
Size:
2.29 KB
patch
obsolete
>From 23e9eb95695373408b140274a9500f223e1891ff Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 14 Apr 2022 12:07:49 -0300 >Subject: [PATCH] Bug 30536: Unit tests > >This patch adds tests to make sure there's no behavior change regarding >error conditions. When requests include wrong x-koha-embed values, a 400 >error should be returned, both in our original implementation or relying >on the Mojolicious::Plugin::OpenAPI features. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/query.t >=> SUCCESS: Tests pass >3. Apply the rest of the patches >4. Repeat 2 >=> SUCCESS: Tests still pass >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/api/v1/query.t | 37 ++++++++++++++++++++++++++++++++++- > 1 file changed, 36 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/query.t b/t/db_dependent/api/v1/query.t >index dd73f2095c..3b8be18f8a 100755 >--- a/t/db_dependent/api/v1/query.t >+++ b/t/db_dependent/api/v1/query.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > use Test::Mojo; > > use t::lib::TestBuilder; >@@ -105,3 +105,38 @@ subtest 'q handling tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'x-koha-embed tests' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $librarian = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 1 } # superlibrarian >+ } >+ ); >+ my $password = 'thePassword123'; >+ $librarian->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $librarian->userid; >+ >+ my $patron_id = $builder->build_object( { class => 'Koha::Patrons' } )->id; >+ >+ my $res = $t->get_ok( >+ "//$userid:$password@/api/v1/patrons?q={\"me.patron_id\":$patron_id}" >+ => { 'x-koha-embed' => 'extended_attributes' } )->status_is(200) >+ ->tx->res->json; >+ >+ is( scalar @{$res}, 1, 'One patron returned' ); >+ >+ $res = $t->get_ok( >+ "//$userid:$password@/api/v1/patrons?q={\"me.patron_id\":$patron_id}" => { >+ 'x-koha-embed' => >+ 'extended_attributes,custom_bad_embed,another_bad_embed' >+ } >+ )->status_is(400); >+ >+ $schema->storage->txn_rollback; >+}; >-- >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 30536
:
133303
|
133309
|
133313
|
133314
|
133315
|
133316
|
133324
|
133325
|
133327
|
133328
|
133329
|
133330
|
134479
|
134480
|
134481
|
134482
|
134483
|
134484
|
134506
|
134507
|
134508
|
134509
|
134510
|
134511