smartacme/test/test.js

75 lines
5.8 KiB
JavaScript
Raw Normal View History

2016-11-01 17:27:57 +00:00
"use strict";
require("typings-test");
2016-11-01 19:16:43 +00:00
const should = require("should");
2017-01-22 20:50:04 +00:00
const cflare = require("cflare");
const qenv = require("qenv");
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit');
2016-11-01 19:16:43 +00:00
// import the module to test
const smartacme = require("../dist/index");
2017-01-22 20:50:04 +00:00
let myCflareAccount = new cflare.CflareAccount();
myCflareAccount.auth({
email: process.env.CF_EMAIL,
key: process.env.CF_KEY
});
2016-11-01 17:27:57 +00:00
describe('smartacme', function () {
2017-01-14 17:36:33 +00:00
let testSmartAcme;
let testAcmeAccount;
2017-01-15 11:21:29 +00:00
let testAcmeCert;
2017-01-14 13:14:50 +00:00
let testChallenge;
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-01 19:16:43 +00:00
});
2016-11-07 17:41:52 +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-07 17:41:52 +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-15 22:11:51 +00:00
testSmartAcme.createAcmeAccount().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-15 11:21:29 +00:00
it('should create a AcmeCert', function () {
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-22 20:50:04 +00:00
it('should set the challenge', function (done) {
this.timeout(30000);
myCflareAccount.createRecord(testChallenge.domainNamePrefixed, 'TXT', testChallenge.dnsKeyHash).then(() => {
done();
});
});
2017-01-15 21:30:33 +00:00
it('should check for a DNS record', function (done) {
2017-01-22 20:50:04 +00:00
this.timeout(40000);
2017-01-15 21:30:33 +00:00
testAcmeCert.checkDns().then(x => {
console.log(x);
done();
});
});
2017-01-22 20:50:04 +00:00
it('should poll for validation of a challenge', function (done) {
this.timeout(700000);
testAcmeCert.requestValidation().then(x => {
2017-01-22 20:50:04 +00:00
console.log(x);
2017-01-01 20:20:12 +00:00
done();
});
});
2016-11-01 17:27:57 +00:00
});
2017-01-22 20:50:04 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFDaEMsaUNBQWdDO0FBQ2hDLDZCQUE0QjtBQUU1QixJQUFJLFFBQVEsR0FBRyxJQUFJLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxFQUFFLE9BQU8sQ0FBQyxHQUFHLEVBQUUsR0FBRyxTQUFTLENBQUMsQ0FBQTtBQUV0RSw0QkFBNEI7QUFDNUIsMkNBQTBDO0FBRTFDLElBQUksZUFBZSxHQUFHLElBQUksTUFBTSxDQUFDLGFBQWEsRUFBRSxDQUFBO0FBQ2hELGVBQWUsQ0FBQyxJQUFJLENBQUM7SUFD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