yay for promise-only tests working
This commit is contained in:
parent
ef0505ed69
commit
f486bca73e
|
@ -23,10 +23,11 @@ In progress
|
||||||
* Mar 20, 2018 - SUCCESS - got a test certificate (hard-coded)
|
* Mar 20, 2018 - SUCCESS - got a test certificate (hard-coded)
|
||||||
* Mar 21, 2018 - can now accept values (not hard coded)
|
* Mar 21, 2018 - can now accept values (not hard coded)
|
||||||
* Mar 21, 2018 - *mostly* matches le-acme-core.js API
|
* Mar 21, 2018 - *mostly* matches le-acme-core.js API
|
||||||
|
* Apr 5, 2018 - completely match api for acme v1 (le-acme-core.js)
|
||||||
|
|
||||||
Todo
|
Todo
|
||||||
|
|
||||||
* completely match api for acme v1 (le-acme-core.js)
|
* test wildcard
|
||||||
* test http and dns challenges
|
* test http and dns challenges
|
||||||
* export http and dns challenge tests
|
* export http and dns challenge tests
|
||||||
* support ECDSA keys
|
* support ECDSA keys
|
||||||
|
|
|
@ -35,7 +35,7 @@ module.exports.run = function run(web, chType, email, accountKeypair, domainKeyp
|
||||||
console.log("Put the string '" + opts.keyAuthorization + "' into a file at '" + pathname + "'");
|
console.log("Put the string '" + opts.keyAuthorization + "' into a file at '" + pathname + "'");
|
||||||
console.log("echo '" + opts.keyAuthorization + "' > '" + pathname + "'");
|
console.log("echo '" + opts.keyAuthorization + "' > '" + pathname + "'");
|
||||||
} else if ('dns-01' === opts.type) {
|
} else if ('dns-01' === opts.type) {
|
||||||
pathname = acme2.acmeChallengeDnsPrefix + "." + opts.hostname;
|
pathname = acme2.acmeChallengeDnsPrefix + "." + opts.hostname.replace(/^\*\./, '');
|
||||||
console.log("Put the string '" + opts.dnsAuthorization + "' into the TXT record '" + pathname + "'");
|
console.log("Put the string '" + opts.dnsAuthorization + "' into the TXT record '" + pathname + "'");
|
||||||
console.log("ddig TXT " + pathname + " '" + opts.dnsAuthorization + "'");
|
console.log("ddig TXT " + pathname + " '" + opts.dnsAuthorization + "'");
|
||||||
} else {
|
} else {
|
||||||
|
|
4
test.js
4
test.js
|
@ -39,8 +39,8 @@ function getEmail(web, chType) {
|
||||||
var accountKeypair = RSA.import({ privateKeyPem: require('fs').readFileSync(__dirname + '/account.privkey.pem') });
|
var accountKeypair = RSA.import({ privateKeyPem: require('fs').readFileSync(__dirname + '/account.privkey.pem') });
|
||||||
var domainKeypair = RSA.import({ privateKeyPem: require('fs').readFileSync(__dirname + '/privkey.pem') });
|
var domainKeypair = RSA.import({ privateKeyPem: require('fs').readFileSync(__dirname + '/privkey.pem') });
|
||||||
//require('./test.compat.js').run(web, chType, email, accountKeypair, domainKeypair);
|
//require('./test.compat.js').run(web, chType, email, accountKeypair, domainKeypair);
|
||||||
require('./test.cb.js').run(web, chType, email, accountKeypair, domainKeypair);
|
//require('./test.cb.js').run(web, chType, email, accountKeypair, domainKeypair);
|
||||||
//require('./test.promise.js').run(web, chType, email, accountKeypair, domainKeypair);
|
require('./test.promise.js').run(web, chType, email, accountKeypair, domainKeypair);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
103
test.promise.js
103
test.promise.js
|
@ -1,82 +1,85 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/* global Promise */
|
/* global Promise */
|
||||||
|
module.exports.run = function run(web, chType, email, accountKeypair, domainKeypair) {
|
||||||
module.exports.run = function run(web, chType, email) {
|
|
||||||
var RSA = require('rsa-compat').RSA;
|
var RSA = require('rsa-compat').RSA;
|
||||||
var directoryUrl = 'https://acme-staging-v02.api.letsencrypt.org/directory';
|
var directoryUrl = 'https://acme-staging-v02.api.letsencrypt.org/directory';
|
||||||
var acme2 = require('./compat').ACME.create({ RSA: RSA });
|
var acme2 = require('./').ACME.create({ RSA: RSA });
|
||||||
// [ 'test.ppl.family' ] 'coolaj86@gmail.com''http-01'
|
// [ 'test.ppl.family' ] 'coolaj86@gmail.com''http-01'
|
||||||
console.log(web, chType, email);
|
acme2.init(directoryUrl).then(function () {
|
||||||
return;
|
|
||||||
acme2.init(directoryUrl).then(function (body) {
|
|
||||||
console.log(body);
|
|
||||||
return;
|
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
agreeToTerms: function (tosUrl, agree) {
|
agreeToTerms: function (tosUrl) {
|
||||||
agree(null, tosUrl);
|
return Promise.resolve(tosUrl);
|
||||||
}
|
}
|
||||||
, setChallenge: function (opts) {
|
, setChallenge: function (opts) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
var pathname;
|
||||||
|
|
||||||
console.log("");
|
console.log("");
|
||||||
console.log('identifier:');
|
console.log('identifier:');
|
||||||
console.log(opts.identifier);
|
console.log(opts.identifier);
|
||||||
console.log('hostname:');
|
console.log('hostname:');
|
||||||
console.log(opts.hostname);
|
console.log(opts.hostname);
|
||||||
console.log('type:');
|
console.log('type:');
|
||||||
console.log(opts.type);
|
console.log(opts.type);
|
||||||
console.log('token:');
|
console.log('token:');
|
||||||
console.log(opts.token);
|
console.log(opts.token);
|
||||||
console.log('thumbprint:');
|
console.log('thumbprint:');
|
||||||
console.log(opts.thumbprint);
|
console.log(opts.thumbprint);
|
||||||
console.log('keyAuthorization:');
|
console.log('keyAuthorization:');
|
||||||
console.log(opts.keyAuthorization);
|
console.log(opts.keyAuthorization);
|
||||||
console.log('dnsAuthorization:');
|
console.log('dnsAuthorization:');
|
||||||
console.log(opts.dnsAuthorization);
|
console.log(opts.dnsAuthorization);
|
||||||
console.log("");
|
console.log("");
|
||||||
|
|
||||||
console.log("Put the string '" + opts.keyAuthorization + "' into a file at '" + opts.hostname + "/" + opts.token + "'");
|
if ('http-01' === opts.type) {
|
||||||
console.log("\nThen hit the 'any' key to continue (must be specifically the 'any' key)...");
|
pathname = opts.hostname + acme2.acmeChallengePrefix + "/" + opts.token;
|
||||||
|
console.log("Put the string '" + opts.keyAuthorization + "' into a file at '" + pathname + "'");
|
||||||
return new Promise(function (resolve) {
|
console.log("echo '" + opts.keyAuthorization + "' > '" + pathname + "'");
|
||||||
function onAny() {
|
} else if ('dns-01' === opts.type) {
|
||||||
process.stdin.pause();
|
pathname = acme2.acmeChallengeDnsPrefix + "." + opts.hostname.replace(/^\*\./, '');;
|
||||||
process.stdin.removeEventListener('data', onAny);
|
console.log("Put the string '" + opts.dnsAuthorization + "' into the TXT record '" + pathname + "'");
|
||||||
process.stdin.setRawMode(false);
|
console.log("ddig TXT " + pathname + " '" + opts.dnsAuthorization + "'");
|
||||||
|
} else {
|
||||||
resolve();
|
reject(new Error("[acme-v2] unrecognized challenge type"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
console.log("\nThen hit the 'any' key to continue...");
|
||||||
|
|
||||||
|
function onAny() {
|
||||||
|
console.log("'any' key was hit");
|
||||||
|
process.stdin.pause();
|
||||||
|
process.stdin.removeListener('data', onAny);
|
||||||
|
process.stdin.setRawMode(false);
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
process.stdin.setRawMode(true);
|
process.stdin.setRawMode(true);
|
||||||
process.stdin.resume();
|
process.stdin.resume();
|
||||||
process.stdin.on('data', onAny);
|
process.stdin.on('data', onAny);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
, removeChallenge: function (opts) {
|
, removeChallenge: function (opts) {
|
||||||
// hostname, key
|
console.log('[acme-v2] remove challenge', opts.hostname, opts.keyAuthorization);
|
||||||
console.log('[DEBUG] remove challenge', opts.hostname, opts.keyAuthorization);
|
|
||||||
console.log("Remove the file '" + opts.hostname + "/" + opts.token + "'");
|
|
||||||
|
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
|
// hostname, key
|
||||||
setTimeout(resolve, 1 * 1000);
|
setTimeout(resolve, 1 * 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
, challengeType: chType
|
, challengeType: chType
|
||||||
, email: email
|
, email: email
|
||||||
, accountKeypair: RSA.import({ privateKeyPem: require('fs').readFileSync(__dirname + '/account.privkey.pem') })
|
, accountKeypair: accountKeypair
|
||||||
, domainKeypair: RSA.import({ privateKeyPem: require('fs').readFileSync(__dirname + '/privkey.pem') })
|
, domainKeypair: domainKeypair
|
||||||
, domains: web
|
, domains: web
|
||||||
};
|
};
|
||||||
|
|
||||||
acme2.registerNewAccount(options).then(function (account) {
|
acme2.accounts.create(options).then(function (account) {
|
||||||
console.log('account:');
|
console.log('[acme-v2] account:');
|
||||||
console.log(account);
|
console.log(account);
|
||||||
|
|
||||||
acme2.getCertificate(options, function (fullchainPem) {
|
acme2.certificates.create(options).then(function (fullchainPem) {
|
||||||
console.log('[acme-v2] A fullchain.pem:');
|
console.log('[acme-v2] fullchain.pem:');
|
||||||
console.log(fullchainPem);
|
|
||||||
}).then(function (fullchainPem) {
|
|
||||||
console.log('[acme-v2] B fullchain.pem:');
|
|
||||||
console.log(fullchainPem);
|
console.log(fullchainPem);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue