comparison auth_basic.t @ 666:64f22e0aaab2

Tests: auth basic tests for merged "off" value and user not found.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 27 Aug 2015 15:19:27 +0300
parents d5b541a8cf95
children 6bb1f2ccd386
comparison
equal deleted inserted replaced
665:3a8dc14b98ba 666:64f22e0aaab2
21 ############################################################################### 21 ###############################################################################
22 22
23 select STDERR; $| = 1; 23 select STDERR; $| = 1;
24 select STDOUT; $| = 1; 24 select STDOUT; $| = 1;
25 25
26 my $t = Test::Nginx->new()->has(qw/http auth_basic/)->plan(19) 26 my $t = Test::Nginx->new()->has(qw/http auth_basic/)->plan(21)
27 ->write_file_expand('nginx.conf', <<'EOF'); 27 ->write_file_expand('nginx.conf', <<'EOF');
28 28
29 %%TEST_GLOBALS%% 29 %%TEST_GLOBALS%%
30 30
31 daemon off; 31 daemon off;
41 server_name localhost; 41 server_name localhost;
42 42
43 location / { 43 location / {
44 auth_basic "closed site"; 44 auth_basic "closed site";
45 auth_basic_user_file %%TESTDIR%%/htpasswd; 45 auth_basic_user_file %%TESTDIR%%/htpasswd;
46
47 location /inner {
48 auth_basic off;
49 alias %%TESTDIR%%/;
50 }
46 } 51 }
47 } 52 }
48 } 53 }
49 54
50 EOF 55 EOF
113 like(http_get_auth('/', 'ssha2', '1'), qr!401 Unauthorized!, 'ssha broken 1'); 118 like(http_get_auth('/', 'ssha2', '1'), qr!401 Unauthorized!, 'ssha broken 1');
114 like(http_get_auth('/', 'ssha3', '1'), qr!401 Unauthorized!, 'ssha broken 2'); 119 like(http_get_auth('/', 'ssha3', '1'), qr!401 Unauthorized!, 'ssha broken 2');
115 like(http_get_auth('/', 'sha2', '1'), qr!401 Unauthorized!, 'sha broken 1'); 120 like(http_get_auth('/', 'sha2', '1'), qr!401 Unauthorized!, 'sha broken 1');
116 like(http_get_auth('/', 'sha3', '1'), qr!401 Unauthorized!, 'sha broken 2'); 121 like(http_get_auth('/', 'sha3', '1'), qr!401 Unauthorized!, 'sha broken 2');
117 122
123 like(http_get_auth('/', 'notfound', '1'), qr!401 Unauthorized!, 'not found');
124 like(http_get('/inner/'), qr!SEETHIS!, 'inner off');
125
118 ############################################################################### 126 ###############################################################################
119 127
120 sub http_get_auth { 128 sub http_get_auth {
121 my ($url, $user, $password) = @_; 129 my ($url, $user, $password) = @_;
122 130