@@ -197,6 +197,52 @@ describe("sanity", function()
197
197
assert .Not .matches (" [emerg]" , error_log , nil , true )
198
198
end )
199
199
200
+ it (" cleans up dehydrated files on certificate registration failure" , function ()
201
+ server .start ()
202
+
203
+ local ls_before_result , ls_before_err = shell_blocking .capture_combined ({ " ls" , " -1" , server .current_test_dir .. " /auto-ssl/letsencrypt" })
204
+ assert .equal (nil , ls_before_err )
205
+ local expected_ls_before = {
206
+ " conf.d" ,
207
+ " config" ,
208
+ " locks" ,
209
+ }
210
+ if server .dehydrated_cached_accounts then
211
+ table.insert (expected_ls_before , " accounts" )
212
+ end
213
+ table.sort (expected_ls_before )
214
+ assert .same (expected_ls_before , pl_utils .split (ls_before_result [" output" ]))
215
+
216
+ local httpc = http .new ()
217
+ local _ , connect_err = httpc :connect (" 127.0.0.1" , 9443 )
218
+ assert .equal (nil , connect_err )
219
+
220
+ local _ , ssl_err = httpc :ssl_handshake (nil , " unresolvable-sdjfklsdjf.example" , true )
221
+ assert .equal (" 18: self signed certificate" , ssl_err )
222
+
223
+ local error_log = server .read_error_log ()
224
+ assert .matches (" auto-ssl: issuing new certificate for unresolvable-sdjfklsdjf.example" , error_log , nil , true )
225
+ assert .matches (" auto-ssl: dehydrated failed" , error_log , nil , true )
226
+ assert .matches (" auto-ssl: could not get certificate for unresolvable-sdjfklsdjf.example" , error_log , nil , true )
227
+ assert .Not .matches (" [alert]" , error_log , nil , true )
228
+ assert .Not .matches (" [emerg]" , error_log , nil , true )
229
+
230
+ local ls_result , ls_err = shell_blocking .capture_combined ({ " ls" , " -1" , server .current_test_dir .. " /auto-ssl/letsencrypt" })
231
+ assert .equal (nil , ls_err )
232
+ assert .same ({
233
+ " accounts" ,
234
+ " certs" ,
235
+ " chains" ,
236
+ " conf.d" ,
237
+ " config" ,
238
+ " locks" ,
239
+ }, pl_utils .split (ls_result [" output" ]))
240
+
241
+ local ls_certs_result , ls_certs_err = shell_blocking .capture_combined ({ " ls" , " -1" , server .current_test_dir .. " /auto-ssl/letsencrypt/certs" })
242
+ assert .equal (nil , ls_certs_err )
243
+ assert .same ({}, pl_utils .split (ls_certs_result [" output" ]))
244
+ end )
245
+
200
246
it (" allows for custom logic to control domain name to handle lack of SNI support" , function ()
201
247
server .start ({
202
248
auto_ssl_pre_new = [[
@@ -378,7 +424,7 @@ describe("sanity", function()
378
424
assert .Not .matches (" [emerg]" , error_log , nil , true )
379
425
end )
380
426
381
- it (" retains dehydrated temporary files if cert deployment fails" , function ()
427
+ it (" deletes dehydrated temporary files if cert deployment fails" , function ()
382
428
server .start ()
383
429
384
430
-- Create a directory where the storage file would normally belong so
@@ -429,9 +475,7 @@ describe("sanity", function()
429
475
430
476
local ls_certs_result , ls_certs_err = shell_blocking .capture_combined ({ " ls" , " -1" , server .current_test_dir .. " /auto-ssl/letsencrypt/certs" })
431
477
assert .equal (nil , ls_certs_err )
432
- assert .same ({
433
- server .ngrok_hostname ,
434
- }, pl_utils .split (ls_certs_result [" output" ]))
478
+ assert .same ({}, pl_utils .split (ls_certs_result [" output" ]))
435
479
436
480
assert (dir .rmtree (server .current_test_dir .. " /auto-ssl/storage/file/" .. ngx .escape_uri (server .ngrok_hostname .. " :latest" )))
437
481
@@ -452,8 +496,9 @@ describe("sanity", function()
452
496
453
497
local error_log = server .nginx_error_log_tail :read ()
454
498
assert .matches (" auto-ssl: issuing new certificate for" , error_log , nil , true )
455
- assert .matches (" Checking domain name(s) of existing cert... unchanged." , error_log , nil , true )
456
- assert .matches (" auto-ssl: dehydrated succeeded, but certs still missing from storage - trying to manually copy" , error_log , nil , true )
499
+ assert .Not .matches (" [error]" , error_log , nil , true )
500
+ assert .Not .matches (" [alert]" , error_log , nil , true )
501
+ assert .Not .matches (" [emerg]" , error_log , nil , true )
457
502
end
458
503
459
504
local error_log = server .read_error_log ()
0 commit comments