github.com/lulzWill/go-agent@v2.1.2+incompatible/internal/crossagent/cross_agent_tests/rules.json (about) 1 [ 2 { 3 "testname":"replace first", 4 "rules":[{"match_expression":"(psi)", "replacement":"gamma", "ignore":false, "eval_order":0}, 5 {"match_expression":"^/userid/.*/folderid", "replacement":"/userid/*/folderid/*", "ignore":false, "eval_order":1}, 6 {"match_expression":"/need_not_be_first_segment/.*", "replacement":"*/need_not_be_first_segment/*", "ignore":false, "eval_order":2}], 7 "tests": 8 [ 9 {"input":"/alpha/psi/beta", "expected":"/alpha/gamma/beta"}, 10 {"input":"/psi/beta", "expected":"/gamma/beta"}, 11 {"input":"/alpha/psi", "expected":"/alpha/gamma"}, 12 {"input":"/userid/123abc/folderid/qwerty8855", "expected":"/userid/*/folderid/*/qwerty8855"}, 13 {"input":"/first/need_not_be_first_segment/uiop", "expected":"/first*/need_not_be_first_segment/*"} 14 ] 15 }, 16 { 17 "testname":"resource normalization rule", 18 "rules":[{"match_expression":"(.*)/[^/]*.(bmp|css|gif|ico|jpg|jpeg|js|png)$", "replacement":"\\1/*.\\2", "ignore":false, "eval_order":1}], 19 "tests": 20 [ 21 {"input":"/test/dude/flower.jpg", "expected":"/test/dude/*.jpg"}, 22 {"input":"/DUDE.ICO", "expected":"/*.ICO"} 23 ] 24 }, 25 { 26 "testname":"ignore rule", 27 "rules":[{"match_expression":"^/artists/az/(.*)/(.*)$", "replacement":"/artists/az/*/\\2", "ignore":true, "eval_order":11}], 28 "tests": 29 [ 30 {"input":"/artists/az/veritas/truth.jhtml", "expected":null} 31 ] 32 }, 33 { 34 "testname":"hexadecimal each segment rule", 35 "rules":[{"match_expression":"^[0-9a-f]*[0-9][0-9a-f]*$", "replacement":"*", "ignore":false, "eval_order":1, "each_segment":true}], 36 "tests": 37 [ 38 {"input":"/test/1axxx/4babe/cafe222/bad/a1b2c3d3e4f5/ABC123/x999/111", "expected":"/test/1axxx/*/*/bad/*/*/x999/*"}, 39 {"input":"/test/4/dude", "expected":"/test/*/dude"}, 40 {"input":"/test/babe4/999x", "expected":"/test/*/999x"}, 41 {"input":"/glass/resource/vase/images/9ae1283", "expected":"/glass/resource/vase/images/*"}, 42 {"input":"/test/4/dude.jsp", "expected":"/test/*/dude.jsp"}, 43 {"input":"/glass/resource/vase/images/add", "expected":"/glass/resource/vase/images/add"} 44 ] 45 }, 46 { 47 "testname":"url encoded segments rule", 48 "rules":[{"match_expression":"(.*)%(.*)", "replacement":"*", "ignore":false, "eval_order":1, "each_segment":true, "terminate_chain":false, "replace_all":false}], 49 "tests": 50 [ 51 {"input":"/test/%%%/bad%%/a1b2%c3%d3e4f5/x999/111%", "expected":"/test/*/*/*/x999/*"}, 52 {"input":"/add-resource/vmqoiearks%1B%3R", "expected":"/add-resource/*"} 53 ] 54 }, 55 { 56 "testname":"remove all ticks", 57 "rules":[{"match_expression":"([^']*)'+", "replacement":"\\1", "ignore":false, "eval_order":1, "each_segment":false, "replace_all":true}], 58 "tests": 59 [ 60 {"input":"/test/'''/b'a''d''/a1b2'c3'd3e4f5/x999/111'", "expected":"/test//bad/a1b2c3d3e4f5/x999/111"} 61 ] 62 }, 63 { 64 "testname":"number rule", 65 "rules":[{"match_expression":"\\d+", "replacement":"*", "ignore":false, "eval_order":1, "each_segment":false, "replace_all":true}], 66 "tests": 67 [ 68 {"input":"/solr/shard03/select", "expected":"/solr/shard*/select"}, 69 {"input":"/hey/r2d2", "expected":"/hey/r*d*"} 70 ] 71 }, 72 { 73 "testname":"custom rules", 74 "rules": 75 [ 76 {"match_expression":"^/([^/]*=[^/]*&?)+", "replacement":"/all_params", "ignore":false, "eval_order":0, "each_segment":false, "terminate_chain":true}, 77 {"match_expression":"^/.*/PARAMS/(article|legacy_article|post|product)/.*", "replacement":"/*/PARAMS/\\1/*", "ignore":false, "eval_order":14, "each_segment":false, "terminate_chain":true}, 78 {"match_expression":"^/test/(.*)", "replacement":"/dude", "ignore":false, "eval_order":1, "each_segment":false, "terminate_chain":true}, 79 {"match_expression":"^/blah/(.*)", "replacement":"/\\1", "ignore":false, "eval_order":2, "each_segment":false, "terminate_chain":true}, 80 {"match_expression":"/.*(dude|man)", "replacement":"/*.\\1", "ignore":false, "eval_order":3, "each_segment":false, "terminate_chain":true}, 81 {"match_expression":"^/(bob)", "replacement":"/\\1ert/\\1/\\1ertson", "ignore":false, "eval_order":4, "each_segment":false, "terminate_chain":true}, 82 {"match_expression":"/foo(.*)", "ignore":true, "eval_order":5, "each_segment":false, "terminate_chain":true}, 83 {"match_expression":"^/(keep)(/)(me)", "replacement":"/\\1\\2\\3", "ignore":false, "eval_order":6, "each_segment":false, "terminate_chain":true}, 84 {"match_expression":"^/(keep)(/)(me)", "replacement":"/you_werent_kept", "ignore":false, "eval_order":7, "each_segment":false, "terminate_chain":true} 85 ], 86 "tests": 87 [ 88 {"input":"/xs=zs&fly=*&row=swim&id=*&", "expected":"/all_params"}, 89 {"input":"/zip-zap/PARAMS/article/*", "expected":"/*/PARAMS/article/*"}, 90 {"input":"/bob", "expected":"/bobert/bob/bobertson"}, 91 {"input":"/test/foobar", "expected":"/dude"}, 92 {"input":"/bar/test", "expected":"/bar/test"}, 93 {"input":"/blah/test/man", "expected":"/test/man"}, 94 {"input":"/oh/hey.dude", "expected":"/*.dude"}, 95 {"input":"/oh/hey/what/up.man", "expected":"/*.man"}, 96 {"input":"/foo", "expected":null}, 97 {"input":"/foo/foobar", "expected":null}, 98 {"input":"/keep/me", "expected":"/keep/me"} 99 ] 100 }, 101 { 102 "testname":"chained rules", 103 "rules": 104 [ 105 {"match_expression":"^[0-9a-f]*[0-9][0-9a-f]*$", "replacement":"*", "ignore":false, "eval_order":1, "each_segment":true, "terminate_chain":false}, 106 {"match_expression":"(.*)/fritz/(.*)", "replacement":"\\1/karl/\\2", "ignore":false, "eval_order":11, "each_segment":false, "terminate_chain":true} 107 ], 108 "tests": 109 [ 110 {"input":"/test/1axxx/4babe/fritz/x999/111", "expected":"/test/1axxx/*/karl/x999/*"} 111 ] 112 }, 113 { 114 "testname":"rule ordering (two rules match, but only one is applied due to ordering)", 115 "rules": 116 [ 117 {"match_expression":"/test/(.*)", "replacement":"/el_duderino", "ignore":false, "eval_order":37}, 118 {"match_expression":"/test/(.*)", "replacement":"/dude", "ignore":false, "eval_order":1}, 119 {"match_expression":"/blah/(.*)", "replacement":"/$1", "ignore":false, "eval_order":2}, 120 {"match_expression":"/foo(.*)", "ignore":true, "eval_order":3} 121 ], 122 "tests": 123 [ 124 {"input":"/test/foobar", "expected":"/dude"} 125 ] 126 }, 127 { 128 "testname":"stable rule sorting", 129 "rules": 130 [ 131 {"match_expression":"/test/(.*)", "replacement":"/you_first", "ignore":false, "eval_order":0}, 132 {"match_expression":"/test/(.*)", "replacement":"/no_you", "ignore":false, "eval_order":0}, 133 {"match_expression":"/test/(.*)", "replacement":"/please_after_you", "ignore":false, "eval_order":0} 134 ], 135 "tests": 136 [ 137 {"input":"/test/polite_seattle_drivers", "expected":"/you_first"} 138 ] 139 }, 140 { 141 "testname":"custom rule chaining", 142 "rules": 143 [ 144 {"match_expression":"(.*)/robertson(.*)", "replacement":"\\1/LAST_NAME\\2", "ignore":false, "eval_order":0, "terminate_chain":false}, 145 {"match_expression":"^/robert(.*)", "replacement":"/bob\\1", "ignore":false, "eval_order":1, "terminate_chain":true}, 146 {"match_expression":"/LAST_NAME", "replacement":"/fail", "ignore":false, "eval_order":2, "terminate_chain":true} 147 ], 148 "tests": 149 [ 150 {"input":"/robert/robertson", "expected":"/bob/LAST_NAME"} 151 ] 152 }, 153 { 154 "testname":"saxon's test", 155 "rules":[{"match_expression":"^(?!account|application).*", "replacement":"*", "ignore":false, "eval_order":0, "each_segment":true}], 156 "tests": 157 [ 158 {"input":"/account/myacc/application/test", "expected":"/account/*/application/*"}, 159 {"input":"/oh/dude/account/myacc/application", "expected":"/*/*/account/*/application"} 160 ] 161 } 162 ]