Skip to content

Commit cf5fb98

Browse files
spacewanderagentzh
authored andcommitted
tests: corrected the No SNI, No verify case in 129-ssl-socket.t.
Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
1 parent 01b3145 commit cf5fb98

File tree

1 file changed

+35
-15
lines changed

1 file changed

+35
-15
lines changed

t/129-ssl-socket.t

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ use Test::Nginx::Socket::Lua;
44

55
repeat_each(2);
66

7-
plan tests => repeat_each() * 217;
7+
plan tests => repeat_each() * 218;
88

99
$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
1010

1111
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
1212
$ENV{TEST_NGINX_RESOLVER} ||= '8.8.8.8';
13+
$ENV{TEST_NGINX_SERVER_SSL_PORT} ||= 12345;
1314

1415
#log_level 'warn';
1516
log_level 'debug';
@@ -123,19 +124,27 @@ SSL reused session
123124

124125

125126
=== TEST 2: no SNI, no verify
127+
--- http_config
128+
server {
129+
listen $TEST_NGINX_SERVER_SSL_PORT ssl;
130+
server_name test.com;
131+
ssl_certificate ../html/test.crt;
132+
ssl_certificate_key ../html/test.key;
133+
134+
location / {
135+
content_by_lua_block {
136+
ngx.exit(201)
137+
}
138+
}
139+
}
126140
--- config
127-
server_tokens off;
128141
resolver $TEST_NGINX_RESOLVER ipv6=off;
129142
location /t {
130-
#set $port 5000;
131-
set $port $TEST_NGINX_MEMCACHED_PORT;
132-
133-
content_by_lua '
134-
local sock = ngx.socket.tcp()
135-
sock:settimeout(2000)
136-
143+
content_by_lua_block {
137144
do
138-
local ok, err = sock:connect("openresty.org", 443)
145+
local sock = ngx.socket.tcp()
146+
sock:settimeout(2000)
147+
local ok, err = sock:connect("127.0.0.1", $TEST_NGINX_SERVER_SSL_PORT)
139148
if not ok then
140149
ngx.say("failed to connect: ", err)
141150
return
@@ -151,7 +160,7 @@ SSL reused session
151160

152161
ngx.say("ssl handshake: ", type(session))
153162

154-
local req = "GET / HTTP/1.1\\r\\nHost: openresty.org\\r\\nConnection: close\\r\\n\\r\\n"
163+
local req = "GET / HTTP/1.1\r\nHost: test.com\r\nConnection: close\r\n\r\n"
155164
local bytes, err = sock:send(req)
156165
if not bytes then
157166
ngx.say("failed to send http request: ", err)
@@ -172,21 +181,32 @@ SSL reused session
172181
ngx.say("close: ", ok, " ", err)
173182
end -- do
174183
collectgarbage()
175-
';
184+
}
176185
}
177186

178187
--- request
179188
GET /t
180189
--- response_body
181190
connected: 1
182-
failed to do SSL handshake: handshake failed
191+
ssl handshake: userdata
192+
sent http request: 53 bytes.
193+
received: HTTP/1.1 201 Created
194+
close: 1 nil
195+
--- user_files eval
196+
">>> test.key
197+
$::TestCertificateKey
198+
>>> test.crt
199+
$::TestCertificate"
183200

184-
--- log_level: debug
185201
--- grep_error_log eval: qr/lua ssl (?:set|save|free) session: [0-9A-F]+/
186-
--- grep_error_log_out
202+
--- grep_error_log_out eval
203+
qr/^lua ssl save session: ([0-9A-F]+)
204+
lua ssl free session: ([0-9A-F]+)
205+
$/
187206
--- no_error_log
188207
lua ssl server name:
189208
SSL reused session
209+
[error]
190210
[alert]
191211
--- timeout: 5
192212

0 commit comments

Comments
 (0)