@@ -315,3 +315,108 @@ ETag: foobar
315315<< EOF
316316using proxy: http: // 127.0 . 0. 1: $ Test ::Nginx::Util::PROXY_SSL_PORT,
317317EOF
318+
319+ === TEST 5 : chunked request using HTTPS proxy for backend.
320+ -- - ONLY
321+ -- - init eval
322+ $ Test ::Nginx::Util::PROXY_SSL_PORT = Test ::APIcast::get_random_port();
323+ $ Test ::Nginx::Util::ENDPOINT_SSL_PORT = Test ::APIcast::get_random_port();
324+ -- - configuration random_port env eval
325+ << EOF
326+ {
327+ " services" : [
328+ {
329+ " backend_version" : 1 ,
330+ " proxy" : {
331+ " api_backend" : " https://localhost:$ Test ::Nginx::Util::ENDPOINT_SSL_PORT" ,
332+ " proxy_rules" : [
333+ { " pattern" : " /test" , " http_method" : " POST" , " metric_system_name" : " hits" , " delta" : 2 }
334+ ],
335+ " policy_chain" : [
336+ {
337+ " name" : " apicast.policy.apicast"
338+ },
339+ {
340+ " name" : " apicast.policy.camel" ,
341+ " configuration" : {
342+ " https_proxy" : " http://127.0.0.1:$ Test ::Nginx::Util::PROXY_SSL_PORT"
343+ }
344+ }
345+ ]
346+ }
347+ }
348+ ]
349+ }
350+ EOF
351+ -- - backend
352+ location / transactions/ authrep. xml {
353+ content_by_lua_block {
354+ ngx. exit(ngx. OK)
355+ }
356+ }
357+ -- - upstream eval
358+ << EOF
359+ # Endpoint config
360+ listen $ Test ::Nginx::Util::ENDPOINT_SSL_PORT ssl;
361+
362+ ssl_certificate $ Test ::Nginx::Util::ServRoot/ html/ server. crt;
363+ ssl_certificate_key $ Test ::Nginx::Util::ServRoot/ html/ server. key ;
364+
365+ server_name _ default_server;
366+
367+ location / test {
368+ access_by_lua_block {
369+ assert = require (' luassert' )
370+ local content_length = ngx. req. get_headers()[" Content-Length" ]
371+ local encoding = ngx. req. get_headers()[" Transfer-Encoding" ]
372+
373+ -- This is due to the proxy_pass
374+ -- Perhaps we should refactor the test
375+ assert. falsy(encoding)
376+ assert. equal(' 12' , content_length)
377+
378+ ngx. req. read_body()
379+ local body = ngx. req. get_body_data()
380+ assert. equal(' hello, world' , body )
381+
382+ ngx. header[" Content-Length" ] = 0
383+ ngx. exit(200 )
384+ }
385+ }
386+ }
387+ server {
388+ # Proxy config
389+ listen $ Test ::Nginx::Util::PROXY_SSL_PORT ssl;
390+
391+ ssl_certificate $ Test ::Nginx::Util::ServRoot/ html/ server. crt;
392+ ssl_certificate_key $ Test ::Nginx::Util::ServRoot/ html/ server. key ;
393+
394+
395+ server_name _ default_server;
396+
397+ location ~ /.* {
398+ proxy_http_version 1.1 ;
399+ proxy_pass https: // \$ http_host ;
400+ }
401+ EOF
402+ -- - raw_request eval
403+ " POST /test?user_key=value HTTP/1.1\r
404+ Host: localhost\r
405+ Connection: close\r
406+ User-Agent: Test::APIcast::Blackbox\r
407+ ETag: foobar\r
408+ Transfer-Encoding: chunked\r
409+ \r
410+ 7\r
411+ hello, \r
412+ 5\r
413+ world\r
414+ 0\r
415+ \r
416+ "
417+ -- - error_code: 200
418+ -- - user_files fixture= tls. pl eval
419+ -- - error_log eval
420+ << EOF
421+ using proxy: http: // 127.0 . 0. 1: $ Test ::Nginx::Util::PROXY_SSL_PORT,
422+ EOF
0 commit comments