@@ -, +, @@ $ kshell k$ prove t/db_dependent/api/v1/query.t --- t/db_dependent/api/v1/query.t | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) --- a/t/db_dependent/api/v1/query.t +++ a/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; +}; --