smartacme/test/test.js

53 lines
4.1 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");
// import the module to test
const smartacme = require("../dist/index");
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-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-15 11:21:29 +00:00
it('should create a AcmeCert', function () {
testAcmeAccount.createAcmeCert('bleu.de').then(x => {
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-14 17:36:33 +00:00
it.skip('should poll for validation of a challenge', function (done) {
2017-01-14 13:14:50 +00:00
this.timeout(10000);
2017-01-14 17:36:33 +00:00
testSmartAcme.validate(testChallenge).then(x => {
2017-01-01 20:20:12 +00:00
done();
});
});
2016-11-01 17:27:57 +00:00
});
2017-01-15 11:21:29 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFHaEMsNEJBQTRCO0FBQzVCLDJDQUEwQztBQUUxQyxRQUFRLENBQUMsV0FBVyxFQUFFO0lBQ2xCLElBQUksYUFBa0MsQ0FBQTtJQUN0QyxJQUFJLGVBQXNDLENBQUE7SUFDMUMsSUFBSSxZQUFnQyxDQUFBO0lBQ3BDLElBQUksYUFBb0QsQ0FBQTtJQUN4RCxFQUFFLENBQUMsZ0NBQWdDLEVBQUUsVUFBVSxJQUFJO1FBQy9DLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUE7UUFDbkIsYUFBYSxHQUFHLElBQUksU0FBUyxDQUFDLFNBQVMsRUFBRSxDQUFBO1FBQ3pDLGFBQWEsQ0FBQyxJQUFJLEVBQUUsQ0FBQyxJQUFJLENBQUM7WUFDdEIsTUFBTSxDQUFDLGFBQWEsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFBO1lBQ3hELElBQUksRUFBRSxDQUFBO1FBQ1YsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLEdBQUcsTUFBTSxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUEsQ0FBQyxDQUFDLENBQUMsQ0FBQTtJQUNsQyxDQUFDLENBQUMsQ0FBQTtJQUVGLEVBQUUsQ0FBQyw2QkFBNkIsRUFBRTtRQUM5QixNQUFNLENBQUM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