Mercurial > hg > nginx-tests
comparison ssl.t @ 974:882267679006
Tests: simplified parallel modifications in tests.
Mail tests were simplified in c227348453db.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 12 Jul 2016 17:39:03 +0300 |
parents | e9064d691790 |
children | 4606a2ec3d7c |
comparison
equal
deleted
inserted
replaced
973:7d7aef8b9f3a | 974:882267679006 |
---|---|
46 ssl_certificate_key localhost.key; | 46 ssl_certificate_key localhost.key; |
47 ssl_certificate localhost.crt; | 47 ssl_certificate localhost.crt; |
48 ssl_session_tickets off; | 48 ssl_session_tickets off; |
49 | 49 |
50 server { | 50 server { |
51 listen 127.0.0.1:%%PORT_5%% ssl; | 51 listen 127.0.0.1:8085 ssl; |
52 listen 127.0.0.1:%%PORT_0%%; | 52 listen 127.0.0.1:8080; |
53 server_name localhost; | 53 server_name localhost; |
54 | 54 |
55 ssl_certificate_key inner.key; | 55 ssl_certificate_key inner.key; |
56 ssl_certificate inner.crt; | 56 ssl_certificate inner.crt; |
57 ssl_session_cache shared:SSL:1m; | 57 ssl_session_cache shared:SSL:1m; |
72 return 200 "body $ssl_protocol"; | 72 return 200 "body $ssl_protocol"; |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 server { | 76 server { |
77 listen 127.0.0.1:%%PORT_1%%; | 77 listen 127.0.0.1:8081; |
78 server_name localhost; | 78 server_name localhost; |
79 | 79 |
80 # Special case for enabled "ssl" directive. | 80 # Special case for enabled "ssl" directive. |
81 | 81 |
82 ssl on; | 82 ssl on; |
87 return 200 "body $ssl_session_reused"; | 87 return 200 "body $ssl_session_reused"; |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 server { | 91 server { |
92 listen 127.0.0.1:%%PORT_2%% ssl; | 92 listen 127.0.0.1:8082 ssl; |
93 server_name localhost; | 93 server_name localhost; |
94 | 94 |
95 ssl_session_cache builtin:1000; | 95 ssl_session_cache builtin:1000; |
96 | 96 |
97 location / { | 97 location / { |
98 return 200 "body $ssl_session_reused"; | 98 return 200 "body $ssl_session_reused"; |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 server { | 102 server { |
103 listen 127.0.0.1:%%PORT_3%% ssl; | 103 listen 127.0.0.1:8083 ssl; |
104 server_name localhost; | 104 server_name localhost; |
105 | 105 |
106 ssl_session_cache none; | 106 ssl_session_cache none; |
107 | 107 |
108 location / { | 108 location / { |
109 return 200 "body $ssl_session_reused"; | 109 return 200 "body $ssl_session_reused"; |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 server { | 113 server { |
114 listen 127.0.0.1:%%PORT_4%% ssl; | 114 listen 127.0.0.1:8084 ssl; |
115 server_name localhost; | 115 server_name localhost; |
116 | 116 |
117 ssl_session_cache off; | 117 ssl_session_cache off; |
118 | 118 |
119 location / { | 119 location / { |
148 | 148 |
149 $t->run(); | 149 $t->run(); |
150 | 150 |
151 ############################################################################### | 151 ############################################################################### |
152 | 152 |
153 like(http_get('/reuse', socket => get_ssl_socket($ctx, port(5))), | 153 like(http_get('/reuse', socket => get_ssl_socket($ctx, port(8085))), |
154 qr/^body \.$/m, 'shared initial session'); | 154 qr/^body \.$/m, 'shared initial session'); |
155 like(http_get('/reuse', socket => get_ssl_socket($ctx, port(5))), | 155 like(http_get('/reuse', socket => get_ssl_socket($ctx, port(8085))), |
156 qr/^body r$/m, 'shared session reused'); | 156 qr/^body r$/m, 'shared session reused'); |
157 | 157 |
158 like(http_get('/', socket => get_ssl_socket($ctx, port(1))), qr/^body \.$/m, | 158 like(http_get('/', socket => get_ssl_socket($ctx, port(8081))), qr/^body \.$/m, |
159 'builtin initial session'); | 159 'builtin initial session'); |
160 like(http_get('/', socket => get_ssl_socket($ctx, port(1))), qr/^body r$/m, | 160 like(http_get('/', socket => get_ssl_socket($ctx, port(8081))), qr/^body r$/m, |
161 'builtin session reused'); | 161 'builtin session reused'); |
162 | 162 |
163 like(http_get('/', socket => get_ssl_socket($ctx, port(2))), qr/^body \.$/m, | 163 like(http_get('/', socket => get_ssl_socket($ctx, port(8082))), qr/^body \.$/m, |
164 'builtin size initial session'); | 164 'builtin size initial session'); |
165 like(http_get('/', socket => get_ssl_socket($ctx, port(2))), qr/^body r$/m, | 165 like(http_get('/', socket => get_ssl_socket($ctx, port(8082))), qr/^body r$/m, |
166 'builtin size session reused'); | 166 'builtin size session reused'); |
167 | 167 |
168 like(http_get('/', socket => get_ssl_socket($ctx, port(3))), qr/^body \.$/m, | 168 like(http_get('/', socket => get_ssl_socket($ctx, port(8083))), qr/^body \.$/m, |
169 'reused none initial session'); | 169 'reused none initial session'); |
170 like(http_get('/', socket => get_ssl_socket($ctx, port(3))), qr/^body \.$/m, | 170 like(http_get('/', socket => get_ssl_socket($ctx, port(8083))), qr/^body \.$/m, |
171 'session not reused 1'); | 171 'session not reused 1'); |
172 | 172 |
173 like(http_get('/', socket => get_ssl_socket($ctx, port(4))), qr/^body \.$/m, | 173 like(http_get('/', socket => get_ssl_socket($ctx, port(8084))), qr/^body \.$/m, |
174 'reused off initial session'); | 174 'reused off initial session'); |
175 like(http_get('/', socket => get_ssl_socket($ctx, port(4))), qr/^body \.$/m, | 175 like(http_get('/', socket => get_ssl_socket($ctx, port(8084))), qr/^body \.$/m, |
176 'session not reused 2'); | 176 'session not reused 2'); |
177 | 177 |
178 # ssl certificate inheritance | 178 # ssl certificate inheritance |
179 | 179 |
180 my $s = get_ssl_socket($ctx, port(1)); | 180 my $s = get_ssl_socket($ctx, port(8081)); |
181 like($s->dump_peer_certificate(), qr/CN=localhost/, 'CN'); | 181 like($s->dump_peer_certificate(), qr/CN=localhost/, 'CN'); |
182 | 182 |
183 $s->close(); | 183 $s->close(); |
184 | 184 |
185 $s = get_ssl_socket($ctx, port(5)); | 185 $s = get_ssl_socket($ctx, port(8085)); |
186 like($s->dump_peer_certificate(), qr/CN=inner/, 'CN inner'); | 186 like($s->dump_peer_certificate(), qr/CN=inner/, 'CN inner'); |
187 | 187 |
188 $s->close(); | 188 $s->close(); |
189 | 189 |
190 # session timeout | 190 # session timeout |
191 | 191 |
192 select undef, undef, undef, 2.1; | 192 select undef, undef, undef, 2.1; |
193 | 193 |
194 like(http_get('/', socket => get_ssl_socket($ctx, port(1))), qr/^body \.$/m, | 194 like(http_get('/', socket => get_ssl_socket($ctx, port(8081))), qr/^body \.$/m, |
195 'session timeout'); | 195 'session timeout'); |
196 | 196 |
197 # embedded variables | 197 # embedded variables |
198 | 198 |
199 my ($sid) = http_get('/id', | 199 my ($sid) = http_get('/id', |
200 socket => get_ssl_socket($ctx, port(5))) =~ /^body (\w+)$/m; | 200 socket => get_ssl_socket($ctx, port(8085))) =~ /^body (\w+)$/m; |
201 is(length $sid, 64, 'session id'); | 201 is(length $sid, 64, 'session id'); |
202 | 202 |
203 unlike(http_get('/id'), qr/body \w/, 'session id no ssl'); | 203 unlike(http_get('/id'), qr/body \w/, 'session id no ssl'); |
204 | 204 |
205 like(http_get('/cipher', socket => get_ssl_socket($ctx, port(5))), | 205 like(http_get('/cipher', socket => get_ssl_socket($ctx, port(8085))), |
206 qr/^body [\w-]+$/m, 'cipher'); | 206 qr/^body [\w-]+$/m, 'cipher'); |
207 | 207 |
208 like(http_get('/client_verify', socket => get_ssl_socket($ctx, port(5))), | 208 like(http_get('/client_verify', socket => get_ssl_socket($ctx, port(8085))), |
209 qr/^body NONE$/m, 'client verify'); | 209 qr/^body NONE$/m, 'client verify'); |
210 | 210 |
211 like(http_get('/protocol', socket => get_ssl_socket($ctx, port(5))), | 211 like(http_get('/protocol', socket => get_ssl_socket($ctx, port(8085))), |
212 qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol'); | 212 qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol'); |
213 | 213 |
214 ############################################################################### | 214 ############################################################################### |
215 | 215 |
216 sub get_ssl_socket { | 216 sub get_ssl_socket { |