View | Details | Raw Unified | Return to bug 37018
Collapse All | Expand All

(-)a/t/Koha/REST/Plugin/Query.t (-2 / +50 lines)
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
    $c->dbic_validate_operators({ filtered_params => $query });
215
216
    $c->render( json => { filtered_params => $query }, status => 200 );
217
};
218
209
get '/stash_embed' => sub {
219
get '/stash_embed' => sub {
210
    my $c = shift;
220
    my $c = shift;
211
221
Lines 337-343 sub to_model { Link Here
337
347
338
# The tests
348
# The tests
339
349
340
use Test::More tests => 8;
350
use Test::More tests => 9;
341
use Test::Mojo;
351
use Test::Mojo;
342
352
343
subtest 'extract_reserved_params() tests' => sub {
353
subtest 'extract_reserved_params() tests' => sub {
Lines 634-636 subtest 'dbic_extended_attributes_join() tests' => sub { Link Here
634
        ]
644
        ]
635
    );
645
    );
636
};
646
};
637
- 
647
648
subtest 'dbic_validate_operators' => sub {
649
    plan tests => 16;
650
651
    my $t = Test::Mojo->new;
652
653
    # Valid queries
654
    my $q = {};
655
    $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200);
656
657
    $q = [];
658
    $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200);
659
660
    $q = {
661
        firstname => 'Bilbo',
662
        lastname  => 'Baggins'
663
    };
664
    $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200);
665
666
    $q = {
667
        firstname => undef,
668
        lastname  => 'Baggins'
669
    };
670
    $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200);
671
672
    $q = { lastname => [ 'Gaggins', 'Gamgee' ] };
673
    $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200);
674
675
    $q = { lastname => { '!=' => [ 'Gaggins', 'Gamgee' ] } };
676
    $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200);
677
678
    $q = { status => { '!=', 'completed', -not_like => 'pending%' }};
679
    $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(200);
680
681
    # Invalid queries
682
    $q = [ { "-and" => [ [ { "biblio_id" => { "like(sleep(1/100000))or" => "%a%" } } ] ] } ];
683
    $t->get_ok( '/dbic_validate_operators' => json => { q => $q } )->status_is(400);
684
685
};

Return to bug 37018