diff --git a/body_chunked.t b/body_chunked.t index 6d78d410..9a53f1be 100644 --- a/body_chunked.t +++ b/body_chunked.t @@ -22,7 +22,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(18); +my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(24); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -68,6 +68,7 @@ http { } location /large { client_max_body_size 1k; + client_body_buffer_size 2k; proxy_pass http://127.0.0.1:8081; } location /discard { @@ -119,6 +120,8 @@ like(http_get_body('/single', '0123456789' x 128), qr/X-Body: (0123456789){128}\x0d?$/ms, 'body in single buffer'); like(http_get_body('/large', '0123456789' x 128), qr/ 413 /, 'body too large'); +like(http_get_body('/large', 'X' x 1024), qr/ 200 /, 'body exact limit'); +like(http_get_body('/large', 'X' x 1025), qr/ 413 /, 'body just above limit'); # pipelined requests @@ -162,6 +165,66 @@ like( qr/400 Bad/, 'runaway chunk discard' ); +# chunk extensions and trailers + +like( + http( + 'GET /large HTTP/1.1' . CRLF + . 'Host: localhost' . CRLF + . 'Connection: close' . CRLF + . 'Transfer-Encoding: chunked' . CRLF . CRLF + . ('1; foo' . CRLF . 'X' . CRLF) x 16 + . '0' . CRLF . CRLF + ), + qr/ 200 /, 'chunk extensions' +); + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.31.5'); + +like( + http( + 'GET /large HTTP/1.1' . CRLF + . 'Host: localhost' . CRLF + . 'Connection: close' . CRLF + . 'Transfer-Encoding: chunked' . CRLF . CRLF + . ('1; foo' . CRLF . 'X' . CRLF) x 512 + . '0' . CRLF . CRLF + ), + qr/ 413 /, 'too many chunk extensions' +); + +} + +like( + http( + 'GET /large HTTP/1.1' . CRLF + . 'Host: localhost' . CRLF + . 'Connection: close' . CRLF + . 'Transfer-Encoding: chunked' . CRLF . CRLF + . '1' . CRLF . 'X' . CRLF + . '0' . CRLF . ('X-Trailer: foo' . CRLF) x 16 . CRLF + ), + qr/ 200 /, 'trailers' +); + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.31.5'); + +like( + http( + 'GET /large HTTP/1.1' . CRLF + . 'Host: localhost' . CRLF + . 'Connection: close' . CRLF + . 'Transfer-Encoding: chunked' . CRLF . CRLF + . '1' . CRLF . 'X' . CRLF + . '0' . CRLF . ('X-Trailer: foo' . CRLF) x 512 . CRLF + ), + qr/ 413 /, 'too many trailers' +); + +} + # proxy_next_upstream like(http_get_body('/next', '0123456789'), diff --git a/mail_imap.t b/mail_imap.t index b1dba6cd..77f64a8f 100644 --- a/mail_imap.t +++ b/mail_imap.t @@ -96,7 +96,7 @@ http { EOF $t->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon); -$t->run()->plan(31); +$t->run()->plan(32); $t->waitforsocket('127.0.0.1:' . port(8144)); @@ -201,6 +201,23 @@ $s->read(); $s->send('1 AUTHENTICATE EXTERNAL ' . encode_base64('test@example.com', '')); $s->ok('auth external with username'); +# auth external after failed plain + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.31.5'); + +$s = Test::Nginx::IMAP->new(); +$s->read(); + +$s->send('1 AUTHENTICATE PLAIN ' + . encode_base64("\0test\@example.com\0bad", '')); +$s->read(); + +$s->send('1 AUTHENTICATE EXTERNAL ' . encode_base64('test@example.com', '')); +$s->ok('auth external after plain'); + +} + # quoted strings $s = Test::Nginx::IMAP->new(); diff --git a/proxy_ssl_certificate_vars.t b/proxy_ssl_certificate_vars.t index aff71ffc..d86aa9f7 100644 --- a/proxy_ssl_certificate_vars.t +++ b/proxy_ssl_certificate_vars.t @@ -67,6 +67,20 @@ http { proxy_ssl_certificate $arg_cert; proxy_ssl_certificate_key $arg_cert; } + + location /complex/ { + proxy_ssl_certificate $arg_cert.example.com.crt; + proxy_ssl_certificate_key $arg_cert.example.com.key; + proxy_ssl_password_file password; + + location /complex/1 { + proxy_pass https://127.0.0.1:8082/; + } + + location /complex/2 { + proxy_pass https://127.0.0.1:8082/; + } + } } server { @@ -138,7 +152,7 @@ sleep 1 if $^O eq 'MSWin32'; $t->write_file('password', '3.example.com'); $t->write_file('index.html', ''); -$t->run()->plan(5); +$t->run()->plan(7); ############################################################################### @@ -161,4 +175,16 @@ like(http_get('/optimized?cert=3'), like(http_get('/none'), qr/X-Verify: NONE/ms, 'variable - no certificate'); +TODO: { +todo_skip 'leaves coredump', 2 unless $t->has_version('1.27.5') + or $ENV{TEST_NGINX_UNSAFE}; + +like(http_get('/complex/1?cert=3'), + qr/X-Verify: SUCCESS/ms, 'variable - inherited encrypted key 1st'); + +like(http_get('/complex/2?cert=3'), + qr/X-Verify: SUCCESS/ms, 'variable - inherited encrypted key 2nd'); + +} + ############################################################################### diff --git a/ssi_stub.t b/ssi_stub.t new file mode 100644 index 00000000..85aafb5b --- /dev/null +++ b/ssi_stub.t @@ -0,0 +1,108 @@ +#!/usr/bin/perl + +# (C) Maxim Dounin + +# Tests for nginx ssi module, stub output. + +############################################################################### + +use warnings; +use strict; + +use Test::More; + +BEGIN { use FindBin; chdir($FindBin::Bin); } + +use lib 'lib'; +use Test::Nginx; + +############################################################################### + +select STDERR; $| = 1; +select STDOUT; $| = 1; + +my $t = Test::Nginx->new()->has(qw/http proxy ssi/)->plan(4) + ->write_file_expand('nginx.conf', <<'EOF'); + +%%TEST_GLOBALS%% + +daemon off; + +events { +} + +http { + %%TEST_GLOBALS_HTTP%% + + server { + listen 127.0.0.1:8080; + server_name localhost; + + location / { + ssi on; + } + + location = /empty { + # static + } + + location = /error404 { + # static 404 + } + + location = /proxy404 { + proxy_pass http://127.0.0.1:8081; + proxy_intercept_errors on; + error_page 404 /error404; + } + + location = /not_empty { + proxy_pass http://127.0.0.1:8081; + } + } + + server { + listen 127.0.0.1:8081; + server_name localhost; + } +} + +EOF + +$t->write_file('empty.html', + 'fallback' . + '::'); + +$t->write_file('error.html', + 'fallback' . + '::'); + +$t->write_file('proxy_error.html', + 'fallback' . + '::'); + +$t->write_file('postponed.html', + 'fallback' . + ':' . + '::'); + +$t->write_file('empty', ''); +$t->write_file('not_empty', 'not empty'); + +$t->run(); + +############################################################################### + +like(http_get('/empty.html'), qr/:fallback:/, 'ssi stub empty'); +like(http_get('/error.html'), qr/:fallback:/, 'ssi stub error'); +like(http_get('/proxy_error.html'), qr/:fallback:/, 'ssi stub proxied error'); + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.31.5'); + +like(http_get('/postponed.html'), qr/:not empty:fallback:/s, + 'ssi stub postponed'); + +} + +###############################################################################