Mercurial > hg > nginx-tests
comparison js_subrequests.t @ 1482:34e86a28cabd
Tests: adapted js_subrequests.t to njs changes after 0.3.3.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Tue, 28 May 2019 16:51:24 +0300 |
parents | 95951c72e721 |
children | 9521130f6f22 |
comparison
equal
deleted
inserted
replaced
1481:06fbf6269f38 | 1482:34e86a28cabd |
---|---|
139 js_content sr_except_failed_to_convert_arg; | 139 js_content sr_except_failed_to_convert_arg; |
140 } | 140 } |
141 | 141 |
142 location /sr_except_failed_to_convert_options_arg { | 142 location /sr_except_failed_to_convert_options_arg { |
143 js_content sr_except_failed_to_convert_options_arg; | 143 js_content sr_except_failed_to_convert_options_arg; |
144 } | |
145 | |
146 location /sr_except_invalid_options_method { | |
147 js_content sr_except_invalid_options_method; | |
148 } | 144 } |
149 | 145 |
150 location /sr_except_invalid_options_header_only { | 146 location /sr_except_invalid_options_header_only { |
151 js_content sr_except_invalid_options_header_only; | 147 js_content sr_except_invalid_options_header_only; |
152 } | 148 } |
269 r.finish(); | 265 r.finish(); |
270 }); | 266 }); |
271 } | 267 } |
272 | 268 |
273 function sr_options_method(r) { | 269 function sr_options_method(r) { |
274 r.subrequest('/p/method', {method:'POST'}, body_fwd_cb); | 270 r.subrequest('/p/method', {method:r.args.m}, body_fwd_cb); |
275 } | 271 } |
276 | 272 |
277 function sr_options_body(r) { | 273 function sr_options_body(r) { |
278 r.subrequest('/p/body', {method:'POST', body:'["REQ-BODY"]'}, | 274 r.subrequest('/p/body', {method:'POST', body:'["REQ-BODY"]'}, |
279 body_fwd_cb); | 275 body_fwd_cb); |
447 | 443 |
448 function sr_except_failed_to_convert_options_arg(r) { | 444 function sr_except_failed_to_convert_options_arg(r) { |
449 r.subrequest('/sub1', {args:r.args}, function(){}); | 445 r.subrequest('/sub1', {args:r.args}, function(){}); |
450 } | 446 } |
451 | 447 |
452 function sr_except_invalid_options_method(r) { | |
453 r.subrequest('/sub1', {method:'UNKNOWN_METHOD'}, function(){}); | |
454 } | |
455 | |
456 function sr_uri_except(r) { | 448 function sr_uri_except(r) { |
457 r.subrequest(r, 'a=1', 'b'); | 449 r.subrequest(r, 'a=1', 'b'); |
458 } | 450 } |
459 | 451 |
460 function body_fwd_cb(reply) { | 452 function body_fwd_cb(reply) { |
482 ############################################################################### | 474 ############################################################################### |
483 | 475 |
484 is(get_json('/sr'), '[{"status":404,"uri":"/p/sub2"}]', 'sr'); | 476 is(get_json('/sr'), '[{"status":404,"uri":"/p/sub2"}]', 'sr'); |
485 is(get_json('/sr_args'), '{"h":"xxx"}', 'sr_args'); | 477 is(get_json('/sr_args'), '{"h":"xxx"}', 'sr_args'); |
486 is(get_json('/sr_options_args'), '{"h":"xxx"}', 'sr_options_args'); | 478 is(get_json('/sr_options_args'), '{"h":"xxx"}', 'sr_options_args'); |
487 is(get_json('/sr_options_method'), '["POST"]', 'sr_options_method'); | 479 is(get_json('/sr_options_method?m=POST'), '["POST"]', 'sr method POST'); |
480 | |
481 TODO: { | |
482 local $TODO = 'not yet' | |
483 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.3.3'; | |
484 | |
485 is(get_json('/sr_options_method?m=PURGE'), '["PURGE"]', 'sr method PURGE'); | |
486 | |
487 } | |
488 | |
488 is(get_json('/sr_options_body'), '["REQ-BODY"]', 'sr_options_body'); | 489 is(get_json('/sr_options_body'), '["REQ-BODY"]', 'sr_options_body'); |
489 is(get_json('/sr_options_method_head'), '{"c":200,"s":0}', | 490 is(get_json('/sr_options_method_head'), '{"c":200,"s":0}', |
490 'sr_options_method_head'); | 491 'sr_options_method_head'); |
491 is(get_json('/sr_body'), '{"a":{"b":1}}', 'sr_body'); | 492 is(get_json('/sr_body'), '{"a":{"b":1}}', 'sr_body'); |
492 is(get_json('/sr_body_special'), '{"e":"msg"}', 'sr_body_special'); | 493 is(get_json('/sr_body_special'), '{"e":"msg"}', 'sr_body_special'); |
521 http_get('/sr_error_page'); | 522 http_get('/sr_error_page'); |
522 http_get('/sr_too_large'); | 523 http_get('/sr_too_large'); |
523 http_get('/sr_except_not_a_func'); | 524 http_get('/sr_except_not_a_func'); |
524 http_get('/sr_except_failed_to_convert_arg'); | 525 http_get('/sr_except_failed_to_convert_arg'); |
525 http_get('/sr_except_failed_to_convert_options_arg'); | 526 http_get('/sr_except_failed_to_convert_options_arg'); |
526 http_get('/sr_except_invalid_options_method'); | |
527 http_get('/sr_uri_except'); | 527 http_get('/sr_uri_except'); |
528 | 528 |
529 TODO: { | 529 TODO: { |
530 local $TODO = 'not yet' | 530 local $TODO = 'not yet' |
531 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.2.4'; | 531 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.2.4'; |
549 'subrequest cb exception'); | 549 'subrequest cb exception'); |
550 ok(index($t->read_file('error.log'), 'failed to convert uri arg') > 0, | 550 ok(index($t->read_file('error.log'), 'failed to convert uri arg') > 0, |
551 'subrequest uri exception'); | 551 'subrequest uri exception'); |
552 ok(index($t->read_file('error.log'), 'failed to convert args') > 0, | 552 ok(index($t->read_file('error.log'), 'failed to convert args') > 0, |
553 'subrequest invalid args exception'); | 553 'subrequest invalid args exception'); |
554 ok(index($t->read_file('error.log'), 'unknown method "UNKNOWN_METHOD"') > 0, | |
555 'subrequest unknown method exception'); | |
556 ok(index($t->read_file('error.log'), 'BACKGROUND') > 0, | 554 ok(index($t->read_file('error.log'), 'BACKGROUND') > 0, |
557 'background subrequest'); | 555 'background subrequest'); |
558 ok(index($t->read_file('error.log'), 'too big subrequest response') > 0, | 556 ok(index($t->read_file('error.log'), 'too big subrequest response') > 0, |
559 'subrequest too large body'); | 557 'subrequest too large body'); |
560 ok(index($t->read_file('error.log'), 'subrequest creation failed') > 0, | 558 ok(index($t->read_file('error.log'), 'subrequest creation failed') > 0, |