Lines 206-211
get '/build_query' => sub {
Link Here
|
206 |
}; |
206 |
}; |
207 |
}; |
207 |
}; |
208 |
|
208 |
|
|
|
209 |
get '/dbic_validate_operators' => sub { |
210 |
my ( $c, $args ) = @_; |
211 |
|
212 |
my $query = $c->req->json->{q}; |
213 |
|
214 |
return try { |
215 |
$c->dbic_validate_operators( { filtered_params => $query } ); |
216 |
$c->render( json => { filtered_params => $query }, status => 200 ); |
217 |
} catch { |
218 |
return $c->render( json => { filtered_params => $query }, status => 400 ); |
219 |
}; |
220 |
}; |
221 |
|
209 |
get '/stash_embed' => sub { |
222 |
get '/stash_embed' => sub { |
210 |
my $c = shift; |
223 |
my $c = shift; |
211 |
|
224 |
|
Lines 294-300
sub to_model {
Link Here
|
294 |
|
307 |
|
295 |
# The tests |
308 |
# The tests |
296 |
|
309 |
|
297 |
use Test::More tests => 7; |
310 |
use Test::More tests => 8; |
298 |
use Test::Mojo; |
311 |
use Test::Mojo; |
299 |
|
312 |
|
300 |
subtest 'extract_reserved_params() tests' => sub { |
313 |
subtest 'extract_reserved_params() tests' => sub { |
Lines 543-545
subtest 'stash_overrides() tests' => sub {
Link Here
|
543 |
->json_is( {} ); # x-koha-ovverride not passed is skipped |
556 |
->json_is( {} ); # x-koha-ovverride not passed is skipped |
544 |
|
557 |
|
545 |
}; |
558 |
}; |
546 |
- |
559 |
|
|
|
560 |
subtest 'dbic_validate_operators' => sub { |
561 |
plan tests => 16; |
562 |
|
563 |
my $t = Test::Mojo->new; |
564 |
|
565 |
# Valid queries |
566 |
my $q = {}; |
567 |
$t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); |
568 |
|
569 |
$q = []; |
570 |
$t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); |
571 |
|
572 |
$q = { |
573 |
firstname => 'Bilbo', |
574 |
lastname => 'Baggins' |
575 |
}; |
576 |
$t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); |
577 |
|
578 |
$q = { |
579 |
firstname => undef, |
580 |
lastname => 'Baggins' |
581 |
}; |
582 |
$t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); |
583 |
|
584 |
$q = { lastname => [ 'Gaggins', 'Gamgee' ] }; |
585 |
$t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); |
586 |
|
587 |
$q = { lastname => { '!=' => [ 'Gaggins', 'Gamgee' ] } }; |
588 |
$t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); |
589 |
|
590 |
$q = { status => { '!=', 'completed', -not_like => 'pending%' } }; |
591 |
$t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200); |
592 |
|
593 |
# Invalid queries |
594 |
$q = [ { "-and" => [ [ { "biblio_id" => { "like(sleep(1/100000))or" => "%a%" } } ] ] } ]; |
595 |
$t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(400); |
596 |
|
597 |
}; |