85 lines
6.8 KiB
JavaScript
85 lines
6.8 KiB
JavaScript
"use strict";
|
|
require("typings-test");
|
|
const smartchai_1 = require("smartchai");
|
|
const cflare = require("cflare");
|
|
const qenv = require("qenv");
|
|
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit');
|
|
// import the module to test
|
|
const smartacme = require("../dist/index");
|
|
let myCflareAccount = new cflare.CflareAccount();
|
|
myCflareAccount.auth({
|
|
email: process.env.CF_EMAIL,
|
|
key: process.env.CF_KEY
|
|
});
|
|
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(false);
|
|
testSmartAcme.init().then(() => {
|
|
smartchai_1.expect(testSmartAcme).to.be.instanceOf(smartacme.SmartAcme);
|
|
done();
|
|
}).catch(err => { done(err); });
|
|
});
|
|
it('should have created keyPair', function () {
|
|
smartchai_1.expect(testSmartAcme.acmeUrl).to.be.a('string');
|
|
});
|
|
it('should register a new account', function (done) {
|
|
this.timeout(10000);
|
|
testSmartAcme.createAcmeAccount().then(x => {
|
|
testAcmeAccount = x;
|
|
done();
|
|
}).catch(err => {
|
|
console.log(err);
|
|
done(err);
|
|
});
|
|
});
|
|
it('should create a AcmeCert', function () {
|
|
testAcmeAccount.createAcmeCert('test2.bleu.de').then(x => {
|
|
testAcmeCert = x;
|
|
smartchai_1.expect(testAcmeAccount).to.be.instanceOf(smartacme.AcmeCert);
|
|
});
|
|
});
|
|
it('should get a challenge for a AcmeCert', function (done) {
|
|
this.timeout(10000);
|
|
testAcmeCert.requestChallenge().then((challengeChosen) => {
|
|
console.log(challengeChosen);
|
|
testChallenge = challengeChosen;
|
|
done();
|
|
});
|
|
});
|
|
it('should set the challenge', function (done) {
|
|
this.timeout(20000);
|
|
myCflareAccount.createRecord(testChallenge.domainNamePrefixed, 'TXT', testChallenge.dnsKeyHash).then(() => {
|
|
done();
|
|
});
|
|
});
|
|
it('should check for a DNS record', function (done) {
|
|
this.timeout(20000);
|
|
testAcmeCert.checkDns().then(x => {
|
|
console.log(x);
|
|
done();
|
|
});
|
|
});
|
|
it('should accept the challenge', function (done) {
|
|
this.timeout(10000);
|
|
testAcmeCert.acceptChallenge().then(() => { done(); });
|
|
});
|
|
it('should poll for validation of a challenge', function (done) {
|
|
this.timeout(10000);
|
|
testAcmeCert.requestValidation().then(x => {
|
|
console.log(x);
|
|
done();
|
|
});
|
|
});
|
|
it('should remove the challenge', function (done) {
|
|
this.timeout(20000);
|
|
myCflareAccount.removeRecord(testChallenge.domainNamePrefixed, 'TXT').then(() => {
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQix5Q0FBa0M7QUFDbEMsaUNBQWdDO0FBQ2hDLDZCQUE0QjtBQUU1QixJQUFJLFFBQVEsR0FBRyxJQUFJLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxFQUFFLE9BQU8sQ0FBQyxHQUFHLEVBQUUsR0FBRyxTQUFTLENBQUMsQ0FBQTtBQUV0RSw0QkFBNEI7QUFDNUIsMkNBQTBDO0FBRTFDLElBQUksZUFBZSxHQUFHLElBQUksTUFBTSxDQUFDLGFBQWEsRUFBRSxDQUFBO0FBQ2hELGVBQWUsQ0FBQyxJQUFJLENBQUM7SUFDakIsS0FBSyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUTtJQUMzQixHQUFHLEVBQUUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxNQUFNO0NBQzFCLENBQUMsQ0FBQTtBQUVGLFFBQVEsQ0FBQyxXQ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