@@ -200,4 +200,46 @@ describe("BuiltInFunctions tests", function ()
200
200
assert .is .False (BuiltInFunctions .IPMatch (" 192.168.2.124" , " 192.168.2.123" ))
201
201
assert .is .False (BuiltInFunctions .IPMatch (" 192.166.2.123" , " 192.168.2.123" ))
202
202
end )
203
+
204
+ it (" keyMatch5 tests" , function ()
205
+ assert .has_error (function () BuiltInFunctions .keyMatch5Func ({" /foo" }) end , " Expected 2 arguments, but got 1" )
206
+ assert .has_error (function () BuiltInFunctions .keyMatch5Func ({" /foo/create/123" , " /foo/*" , " /foo/update/123" }) end , " Expected 2 arguments, but got 3" )
207
+ assert .has_error (function () BuiltInFunctions .keyMatch5Func ({" /parent/123" , true }) end , " Argument must be a string" )
208
+
209
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /parent/child?status=1&type=2" , " /parent/child" ))
210
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /parent?status=1&type=2" , " /parent/child" ))
211
+
212
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /parent/child/?status=1&type=2" , " /parent/child/" ))
213
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /parent/child/?status=1&type=2" , " /parent/child" ))
214
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /parent/child?status=1&type=2" , " /parent/child/" ))
215
+
216
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /foo" , " /foo" ))
217
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /foo" , " /foo*" ))
218
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /foo" , " /foo/*" ))
219
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /foo/bar" , " /foo" ))
220
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /foo/bar" , " /foo*" ))
221
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /foo/bar" , " /foo/*" ))
222
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /foobar" , " /foo" ))
223
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /foobar" , " /foo*" ))
224
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /foobar" , " /foo/*" ))
225
+
226
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /" , " /{resource}" ))
227
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /resource1" , " /{resource}" ))
228
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /myid" , " /{id}/using/{resId}" ))
229
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /myid/using/myresid" , " /{id}/using/{resId}" ))
230
+
231
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /proxy/myid" , " /proxy/{id}/*" ))
232
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /proxy/myid/" , " /proxy/{id}/*" ))
233
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /proxy/myid/res" , " /proxy/{id}/*" ))
234
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /proxy/myid/res/res2" , " /proxy/{id}/*" ))
235
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /proxy/myid/res/res2/res3" , " /proxy/{id}/*" ))
236
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /proxy/" , " /proxy/{id}/*" ))
237
+
238
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /proxy/myid?status=1&type=2" , " /proxy/{id}/*" ))
239
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /proxy/myid/" , " /proxy/{id}/*" ))
240
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /proxy/myid/res?status=1&type=2" , " /proxy/{id}/*" ))
241
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /proxy/myid/res/res2?status=1&type=2" , " /proxy/{id}/*" ))
242
+ assert .is .True (BuiltInFunctions .keyMatch5 (" /proxy/myid/res/res2/res3?status=1&type=2" , " /proxy/{id}/*" ))
243
+ assert .is .False (BuiltInFunctions .keyMatch5 (" /proxy/" , " /proxy/{id}/*" ))
244
+ end )
203
245
end )
0 commit comments