File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -399,12 +399,28 @@ def expected_rule_json(rule)
399399 end
400400
401401 describe 'filtering by selector_resource_guids' do
402- it 'does not match unintended rows when guid contains LIKE wildcards ' do
402+ it 'escapes % so it does not act as a LIKE wildcard ' do
403403 get '/v3/access_rules?selector_resource_guids=%25' , nil , admin_header
404404
405405 expect ( last_response . status ) . to eq ( 200 )
406406 parsed = Oj . load ( last_response . body )
407- # Should not match all rows via SQL wildcard; % is escaped
407+ expect ( parsed [ 'resources' ] . length ) . to eq ( 0 )
408+ end
409+
410+ it 'escapes _ so it does not act as a LIKE single-char wildcard' do
411+ get '/v3/access_rules?selector_resource_guids=cf_app' , nil , admin_header
412+
413+ expect ( last_response . status ) . to eq ( 200 )
414+ parsed = Oj . load ( last_response . body )
415+ # _ would match any single char (e.g. "cf:app"), but escaped it matches literal "_"
416+ expect ( parsed [ 'resources' ] . length ) . to eq ( 0 )
417+ end
418+
419+ it 'escapes backslash so it does not act as a LIKE escape character' do
420+ get '/v3/access_rules?selector_resource_guids=cf%5Capp' , nil , admin_header
421+
422+ expect ( last_response . status ) . to eq ( 200 )
423+ parsed = Oj . load ( last_response . body )
408424 expect ( parsed [ 'resources' ] . length ) . to eq ( 0 )
409425 end
410426 end
You can’t perform that action at this time.
0 commit comments