From dda7ecb497cb726d276864cb204439707087f512 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 7 Jun 2019 00:48:10 -0600 Subject: [PATCH] v3.1.2: keep same random prefix per test set --- example.js | 8 ++++---- index.js | 7 ++++--- package.json | 6 +++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/example.js b/example.js index 912400f..7106618 100644 --- a/example.js +++ b/example.js @@ -3,10 +3,10 @@ //var tester = require('acme-challenge-test'); var tester = require('./'); -var type = 'http-01'; -var challenger = require('acme-http-01-cli').create({}); -//var type = 'dns-01'; -//var challenger = require('acme-dns-01-cli').create({}); +//var type = 'http-01'; +//var challenger = require('acme-http-01-cli').create({}); +var type = 'dns-01'; +var challenger = require('acme-dns-01-cli').create({}); //var challenger = require('./YOUR-CHALLENGE-STRATEGY').create({}); //var type = 'YOUR-TYPE-01'; diff --git a/index.js b/index.js index 5746654..291f7f7 100644 --- a/index.js +++ b/index.js @@ -76,10 +76,11 @@ function testEach(type, domains, challenger) { var all = domains.map(function(d) { return { domain: d }; }); + var rnd = crypto.randomBytes(2).toString('hex'); return mapAsync(all, function(opts) { console.info("TEST '%s'", opts.domain); - opts.challenge = getChallenge(type, opts.domain); + opts.challenge = fakeChallenge(type, opts.domain, rnd); var ch = opts.challenge; if ('http-01' === ch.type && ch.wildname) { 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 }; } -function getChallenge(type, altname) { +function fakeChallenge(type, altname, rnd) { var expires = new Date(Date.now() + 10 * 60 * 1000).toISOString(); var token = crypto.randomBytes(8).toString('hex'); var thumb = crypto.randomBytes(16).toString('hex'); @@ -257,7 +258,7 @@ function getChallenge(type, altname) { thumbprint: thumb, keyAuthorization: keyAuth, 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, altname: altname, _test: true // used by CLI referenced implementations diff --git a/package.json b/package.json index ebfd382..fa0274e 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,13 @@ { "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.", "main": "index.js", "homepage": "https://git.rootprojects.org/root/acme-challenge-test.js", + "files": [ + "example.js", + "lib" + ], "dependencies": {}, "devDependencies": {}, "scripts": {