File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,6 +107,20 @@ local function parse_params(node)
107107 }
108108end
109109
110+ local function server_was_changed (name , node , host , port )
111+ if servers [name ].httpd .host ~= host or servers [name ].httpd .port ~= port then
112+ return true
113+ end
114+ for k in pairs (node ) do
115+ if k ~= ' listen' then
116+ if servers [name ].httpd .options [k ] ~= node [k ] then
117+ return true
118+ end
119+ end
120+ end
121+ return false
122+ end
123+
110124local function apply_http (name , node )
111125 local host , port , err = parse_listen (node .listen )
112126 if err ~= nil then
@@ -121,7 +135,7 @@ local function apply_http(name, node)
121135 httpd = httpd ,
122136 routes = {},
123137 }
124- elseif servers [ name ]. httpd . host ~= host or servers [ name ]. httpd . port ~= port then
138+ elseif server_was_changed ( name , node , host , port ) then
125139 servers [name ].httpd :stop ()
126140 servers [name ].httpd = http_server .new (host , port , parse_params (node ))
127141 servers [name ].httpd :start ()
Original file line number Diff line number Diff line change @@ -203,3 +203,22 @@ for _, log_lvl in pairs(LOG_LEVELS) do
203203 assert_should_log (log_level >= LOG_LEVELS .INFO )
204204 end
205205end
206+
207+ g .test_enable_tls_on_config_reload = function (cg )
208+ -- We should start with no tls firstly.
209+ t .skip_if (cg .params .use_tls )
210+
211+ local resp = http_client :get (' http://localhost:13000/ping' )
212+ t .assert_equals (resp .status , 200 , ' response not 200' )
213+ t .assert_equals (resp .body , ' pong' )
214+
215+ treegen .write_file (cg .server .chdir , ' config.yaml' , yaml .encode (tls_config ))
216+ local _ , err = cg .server :eval (" require('config'):reload()" )
217+ t .assert_not (err )
218+
219+ resp = http_client :get (' https://localhost:13000/ping' , {
220+ ca_file = fio .pathjoin (ssl_data_dir , ' ca.crt' )
221+ })
222+ t .assert_equals (resp .status , 200 , ' response not 200' )
223+ t .assert_equals (resp .body , ' pong' )
224+ end
You can’t perform that action at this time.
0 commit comments