2016-11-01 17:27:57 +00:00
|
|
|
import 'typings-test'
|
|
|
|
import * as should from 'should'
|
2017-01-14 17:36:33 +00:00
|
|
|
import * as cflare from 'cflare'
|
2016-11-01 17:27:57 +00:00
|
|
|
|
|
|
|
// import the module to test
|
|
|
|
import * as smartacme from '../dist/index'
|
|
|
|
|
2016-11-11 13:17:50 +00:00
|
|
|
describe('smartacme', function () {
|
2017-01-14 17:36:33 +00:00
|
|
|
let testSmartAcme: smartacme.SmartAcme
|
|
|
|
let testAcmeAccount: smartacme.AcmeAccount
|
2017-01-15 11:21:29 +00:00
|
|
|
let testAcmeCert: smartacme.AcmeCert
|
2017-01-14 13:14:50 +00:00
|
|
|
let testChallenge: smartacme.ISmartAcmeChallengeAccepted
|
2017-01-15 12:33:55 +00:00
|
|
|
|
2017-01-14 17:36:33 +00:00
|
|
|
it('should create a valid instance', function (done) {
|
2016-11-11 13:17:50 +00:00
|
|
|
this.timeout(10000)
|
2017-01-14 17:36:33 +00:00
|
|
|
testSmartAcme = new smartacme.SmartAcme()
|
|
|
|
testSmartAcme.init().then(() => {
|
|
|
|
should(testSmartAcme).be.instanceOf(smartacme.SmartAcme)
|
|
|
|
done()
|
|
|
|
}).catch(err => { done(err) })
|
2016-11-07 17:41:52 +00:00
|
|
|
})
|
2017-01-14 13:14:50 +00:00
|
|
|
|
2016-11-11 13:17:50 +00:00
|
|
|
it('should have created keyPair', function () {
|
2017-01-14 17:36:33 +00:00
|
|
|
should(testSmartAcme.acmeUrl).be.of.type('string')
|
2016-11-01 19:16:43 +00:00
|
|
|
})
|
2017-01-01 20:20:12 +00:00
|
|
|
|
2016-11-11 13:17:50 +00:00
|
|
|
it('should register a new account', function (done) {
|
2017-01-01 20:20:12 +00:00
|
|
|
this.timeout(10000)
|
2017-01-14 17:36:33 +00:00
|
|
|
testSmartAcme.createAccount().then(x => {
|
2017-01-15 11:21:29 +00:00
|
|
|
testAcmeAccount = x
|
2016-11-11 13:17:50 +00:00
|
|
|
done()
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
done(err)
|
|
|
|
})
|
2016-11-01 19:16:43 +00:00
|
|
|
})
|
2017-01-01 20:20:12 +00:00
|
|
|
|
2017-01-15 11:21:29 +00:00
|
|
|
it('should create a AcmeCert', function() {
|
2017-01-15 12:33:55 +00:00
|
|
|
testAcmeAccount.createAcmeCert('test1.bleu.de').then(x => {
|
2017-01-15 11:21:29 +00:00
|
|
|
testAcmeCert = x
|
|
|
|
should(testAcmeAccount).be.instanceOf(smartacme.AcmeCert)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should get a challenge for a AcmeCert', function (done) {
|
2017-01-01 20:20:12 +00:00
|
|
|
this.timeout(10000)
|
2017-01-15 11:21:29 +00:00
|
|
|
testAcmeCert.requestChallenge().then((challengeAccepted) => {
|
2017-01-14 13:14:50 +00:00
|
|
|
console.log(challengeAccepted)
|
|
|
|
testChallenge = challengeAccepted
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2017-01-15 12:33:55 +00:00
|
|
|
it('should poll for validation of a challenge', function (done) {
|
2017-01-14 13:14:50 +00:00
|
|
|
this.timeout(10000)
|
2017-01-15 12:33:55 +00:00
|
|
|
testAcmeCert.requestValidation().then(x => {
|
2017-01-01 20:20:12 +00:00
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
2016-11-01 17:27:57 +00:00
|
|
|
})
|