changeset 1484:54b92955e4e2

Tests: not_modified_finalize.t with cached response (ticket #1782).
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 04 Jun 2019 13:40:44 +0300
parents 1220f0055135
children 48c3964a10a5
files not_modified_finalize.t
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/not_modified_finalize.t
+++ b/not_modified_finalize.t
@@ -21,7 +21,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(1)
+my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(2)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -46,6 +46,7 @@ http {
             proxy_pass        http://127.0.0.1:8081;
             proxy_cache       cache;
             proxy_cache_lock  on;
+            proxy_cache_valid 1h;
         }
 
         location /error412 {
@@ -76,6 +77,21 @@ like(http_match_get('/t.html'), qr//, 'r
 
 $t->todo_alerts();
 
+# in addition, in 1.11.10 .. 1.17.1, if the response was previously
+# cached, such a request resulted in r->cache null pointer dereference
+# in ngx_http_upstream_cache_background_update(), after it was reset
+# during internal redirect
+
+http_get('/t.html');
+
+TODO: {
+todo_skip 'leaves coredump', 1 unless $ENV{TEST_NGINX_UNSAFE}
+	or $t->has_version('1.17.1');
+
+like(http_match_get('/t.html'), qr//, 'request 412 cached');
+
+}
+
 ###############################################################################
 
 sub http_match_get {