update validation

This commit is contained in:
Philipp Kunz 2017-01-22 21:50:04 +01:00
parent 2cd1794e7e
commit 5fa530456b
12 changed files with 117 additions and 56 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ node_modules/
coverage/ coverage/
public/ public/
pages/ pages/
.nogit/

4
.npmignore Normal file
View File

@ -0,0 +1,4 @@
node_modules/
coverage/
public/
pages/

View File

@ -59,11 +59,11 @@ export declare class AcmeCert {
/** /**
* checks if DNS records are set, will go through a max of 30 cycles * checks if DNS records are set, will go through a max of 30 cycles
*/ */
checkDns(cycleArg?: number): Promise<any>; checkDns(cycleArg?: number): any;
/** /**
* validates a challenge, only call after you have set the challenge at the expected location * validates a challenge, only call after you have set the challenge at the expected location
*/ */
requestValidation(): q.Promise<{}>; requestValidation(): Promise<void>;
/** /**
* requests a certificate * requests a certificate
*/ */

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,7 @@ declare let rsaKeygen: any;
declare let rawacme: any; declare let rawacme: any;
declare let nodeForge: any; declare let nodeForge: any;
import * as dnsly from 'dnsly'; import * as dnsly from 'dnsly';
import * as smartdelay from 'smartdelay';
import * as smartfile from 'smartfile'; import * as smartfile from 'smartfile';
import * as smartstring from 'smartstring'; import * as smartstring from 'smartstring';
export { dnsly, rsaKeygen, rawacme, nodeForge, smartfile, smartstring }; export { dnsly, rsaKeygen, rawacme, nodeForge, smartdelay, smartfile, smartstring };

View File

@ -9,8 +9,10 @@ exports.nodeForge = nodeForge;
// push.rocks modules here // push.rocks modules here
const dnsly = require("dnsly"); const dnsly = require("dnsly");
exports.dnsly = dnsly; exports.dnsly = dnsly;
const smartdelay = require("smartdelay");
exports.smartdelay = smartdelay;
const smartfile = require("smartfile"); const smartfile = require("smartfile");
exports.smartfile = smartfile; exports.smartfile = smartfile;
const smartstring = require("smartstring"); const smartstring = require("smartstring");
exports.smartstring = smartstring; exports.smartstring = smartstring;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR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UNBQXdDO0FBU3BDLGdDQUFVO0FBUmQsdUNBQXNDO0FBU2xDLDhCQUFTO0FBUmIsMkNBQTBDO0FBU3RDLGtDQUFXIn0=

View File

@ -30,14 +30,15 @@
"q": "^1.4.1", "q": "^1.4.1",
"rawacme": "^0.2.1", "rawacme": "^0.2.1",
"rsa-keygen": "^1.0.6", "rsa-keygen": "^1.0.6",
"smartfile": "^4.1.2", "smartdelay": "^1.0.1",
"smartfile": "^4.1.4",
"smartstring": "^2.0.22", "smartstring": "^2.0.22",
"typings-global": "^1.0.14" "typings-global": "^1.0.14"
}, },
"devDependencies": { "devDependencies": {
"@types/should": "^8.1.30", "@types/should": "^8.1.30",
"cflare": "0.0.10", "cflare": "0.0.11",
"qenv": "^1.1.1", "qenv": "^1.1.3",
"should": "^11.1.2", "should": "^11.1.2",
"typings-test": "^1.0.3" "typings-test": "^1.0.3"
} }

3
qenv.yml Normal file
View File

@ -0,0 +1,3 @@
vars:
- CF_EMAIL
- CF_KEY

View File

@ -1,8 +1,16 @@
"use strict"; "use strict";
require("typings-test"); require("typings-test");
const should = require("should"); const should = require("should");
const cflare = require("cflare");
const qenv = require("qenv");
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit');
// import the module to test // import the module to test
const smartacme = require("../dist/index"); 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 () { describe('smartacme', function () {
let testSmartAcme; let testSmartAcme;
let testAcmeAccount; let testAcmeAccount;
@ -43,17 +51,25 @@ describe('smartacme', function () {
done(); done();
}); });
}); });
it('should set the challenge', function (done) {
this.timeout(30000);
myCflareAccount.createRecord(testChallenge.domainNamePrefixed, 'TXT', testChallenge.dnsKeyHash).then(() => {
done();
});
});
it('should check for a DNS record', function (done) { it('should check for a DNS record', function (done) {
this.timeout(40000);
testAcmeCert.checkDns().then(x => { testAcmeCert.checkDns().then(x => {
console.log(x); console.log(x);
done(); done();
}); });
}); });
it.skip('should poll for validation of a challenge', function (done) { it('should poll for validation of a challenge', function (done) {
this.timeout(10000); this.timeout(700000);
testAcmeCert.requestValidation().then(x => { testAcmeCert.requestValidation().then(x => {
console.log(x);
done(); done();
}); });
}); });
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFJaEMsNEJBQTRCO0FBQzVCLDJDQUEwQztBQUUxQyxRQUFRLENBQUMsV0FBVyxFQUFFO0lBQ2xCLElBQUksYUFBa0MsQ0FBQTtJQUN0QyxJQUFJLGVBQXNDLENBQUE7SUFDMUMsSUFBSSxZQUFnQyxDQUFBO0lBQ3BDLElBQUksYUFBb0QsQ0FBQTtJQUV4RCxFQUFFLENBQUMsZ0NBQWdDLEVBQUUsVUFBVSxJQUFJO1FBQy9DLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUE7UUFDbkIsYUFBYSxHQUFHLElBQUksU0FBUyxDQUFDLFNBQVMsRUFBRSxDQUFBO1FBQ3pDLGFBQWEsQ0FBQyxJQUFJLEVBQUUsQ0FBQyxJQUFJLENBQUM7WUFDdEIsTUFBTSxDQUFDLGFBQWEsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxDQUFBO1lBQ3hELElBQUksRUFBRSxDQUFBO1FBQ1YsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLEdBQUcsTUFBTSxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUEsQ0FBQyxDQUFDLENBQUMsQ0FBQTtJQUNsQyxDQUFDLENBQUMsQ0FBQTtJQUVGLEVBQUUsQ0FBQyw2QkFBNkIsRUFBRTt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Q0FBQyxDQUFBIn0=

View File

@ -3,9 +3,17 @@ import * as should from 'should'
import * as cflare from 'cflare' import * as cflare from 'cflare'
import * as qenv from 'qenv' import * as qenv from 'qenv'
let testQenv = new qenv.Qenv(process.cwd(), process.cwd() + '/.nogit')
// import the module to test // import the module to test
import * as smartacme from '../dist/index' import * as smartacme from '../dist/index'
let myCflareAccount = new cflare.CflareAccount()
myCflareAccount.auth({
email: process.env.CF_EMAIL,
key: process.env.CF_KEY
})
describe('smartacme', function () { describe('smartacme', function () {
let testSmartAcme: smartacme.SmartAcme let testSmartAcme: smartacme.SmartAcme
let testAcmeAccount: smartacme.AcmeAccount let testAcmeAccount: smartacme.AcmeAccount
@ -52,16 +60,28 @@ describe('smartacme', function () {
}) })
}) })
it.skip('should check for a DNS record', function(done) { it('should set the challenge', function(done) {
this.timeout(30000)
myCflareAccount.createRecord(
testChallenge.domainNamePrefixed,
'TXT', testChallenge.dnsKeyHash
).then(() => {
done()
})
})
it('should check for a DNS record', function(done) {
this.timeout(40000)
testAcmeCert.checkDns().then(x => { testAcmeCert.checkDns().then(x => {
console.log(x) console.log(x)
done() done()
}) })
}) })
it.skip('should poll for validation of a challenge', function (done) { it('should poll for validation of a challenge', function (done) {
this.timeout(10000) this.timeout(700000)
testAcmeCert.requestValidation().then(x => { testAcmeCert.requestValidation().then(x => {
console.log(x)
done() done()
}) })
}) })

View File

@ -139,43 +139,46 @@ export class AcmeCert {
try { try {
myRecord = await myDnsly.getRecord(helpers.prefixName(this.domainName), 'TXT') myRecord = await myDnsly.getRecord(helpers.prefixName(this.domainName), 'TXT')
console.log('DNS is set!') console.log('DNS is set!')
return myRecord[0][0]
} catch (err) { } catch (err) {
if (cycleArg < 30) { if (cycleArg < 30) {
cycleArg++ cycleArg++
await this.checkDns(cycleArg) await plugins.smartdelay.delayFor(2000)
return await this.checkDns(cycleArg)
} else { } else {
console.log('failed permanently...') console.log('failed permanently...')
throw err throw err
} }
} }
return myRecord[0][0]
} }
/** /**
* validates a challenge, only call after you have set the challenge at the expected location * validates a challenge, only call after you have set the challenge at the expected location
*/ */
requestValidation() { async requestValidation() {
console.log('give it 2 minutes to settle!')
await plugins.smartdelay.delayFor(120000)
let makeRequest = () => {
let done = q.defer() let done = q.defer()
this.parentAcmeAccount.parentSmartAcme.rawacmeClient.poll(this.acceptedChallenge.uri, (err, res) => { this.parentAcmeAccount.parentSmartAcme.rawacmeClient.poll(this.acceptedChallenge.uri, async (err, res) => {
if (err) { if (err) {
console.log(err) console.log(err)
done.reject(err) return
} }
console.log(`Validation response:`) console.log(`Validation response:`)
console.log(JSON.stringify(res.body)) console.log(JSON.stringify(res.body))
if (res.body.status === 'pending' || 'invalid') { if (res.body.status === 'pending' || 'invalid') {
setTimeout( console.log('retry in 4 minutes!')
() => { await plugins.smartdelay.delayFor(240000)
this.requestValidation().then(x => { done.resolve(x) }) makeRequest().then((x: any) => { done.resolve(x) })
},
2000
)
} else { } else {
done.resolve(res.body) done.resolve(res.body)
} }
}) })
return done.promise return done.promise
} }
await makeRequest()
}
/** /**
* requests a certificate * requests a certificate

View File

@ -7,6 +7,7 @@ let nodeForge = require('node-forge')
// push.rocks modules here // push.rocks modules here
import * as dnsly from 'dnsly' import * as dnsly from 'dnsly'
import * as smartdelay from 'smartdelay'
import * as smartfile from 'smartfile' import * as smartfile from 'smartfile'
import * as smartstring from 'smartstring' import * as smartstring from 'smartstring'
@ -15,6 +16,7 @@ export {
rsaKeygen, rsaKeygen,
rawacme, rawacme,
nodeForge, nodeForge,
smartdelay,
smartfile, smartfile,
smartstring smartstring
} }