@@ -47,32 +47,6 @@ test_psgi app, sub {
4747 }
4848 );
4949 }
50-
51- local
52- $MetaCPAN::Server::QuerySanitizer::metacpan_scripts {test_script_field }
53- = q{ doc['author.pauseid'].value.length() * 2} ;
54-
55- test_all_methods(
56- {
57- query => { match_all => {} },
58- script_fields =>
59- { pauselen2 => { metacpan_script => ' test_script_field' }, },
60- filter => { term => { pauseid => ' RWSTAUNER' } },
61- },
62- sub {
63- my ($req ) = shift ;
64-
65- my $res = $cb -> ($req );
66- is $res -> code, 200, $req -> method . ' 200 OK'
67- or diag explain $res ;
68-
69- my $json = decode_json_ok($res );
70-
71- is_deeply $json -> {hits }{hits }-> [0]-> {fields },
72- { pauselen2 => [18] }, ' script_fields via metacpan_script'
73- or diag explain $json ;
74- },
75- );
7650};
7751
7852sub test_all_methods {
@@ -126,34 +100,6 @@ my %replacements = (
126100 stupid_script_that_doesnt_exist => undef ,
127101);
128102
129- while ( my ( $mscript , $re ) = each %replacements ) {
130- my $query = filtered_custom_score_hash( metacpan_script => $mscript );
131-
132- my $sanitizer = MetaCPAN::Server::QuerySanitizer-> new( query => $query , );
133-
134- my $cleaned = $sanitizer -> query;
135- like_if_defined
136- delete $cleaned -> {query }{filtered }{query }{custom_score }{script },
137- $re , " $mscript script replaced" ;
138-
139- is_deeply $cleaned , filtered_custom_score_hash(),
140- ' metacpan_script removed' ;
141-
142- # try another hash structure
143- $query
144- = {
145- foo => { bar => [ { metacpan_script => $mscript , other => ' val' } ] }
146- };
147-
148- $cleaned
149- = MetaCPAN::Server::QuerySanitizer-> new( query => $query )-> query;
150-
151- like_if_defined delete $cleaned -> {foo }{bar }-> [0]-> {script },
152- $re , " $mscript script replaced" ;
153- is_deeply $cleaned , { foo => { bar => [ { other => ' val' } ] } },
154- ' any hash structure accepts metacpan_script' ;
155- }
156-
157103hash_key_rejected( script => { script => ' foobar' } );
158104hash_key_rejected(
159105 script => { tree => { of => ' many' , hashes => { script => ' foobar' } } }
0 commit comments