close server only when finished

This commit is contained in:
AJ ONeal 2016-08-09 14:17:44 -04:00
parent 7730ffc319
commit 40c336f204
1 changed files with 11 additions and 8 deletions

View File

@ -5,8 +5,11 @@ var le = LE.create({
server: 'staging' server: 'staging'
, acme: require('le-acme-core').ACME.create() , acme: require('le-acme-core').ACME.create()
, store: require('le-store-certbot').create({ , store: require('le-store-certbot').create({
configDir: '~/letsencrypt.test/etc/' configDir: '~/letsencrypt.test/etc'
, webrootPath: '~/letsencrypt.test/tmp/:hostname' , webrootPath: '~/letsencrypt.test/var/:hostname'
})
, challenge: require('le-challenge-fs').create({
webrootPath: '~/letsencrypt.test/var/:hostname'
}) })
, debug: true , debug: true
}); });
@ -23,7 +26,7 @@ var testDomains = [ 'pokemap.hellabit.com', 'www.pokemap.hellabit.com' ];
var tests = [ var tests = [
function () { function () {
return le.core.certificates.checkAsync({ return le.core.certificates.checkAsync({
domains: [ 'example.com' ] domains: [ 'example.com', 'www.example.com' ]
}).then(function (cert) { }).then(function (cert) {
if (cert) { if (cert) {
throw new Error("Bogus domain should not have certificate."); throw new Error("Bogus domain should not have certificate.");
@ -32,12 +35,12 @@ var tests = [
} }
, function () { , function () {
return le.core.certificates.checkAsync({ return le.core.certificates.getAsync({
email: testEmail email: testEmail
, domains: testDomains , domains: testDomains
}).then(function (account) { }).then(function (certs) {
if (!account) { if (!certs) {
throw new Error("Test account should exist when searched by email."); throw new Error("Should have acquired certificate for domains.");
} }
}); });
} }
@ -52,6 +55,7 @@ function run() {
function next() { function next() {
var test = tests.shift(); var test = tests.shift();
if (!test) { if (!test) {
server.close();
console.info('All tests passed'); console.info('All tests passed');
return; return;
} }
@ -59,7 +63,6 @@ function run() {
test().then(next, function (err) { test().then(next, function (err) {
console.error('ERROR'); console.error('ERROR');
console.error(err.stack); console.error(err.stack);
}).then(function () {
server.close(); server.close();
}); });
} }