v3.1.2: keep same random prefix per test set

This commit is contained in:
AJ ONeal 2019-06-07 00:48:10 -06:00
parent ea508c68f4
commit dda7ecb497
3 changed files with 13 additions and 8 deletions

View File

@ -3,10 +3,10 @@
//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({});
//var type = 'YOUR-TYPE-01'; //var type = 'YOUR-TYPE-01';

View File

@ -76,10 +76,11 @@ function testEach(type, domains, challenger) {
var all = domains.map(function(d) { var all = domains.map(function(d) {
return { domain: d }; return { domain: d };
}); });
var rnd = crypto.randomBytes(2).toString('hex');
return mapAsync(all, function(opts) { return mapAsync(all, function(opts) {
console.info("TEST '%s'", opts.domain); console.info("TEST '%s'", opts.domain);
opts.challenge = getChallenge(type, opts.domain); opts.challenge = fakeChallenge(type, opts.domain, rnd);
var ch = opts.challenge; var ch = opts.challenge;
if ('http-01' === ch.type && ch.wildname) { if ('http-01' === ch.type && ch.wildname) {
throw new Error('http-01 cannot be used for wildcard domains'); throw new Error('http-01 cannot be used for wildcard domains');
@ -234,7 +235,7 @@ function wrapChallenger(challenger) {
return { set: set, get: get, remove: remove }; return { set: set, get: get, remove: remove };
} }
function getChallenge(type, altname) { function fakeChallenge(type, altname, rnd) {
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');
@ -257,7 +258,7 @@ function getChallenge(type, altname) {
thumbprint: thumb, thumbprint: thumb,
keyAuthorization: keyAuth, keyAuthorization: keyAuth,
url: null, // completed below url: null, // completed below
dnsHost: '_acme-challenge-' + token.slice(0, 4) + '.', // completed below dnsHost: '_' + rnd.slice(0, 2) + '-acme-challenge-' + rnd.slice(2) + '.', // completed below
dnsAuthorization: dnsAuth, dnsAuthorization: dnsAuth,
altname: altname, altname: altname,
_test: true // used by CLI referenced implementations _test: true // used by CLI referenced implementations

View File

@ -1,9 +1,13 @@
{ {
"name": "acme-challenge-test", "name": "acme-challenge-test",
"version": "3.1.1", "version": "3.1.2",
"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",
"files": [
"example.js",
"lib"
],
"dependencies": {}, "dependencies": {},
"devDependencies": {}, "devDependencies": {},
"scripts": { "scripts": {