comparison auth_basic.t @ 1719:53a801bf4d0b

Tests: auth_basic_user_file variable tests with conf_prefix.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 30 Jun 2021 23:48:45 +0300
parents 766bcbb632ee
children 032ccd3118cb
comparison
equal deleted inserted replaced
1718:672018971a62 1719:53a801bf4d0b
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(21) 26 my $t = Test::Nginx->new()->has(qw/http auth_basic/)->plan(24)
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;
46 46
47 location /inner { 47 location /inner {
48 auth_basic off; 48 auth_basic off;
49 alias %%TESTDIR%%/; 49 alias %%TESTDIR%%/;
50 } 50 }
51
52 location /var {
53 # prepended with conf_prefix
54 auth_basic_user_file $arg_f;
55 alias %%TESTDIR%%/;
56 }
51 } 57 }
52 } 58 }
53 } 59 }
54 60
55 EOF 61 EOF
110 like(http_get_auth('/', 'sha3', '1'), qr!401 Unauthorized!, 'sha broken 2'); 116 like(http_get_auth('/', 'sha3', '1'), qr!401 Unauthorized!, 'sha broken 2');
111 117
112 like(http_get_auth('/', 'notfound', '1'), qr!401 Unauthorized!, 'not found'); 118 like(http_get_auth('/', 'notfound', '1'), qr!401 Unauthorized!, 'not found');
113 like(http_get('/inner/'), qr!SEETHIS!, 'inner off'); 119 like(http_get('/inner/'), qr!SEETHIS!, 'inner off');
114 120
121 like(http_get_auth('/var/?f=htpasswd', 'apr1', 'password'), qr!SEETHIS!,
122 'user file variable');
123 unlike(http_get_auth('/var/?f=nx', 'apr1', 'password'), qr!SEETHIS!,
124 'user file variable not found');
125 unlike(http_get_auth('/var/', 'apr1', 'password'), qr!SEETHIS!,
126 'user file variable bad value');
127
115 ############################################################################### 128 ###############################################################################
116 129
117 sub http_get_auth { 130 sub http_get_auth {
118 my ($url, $user, $password) = @_; 131 my ($url, $user, $password) = @_;
119 132