Commit e160a930 authored by Aral Balkan's avatar Aral Balkan
Browse files

Fix tests for staging mode

parent e3260239
......@@ -20,11 +20,11 @@ async function setup() {
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.ready()
test.onFinish(async () => {
await Pebble.shutdown()
})
}
test.onFinish(async () => {
await Pebble.shutdown()
})
const customSettingsPath = path.join(os.homedir(), '.small-tech.org', 'auto-encrypt', 'test')
fs.rmSync(customSettingsPath, { recursive: true, force: true })
......
......@@ -21,6 +21,9 @@ async function setup() {
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.ready()
test.onFinish(async () => {
await Pebble.shutdown()
})
}
const customSettingsPath = path.join(os.homedir(), '.small-tech.org', 'auto-encrypt', 'test')
......@@ -36,10 +39,6 @@ async function setup() {
AcmeRequest.uninitialise()
test.onFinish(async () => {
await Pebble.shutdown()
})
return { configuration, accountIdentity, directory }
}
......
......@@ -37,9 +37,11 @@ async function setup() {
fs.rmSync(customSettingsPath, {recursive: true, force: true})
test.onFinish(async () => {
await Pebble.shutdown()
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.shutdown()
}
// As some of the unit tests result in the HTTP Server being created, ensure that it is
// As some of the unit tests result in the HTTP Server being created, ensure that it is
// shut down at the end so we can exit.
await HttpServer.destroySharedInstance()
})
......@@ -226,15 +228,15 @@ test('Certificate', async t => {
certificate2.stopCheckingForRenewal()
// Test that also check now option works with start checking for renewal method.
const actualCheckForRenewalMethod = certificate2.checkForRenewal
const actualCheckForRenewalMethod = certificate2.checkForRenewal.bind(certificate2)
let checkForRenewalCalled = false
certificate2.checkForRenewal = () => {
certificate2.checkForRenewal = (() => {
checkForRenewalCalled = true
}
}).bind(certificate2)
certificate2.startCheckingForRenewal(/* alsoCheckNow */ true)
t.strictEquals(checkForRenewalCalled, true, 'checkForRenewal called via startCheckingForRenewal(true) as expected')
certificate2.checkForRenewal = actualCheckForRenewalMethod
certificate2.stopCheckingForRenewal()
t.end()
})
......@@ -29,7 +29,9 @@ async function setup() {
fs.rmSync(customSettingsPath, { recursive: true, force: true })
test.onFinish(async () => {
await Pebble.shutdown()
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.shutdown()
}
// As some of the unit tests result in the HTTP Server being created, ensure that it is
// shut down at the end so we can exit.
......
......@@ -17,6 +17,9 @@ async function setup() {
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.ready()
test.onFinish(async () => {
await Pebble.shutdown()
})
}
const domains = {
......@@ -36,12 +39,6 @@ async function setup() {
test('Nonce', async t => {
const configuration = await setup()
// Teardown
t.teardown(async () => {
await Pebble.shutdown()
})
const directory = await Directory.getInstanceAsync(configuration)
// Missing directory argument should throw.
......
......@@ -28,7 +28,9 @@ async function setup() {
}
test.onFinish(async () => {
await Pebble.shutdown()
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.shutdown()
}
// As some of the unit tests result in the HTTP Server being created, ensure that it is
// shut down at the end so we can exit.
......
......@@ -21,6 +21,9 @@ async function setup() {
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.ready()
test.onFinish(async () => {
await Pebble.shutdown()
})
}
const domains = {
......@@ -43,10 +46,6 @@ async function setup() {
const account = await Account.getInstanceAsync(configuration)
AcmeRequest.account = account
test.onFinish(async () => {
await Pebble.shutdown()
})
return configuration
}
......
......@@ -21,6 +21,9 @@ async function setup() {
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.ready()
test.onFinish(async () => {
await Pebble.shutdown()
})
}
const domains = {
......@@ -43,10 +46,6 @@ async function setup() {
const account = await Account.getInstanceAsync(configuration)
AcmeRequest.account = account
test.onFinish(async () => {
await Pebble.shutdown()
})
return configuration
}
......
......@@ -21,6 +21,9 @@ async function setup() {
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.ready()
test.onFinish(async () => {
await Pebble.shutdown()
})
}
const domains = {
......@@ -43,10 +46,6 @@ async function setup() {
const account = await Account.getInstanceAsync(configuration)
AcmeRequest.account = account
test.onFinish(async () => {
await Pebble.shutdown()
})
return configuration
}
......
......@@ -21,6 +21,9 @@ async function setup() {
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.ready()
test.onFinish(async () => {
await Pebble.shutdown()
})
}
const domains = {
......@@ -43,10 +46,6 @@ async function setup() {
const account = await Account.getInstanceAsync(configuration)
AcmeRequest.account = account
test.onFinish(async () => {
await Pebble.shutdown()
})
return configuration
}
......
......@@ -21,6 +21,9 @@ async function setup() {
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.ready()
test.onFinish(async () => {
await Pebble.shutdown()
})
}
const domains = {
......@@ -43,10 +46,6 @@ async function setup() {
const account = await Account.getInstanceAsync(configuration)
AcmeRequest.account = account
test.onFinish(async () => {
await Pebble.shutdown()
})
return configuration
}
......
......@@ -21,6 +21,9 @@ async function setup() {
if (letsEncryptServerType === LetsEncryptServer.type.PEBBLE) {
await Pebble.ready()
test.onFinish(async () => {
await Pebble.shutdown()
})
}
const domains = {
......@@ -43,10 +46,6 @@ async function setup() {
const account = await Account.getInstanceAsync(configuration)
AcmeRequest.account = account
test.onFinish(async () => {
await Pebble.shutdown()
})
return configuration
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment