@@ -280,4 +280,110 @@ yay, api backend
280
280
GET / abc/ def? user_key= xyz
281
281
-- - error_code: 404
282
282
-- - no_error_log
283
- [error]
283
+ [error]
284
+
285
+ === TEST 6 : one transformation with method that matches
286
+ -- - configuration
287
+ {
288
+ " services" : [
289
+ {
290
+ " id" : 42 ,
291
+ " proxy" : {
292
+ " policy_chain" : [
293
+ {
294
+ " name" : " rewrite_url_captures" ,
295
+ " configuration" : {
296
+ " transformations" : [
297
+ {
298
+ " match_rule" : " /{ var_1} /{ var_2} " ,
299
+ " template" : " /{ var_2} ?my_arg={ var_1} " ,
300
+ " methods" : [" GET" ]
301
+ }
302
+ ]
303
+ }
304
+ },
305
+ {
306
+ " name" : " upstream" ,
307
+ " configuration" : {
308
+ " rules" : [
309
+ {
310
+ " regex" : " /" ,
311
+ " url" : " http://test:$ TEST_NGINX_SERVER_PORT"
312
+ }
313
+ ]
314
+ }
315
+ }
316
+ ]
317
+ }
318
+ }
319
+ ]
320
+ }
321
+ -- - upstream
322
+ location / {
323
+ content_by_lua_block {
324
+ local assert = require (' luassert' )
325
+ assert. equals(' /def' , ngx. var. uri)
326
+ assert. equals(' abc' , ngx. req. get_uri_args()[' my_arg' ])
327
+ ngx. say (' yay, api backend' );
328
+ }
329
+ }
330
+ -- - request
331
+ GET / abc/ def? user_key= value
332
+ -- - response_body
333
+ yay, api backend
334
+ -- - error_code: 200
335
+ -- - no_error_log
336
+ [error]
337
+
338
+ === TEST 7 : one transformation including an array of methods that matches
339
+ -- - configuration
340
+ {
341
+ " services" : [
342
+ {
343
+ " id" : 42 ,
344
+ " proxy" : {
345
+ " policy_chain" : [
346
+ {
347
+ " name" : " rewrite_url_captures" ,
348
+ " configuration" : {
349
+ " transformations" : [
350
+ {
351
+ " match_rule" : " /{ var_1} /{ var_2} " ,
352
+ " template" : " /{ var_2} ?my_arg={ var_1} " ,
353
+ " methods" : [" GET" , " PUT" , " POST" ]
354
+ }
355
+ ]
356
+ }
357
+ },
358
+ {
359
+ " name" : " upstream" ,
360
+ " configuration" : {
361
+ " rules" : [
362
+ {
363
+ " regex" : " /" ,
364
+ " url" : " http://test:$ TEST_NGINX_SERVER_PORT"
365
+ }
366
+ ]
367
+ }
368
+ }
369
+ ]
370
+ }
371
+ }
372
+ ]
373
+ }
374
+ -- - upstream
375
+ location / {
376
+ content_by_lua_block {
377
+ local assert = require (' luassert' )
378
+ assert. equals(' /def' , ngx. var. uri)
379
+ assert. equals(' abc' , ngx. req. get_uri_args()[' my_arg' ])
380
+ ngx. say (' yay, api backend' );
381
+ }
382
+ }
383
+ -- - request
384
+ PUT / abc/ def? user_key= value
385
+ -- - response_body
386
+ yay, api backend
387
+ -- - error_code: 200
388
+ -- - no_error_log
389
+ [error]
0 commit comments