v3.3.0: update docs and test dep

This commit is contained in:
AJ ONeal 2019-06-15 13:25:11 -06:00
parent 617720d380
commit cba3c635b7
2 changed files with 50 additions and 16 deletions

View File

@ -4,12 +4,13 @@ An ACME dns-01 test harness for Let's Encrypt integrations.
This was specificially designed for [ACME.js](https://git.coolaj86.com/coolaj86/acme-v2.js) and [Greenlock.js](https://git.coolaj86.com/coolaj86/greenlock-express.js), but will be generically useful to any ACME module. This was specificially designed for [ACME.js](https://git.coolaj86.com/coolaj86/acme-v2.js) and [Greenlock.js](https://git.coolaj86.com/coolaj86/greenlock-express.js), but will be generically useful to any ACME module.
Passing the tests is very easy. There are just four functions to implement: Passing the tests is very easy. There are just five functions to implement:
- `zones()` - list domain zones (i.e. example.co.uk, example.com) - `init(deps)` - (optional) this gives you the `request` object you should use for HTTP APIs
- `set()` - set a TXT record in a zone (i.e. `_acme-challenge.foo` in `example.com`) - `zones(opts)` - list domain zones (i.e. example.co.uk, example.com)
- `get()` - confirm that the record was set - `set(opts)` - set a TXT record in a zone (i.e. `_acme-challenge.foo` in `example.co.jp`)
- `remove()` - clean up after the ACME challenge passes - `get(opts)` - confirm that the record was set
- `remove(opts)` - clean up after the ACME challenge completes
The tests account for single-domain certificates (`example.com`) as well as multiple domain certs (SAN / AltName), The tests account for single-domain certificates (`example.com`) as well as multiple domain certs (SAN / AltName),
wildcards (`*.example.com`), and valid private / localhost certificates. No worries on your end, just pass the tests. 👌 wildcards (`*.example.com`), and valid private / localhost certificates. No worries on your end, just pass the tests. 👌
@ -55,15 +56,25 @@ tester.testRecord('dns-01', record, challenger).then(function() {
## Reference Implementations ## Reference Implementations
These are plugins that use the v2.7+ (v3) API, and pass this test harness, - Compatibility
which you should use as a model for any plugins that you create. - [x] Let's Encrypt v2.1 / ACME draft 18
- [x] Node v6+
- [x] Chrome, Firefox, Safari, Edge, etc
- Quality
- [x] Written in VanillaJS
- [x] No compliers or build scripts
- [x] Simple, minimal code, in a single file
- [x] **Zero dependencies**
These libraries are useful as a model for any plugins that you create.
- dns-01 - dns-01
- [`acme-dns-01-cli`](https://git.rootprojects.org/root/acme-dns-01-cli.js) - [`cli`](https://git.rootprojects.org/root/acme-dns-01-cli.js)
- [`acme-dns-01-digitalocean`](https://git.rootprojects.org/root/acme-dns-01-digitalocean.js) - [`digitalocean`](https://git.rootprojects.org/root/acme-dns-01-digitalocean.js)
- [`vultr`](https://git.rootprojects.org/root/acme-dns-01-vultr.js)
- http-01 - http-01
- [`acme-http-01-cli`](https://git.rootprojects.org/root/acme-http-01-cli.js) - [`cli`](https://git.rootprojects.org/root/acme-http-01-cli.js)
- [`acme-http-01-fs`](https://git.rootprojects.org/root/acme-http-01-fs.js) - [`fs`](https://git.rootprojects.org/root/acme-http-01-fs.js)
You can find other implementations by searching npm for [acme-http-01-](https://www.npmjs.com/search?q=acme-http-01-) You can find other implementations by searching npm for [acme-http-01-](https://www.npmjs.com/search?q=acme-http-01-)
and [acme-dns-01-](https://www.npmjs.com/search?q=acme-dns-01-). and [acme-dns-01-](https://www.npmjs.com/search?q=acme-dns-01-).
@ -71,6 +82,10 @@ and [acme-dns-01-](https://www.npmjs.com/search?q=acme-dns-01-).
If you are building a plugin, please let us know. If you are building a plugin, please let us know.
We may like to co-author and help maintain and promote your module. We may like to co-author and help maintain and promote your module.
<small>Note: In some cases (such as non-HTTP, or very complex APIs) you will not be able to maintain
browser compatibility. Other than than, if you keep your code simple, it will also work in browser
implementations of ACME.js.</small>
## Example ## Example
See `example.js` (it works). See `example.js` (it works).
@ -85,9 +100,16 @@ var tester = require('acme-dns-01-test');
// 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 zone = 'example.com'; var zone = 'example.com';
var request;
tester tester
.testZone('dns-01', zone, { .testZone('dns-01', zone, {
// Gives you the promisified `request` object for HTTP APIs
init: function(deps) {
request = deps.request;
return null;
},
// Should return an array of zone domain name strings // Should return an array of zone domain name strings
// (APIs that don't implement zones, such as DuckDNS, should return an empty array) // (APIs that don't implement zones, such as DuckDNS, should return an empty array)
zones: function(opts) { zones: function(opts) {
@ -143,8 +165,18 @@ See [acme-http-01-test.js](https://git.rootprojects.org/root/acme-dns-01-test.js
Here's a quick pseudo stub-out of what a test-passing plugin object might look like: Here's a quick pseudo stub-out of what a test-passing plugin object might look like:
```js ```js
var request;
tester tester
.testZone('dns-01', 'example.com', { .testZone('dns-01', 'example.com', {
init: function(deps) {
// { request: { get, post, put, delete }
// }
request = deps.request;
return null;
},
zones: function(opts) { zones: function(opts) {
// { dnsHosts: [ // { dnsHosts: [
// '_acme-challenge.foo.example.com', // '_acme-challenge.foo.example.com',
@ -217,9 +249,6 @@ Where `YourApi` might look something like this:
```js ```js
var YourApi = function createApi(config) { var YourApi = function createApi(config) {
var request = require('@root/request');
request = require('util').promisify(request);
return function(method, url, body) { return function(method, url, body) {
return request({ return request({
method: method, method: method,
@ -235,6 +264,11 @@ var YourApi = function createApi(config) {
}; };
``` ```
Note: `request` is actually `@root/request`, but the API is the same as the standard `request`.
Avoid using 3rd party API libraries where you can - they tend to bloat your dependencies and
add security risk. Instead, just use the API documentation and cURL examples.
### Two notes: ### Two notes:
Note 1: Note 1:

View File

@ -1,6 +1,6 @@
{ {
"name": "acme-dns-01-test", "name": "acme-dns-01-test",
"version": "3.2.1", "version": "3.3.0",
"description": "ACME dns-01 tests for Let's Encrypt integration. Any `acme-dns-01-` plugin should be able to pass these tests.", "description": "ACME dns-01 tests for Let's Encrypt integration. Any `acme-dns-01-` plugin should be able to pass these tests.",
"main": "index.js", "main": "index.js",
"homepage": "https://git.rootprojects.org/root/acme-dns-01-test.js", "homepage": "https://git.rootprojects.org/root/acme-dns-01-test.js",
@ -9,7 +9,7 @@
"lib" "lib"
], ],
"dependencies": { "dependencies": {
"acme-challenge-test": "^3.2.0" "acme-challenge-test": "^3.3.1"
}, },
"devDependencies": { "devDependencies": {
"acme-dns-01-cli": "^3.1.0" "acme-dns-01-cli": "^3.1.0"