Update record test, use random prefix
* Test multiple zone records (@, foo, *.foo) * Use random _acme-challenge-xxxx
This commit is contained in:
parent
e179188bc0
commit
f2373a09de
17
example.js
17
example.js
|
@ -1,10 +1,10 @@
|
||||||
"use strict";
|
'use strict';
|
||||||
|
|
||||||
//var tester = require('acme-challenge-test');
|
//var tester = require('acme-challenge-test');
|
||||||
var tester = require("./");
|
var tester = require('./');
|
||||||
|
|
||||||
var type = "http-01";
|
var type = 'http-01';
|
||||||
var challenger = require("acme-http-01-cli").create({});
|
var challenger = require('acme-http-01-cli').create({});
|
||||||
//var type = 'dns-01';
|
//var type = 'dns-01';
|
||||||
//var challenger = require('acme-dns-01-cli').create({});
|
//var challenger = require('acme-dns-01-cli').create({});
|
||||||
//var challenger = require('./YOUR-CHALLENGE-STRATEGY').create({});
|
//var challenger = require('./YOUR-CHALLENGE-STRATEGY').create({});
|
||||||
|
@ -12,16 +12,15 @@ var challenger = require("acme-http-01-cli").create({});
|
||||||
|
|
||||||
// The dry-run tests can pass on, literally, 'example.com'
|
// The dry-run tests can pass on, literally, 'example.com'
|
||||||
// but the integration tests require that you have control over the domain
|
// but the integration tests require that you have control over the domain
|
||||||
var domain = "example.com";
|
var zone = 'example.com';
|
||||||
//var domain = '*.example.com';
|
|
||||||
|
|
||||||
tester
|
tester
|
||||||
.test(type, domain, challenger)
|
.test(type, zone, challenger)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
console.info("PASS");
|
console.info('ALL PASSED');
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
console.error("FAIL");
|
console.error('FAIL');
|
||||||
console.error(err);
|
console.error(err);
|
||||||
process.exit(20);
|
process.exit(20);
|
||||||
});
|
});
|
||||||
|
|
37
index.js
37
index.js
|
@ -75,8 +75,7 @@ function run(challenger, opts) {
|
||||||
|
|
||||||
// The first time we just check it against itself
|
// The first time we just check it against itself
|
||||||
// this will cause the prompt to appear
|
// this will cause the prompt to appear
|
||||||
return set(opts)
|
return set(opts).then(function() {
|
||||||
.then(function() {
|
|
||||||
// this will cause the final completion message to appear
|
// this will cause the final completion message to appear
|
||||||
// _test is used by the manual cli reference implementations
|
// _test is used by the manual cli reference implementations
|
||||||
var query = { type: ch.type, /*debug*/ status: ch.status, _test: true };
|
var query = { type: ch.type, /*debug*/ status: ch.status, _test: true };
|
||||||
|
@ -177,8 +176,28 @@ function run(challenger, opts) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
.then(function() {
|
}
|
||||||
|
|
||||||
|
module.exports.test = function(type, zone, challenger) {
|
||||||
|
var domains = [zone, 'foo.' + zone];
|
||||||
|
if ('dns-01' === type) {
|
||||||
|
domains.push('*.foo.' + zone);
|
||||||
|
}
|
||||||
|
|
||||||
|
function next() {
|
||||||
|
var domain = domains.shift();
|
||||||
|
if (!domain) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.info("TEST '%s'", domain);
|
||||||
|
return testOne(type, domain, challenger).then(function() {
|
||||||
|
console.info("PASS '%s'", domain);
|
||||||
|
return next();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return next().then(function() {
|
||||||
console.info('All soft tests: PASS');
|
console.info('All soft tests: PASS');
|
||||||
console.warn(
|
console.warn(
|
||||||
'Hard tests (actually checking http URLs and dns records) is implemented in acme-v2.'
|
'Hard tests (actually checking http URLs and dns records) is implemented in acme-v2.'
|
||||||
|
@ -187,9 +206,9 @@ function run(challenger, opts) {
|
||||||
"We'll copy them over here as well, but that's a TODO for next week."
|
"We'll copy them over here as well, but that's a TODO for next week."
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.test = function(type, altname, challenger) {
|
function testOne(type, altname, challenger) {
|
||||||
var expires = new Date(Date.now() + 10 * 60 * 1000).toISOString();
|
var expires = new Date(Date.now() + 10 * 60 * 1000).toISOString();
|
||||||
var token = crypto.randomBytes(8).toString('hex');
|
var token = crypto.randomBytes(8).toString('hex');
|
||||||
var thumb = crypto.randomBytes(16).toString('hex');
|
var thumb = crypto.randomBytes(16).toString('hex');
|
||||||
|
@ -212,7 +231,7 @@ module.exports.test = function(type, altname, challenger) {
|
||||||
thumbprint: thumb,
|
thumbprint: thumb,
|
||||||
keyAuthorization: keyAuth,
|
keyAuthorization: keyAuth,
|
||||||
url: null, // completed below
|
url: null, // completed below
|
||||||
dnsHost: '_acme-challenge.', // completed below
|
dnsHost: '_acme-challenge-' + token.slice(0, 4) + '.', // completed below
|
||||||
dnsAuthorization: dnsAuth,
|
dnsAuthorization: dnsAuth,
|
||||||
altname: altname,
|
altname: altname,
|
||||||
_test: true // used by CLI referenced implementations
|
_test: true // used by CLI referenced implementations
|
||||||
|
@ -227,4 +246,6 @@ module.exports.test = function(type, altname, challenger) {
|
||||||
challenge.dnsHost += altname;
|
challenge.dnsHost += altname;
|
||||||
|
|
||||||
return run(challenger, { challenge: challenge });
|
return run(challenger, { challenge: challenge });
|
||||||
};
|
}
|
||||||
|
|
||||||
|
module.exports._test = testOne;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"name": "acme-challenge-test",
|
||||||
|
"version": "3.0.4",
|
||||||
|
"lockfileVersion": 1
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "acme-challenge-test",
|
"name": "acme-challenge-test",
|
||||||
"version": "3.0.4",
|
"version": "3.0.5",
|
||||||
"description": "The base set of tests for all ACME challenge strategies. Any `acme-http-01-`, `acme-dns-01-`, `acme-challenge-`, or greenlock plugin should be able to pass these tests.",
|
"description": "The base set of tests for all ACME challenge strategies. Any `acme-http-01-`, `acme-dns-01-`, `acme-challenge-`, or greenlock plugin should be able to pass these tests.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"homepage": "https://git.rootprojects.org/root/acme-challenge-test.js",
|
"homepage": "https://git.rootprojects.org/root/acme-challenge-test.js",
|
||||||
|
|
Loading…
Reference in New Issue