comparison userid.t @ 1422:2d7fcd713b66

Tests: added userid tests with IPv6 and unix sockets.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 24 Dec 2018 19:56:15 +0300
parents 382011b269f1
children a8d18c2852ab
comparison
equal deleted inserted replaced
1421:4e48bf51714f 1422:2d7fcd713b66
24 ############################################################################### 24 ###############################################################################
25 25
26 select STDERR; $| = 1; 26 select STDERR; $| = 1;
27 select STDOUT; $| = 1; 27 select STDOUT; $| = 1;
28 28
29 my $t = Test::Nginx->new()->has(qw/http userid map/)->plan(33); 29 my $t = Test::Nginx->new()->has(qw/http userid map unix/);
30 30
31 $t->write_file_expand('nginx.conf', <<'EOF'); 31 $t->write_file_expand('nginx.conf', <<'EOF');
32 32
33 %%TEST_GLOBALS%% 33 %%TEST_GLOBALS%%
34 34
46 log log; 46 log log;
47 } 47 }
48 48
49 server { 49 server {
50 listen 127.0.0.1:8080; 50 listen 127.0.0.1:8080;
51 listen [::1]:%%PORT_8080%%;
52 listen unix:%%TESTDIR%%/unix.sock;
51 server_name localhost; 53 server_name localhost;
52 54
53 add_header X-Got $uid_got; 55 add_header X-Got $uid_got;
54 add_header X-Reset $uid_reset; 56 add_header X-Reset $uid_reset;
55 add_header X-Set $uid_set; 57 add_header X-Set $uid_set;
113 } 115 }
114 116
115 location /cv1 { 117 location /cv1 {
116 userid v1; 118 userid v1;
117 userid_mark t; 119 userid_mark t;
120 }
121
122 location /ip6 {
123 userid off;
124 proxy_pass http://[::1]:%%PORT_8080%%/;
125 }
126
127 location /unix {
128 userid off;
129 proxy_pass http://unix:%%TESTDIR%%/unix.sock:/;
118 } 130 }
119 131
120 location /clog { 132 location /clog {
121 userid log; 133 userid log;
122 } 134 }
133 $t->write_file('expires_time', ''); 145 $t->write_file('expires_time', '');
134 $t->write_file('service', ''); 146 $t->write_file('service', '');
135 $t->write_file('cv1', ''); 147 $t->write_file('cv1', '');
136 $t->write_file('clog', ''); 148 $t->write_file('clog', '');
137 $t->write_file('coff', ''); 149 $t->write_file('coff', '');
138 $t->run(); 150 $t->try_run('no inet6 support')->plan(35);
139 151
140 ############################################################################### 152 ###############################################################################
141 153
142 # userid 154 # userid
143 155
210 is(substr(uid_set(http_get('/')), 0, 8), $addr, 'service default v2'); 222 is(substr(uid_set(http_get('/')), 0, 8), $addr, 'service default v2');
211 223
212 $addr = $bigendian ? "0000FFFE" : "FEFF0000"; 224 $addr = $bigendian ? "0000FFFE" : "FEFF0000";
213 is(substr(uid_set(http_get('/service')), 0, 8), $addr, 'service custom'); 225 is(substr(uid_set(http_get('/service')), 0, 8), $addr, 'service custom');
214 226
227 $addr = $bigendian ? "00000001" : "01000000";
228 is(substr(uid_set(http_get('/ip6')), 0, 8), $addr, 'service ipv6');
229
230 TODO: {
231 local $TODO = 'not yet';
232
233 is(substr(uid_set(http_get('/unix')), 0, 8), "00000000", 'service unix');
234
235 }
236
215 # reset log 237 # reset log
216 238
217 send_uid('/?log', cookie($r, 'uid')); 239 send_uid('/?log', cookie($r, 'uid'));
218 240
219 $t->stop(); 241 $t->stop();