changeset 508:4ac60aad723e

Tests: test for auth request with proxy cache.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 04 Dec 2014 19:18:45 +0300
parents 34280f6b0bc6
children f135127e97af
files auth_request.t
diffstat 1 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/auth_request.t
+++ b/auth_request.t
@@ -24,8 +24,8 @@ select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
 my $t = Test::Nginx->new()
-	->has(qw/http rewrite proxy fastcgi auth_basic auth_request/)
-	->plan(17);
+	->has(qw/http rewrite proxy cache fastcgi auth_basic auth_request/)
+	->plan(19);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -39,6 +39,9 @@ events {
 http {
     %%TEST_GLOBALS_HTTP%%
 
+    proxy_cache_path   %%TESTDIR%%/cache  levels=1:2
+                       keys_zone=NAME:1m;
+
     server {
         listen       127.0.0.1:8080;
         server_name  localhost;
@@ -115,6 +118,17 @@ http {
             proxy_set_header Content-Length "";
         }
 
+        location /proxy-cache {
+            auth_request /auth-proxy-cache;
+        }
+        location = /auth-proxy-cache {
+            proxy_pass http://127.0.0.1:8080/auth-basic;
+            proxy_pass_request_body off;
+            proxy_set_header Content-Length "";
+            proxy_cache NAME;
+            proxy_cache_valid 1m;
+        }
+
         location /fastcgi {
             auth_request /auth-fastcgi;
         }
@@ -154,6 +168,15 @@ unlike(http_get_auth('/proxy'), qr/INVIS
 
 like(http_post('/proxy'), qr/ 401 /, 'proxy auth post');
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.7.3');
+
+like(http_get_auth('/proxy-cache'), qr/ 404 /, 'proxy auth with cache');
+
+}
+
+like(http_get('/proxy-cache'), qr/ 404 /, 'proxy auth cached');
+
 # Consider the following scenario:
 #
 # 1. proxy_pass reads request body, then goes to fallback via error_page