smartacme/test/test.js

59 lines
4.5 KiB
JavaScript

"use strict";
require("typings-test");
const should = require("should");
// import the module to test
const smartacme = require("../dist/index");
describe('smartacme', function () {
let testSmartAcme;
let testAcmeAccount;
let testAcmeCert;
let testChallenge;
it('should create a valid instance', function (done) {
this.timeout(10000);
testSmartAcme = new smartacme.SmartAcme();
testSmartAcme.init().then(() => {
should(testSmartAcme).be.instanceOf(smartacme.SmartAcme);
done();
}).catch(err => { done(err); });
});
it('should have created keyPair', function () {
should(testSmartAcme.acmeUrl).be.of.type('string');
});
it('should register a new account', function (done) {
this.timeout(10000);
testSmartAcme.createAccount().then(x => {
testAcmeAccount = x;
done();
}).catch(err => {
console.log(err);
done(err);
});
});
it('should create a AcmeCert', function () {
testAcmeAccount.createAcmeCert('test1.bleu.de').then(x => {
testAcmeCert = x;
should(testAcmeAccount).be.instanceOf(smartacme.AcmeCert);
});
});
it('should get a challenge for a AcmeCert', function (done) {
this.timeout(10000);
testAcmeCert.requestChallenge().then((challengeAccepted) => {
console.log(challengeAccepted);
testChallenge = challengeAccepted;
done();
});
});
it('should check for a DNS record', function (done) {
testAcmeCert.checkDns().then(x => {
console.log(x);
done();
});
});
it('should poll for validation of a challenge', function (done) {
this.timeout(10000);
testAcmeCert.requestValidation().then(x => {
done();
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFHaEMsNEJBQTRCO0FBQzVCLDJDQUEwQztBQUUxQyxRQUFRLENBQUMsV0FBVyxFQUFFO0lBQ2xCLElBQUksYUFBa0MsQ0FBQTtJQUN0QyxJQUFJLGVBQXNDLENBQUE7SUFDMUMsSUFBSSxZQUFnQyxDQUFBO0lBQ3BDLElBQUksYUFBb0QsQ0FBQTtJQUV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