Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 64 additions & 1 deletion body_chunked.t
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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'),
Expand Down
19 changes: 18 additions & 1 deletion mail_imap.t
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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();
Expand Down
28 changes: 27 additions & 1 deletion proxy_ssl_certificate_vars.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

###############################################################################

Expand All @@ -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');

}

###############################################################################
108 changes: 108 additions & 0 deletions ssi_stub.t
Original file line number Diff line number Diff line change
@@ -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',
'<!--#block name="fallback" -->fallback<!--#endblock -->' .
':<!--#include virtual="/empty" stub="fallback" -->:');

$t->write_file('error.html',
'<!--#block name="fallback" -->fallback<!--#endblock -->' .
':<!--#include virtual="/error404" stub="fallback" -->:');

$t->write_file('proxy_error.html',
'<!--#block name="fallback" -->fallback<!--#endblock -->' .
':<!--#include virtual="/proxy404" stub="fallback" -->:');

$t->write_file('postponed.html',
'<!--#block name="fallback" -->fallback<!--#endblock -->' .
':<!--#include virtual="/not_empty" -->' .
':<!--#include virtual="/empty" stub="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');

}

###############################################################################