le-manage-test.js/README.md

57 lines
1.4 KiB
Markdown
Raw Normal View History

# [le-manage-test](https://git.coolaj86.com/coolaj86/le-manage-test.js.git)
| A [Root](https://rootprojects.org) Project |
The test harness you should use when writing a management strategy
for [Greenlock](https://git.coolaj86.com/coolaj86/greenlock-express.js) v2.7+ (and v3).
All implementations that support multiple domains MUST pass these tests
(which is not a hard thing to do).
## Install
```bash
npm install --save-dev le-manage-test@3.x
```
## Usage
```bash
var tester = require('le-manage-test');
// The function that checks the database for the domain (or its wildcard) and returns the results
function approveDomains(opts) {
var domain = opts.domain;
// try exact match (ex: www.example.com)
var info = DB.find(domain);
// try wildcard match (ex: *.example.com)
if (!info) { info = DB.find(wild) }
// If there's no info, it didn't exist, return null (not undefined)
if (!info) { return null; }
//return { subject: 'example.com', altnames: [ 'example.com', 'www.example.com' ] };
return { subject: info.subject, altnames: info.altnames };
}
function updateDomains(opts) {
// return null (not undefined)
return DB.associate(opts.subject, opts.altnames);
}
tester.test({
set: updateDomains
, get: approveDomains
}).then(function () {
console.info("PASS");
});
```
## Example
See `example.js`.
Will post reference implementations here later...