make Prettier
This commit is contained in:
parent
d2fca0eea7
commit
fa912800b4
97
README.md
97
README.md
|
@ -55,36 +55,37 @@ See `example.js` (it works).
|
||||||
Here's what you could start with.
|
Here's what you could start with.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var tester = require("acme-challenge-test");
|
var tester = require('acme-challenge-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 domain = "example.com";
|
var domain = 'example.com';
|
||||||
|
|
||||||
tester.test("http-01", domain, {
|
tester
|
||||||
|
.test('http-01', domain, {
|
||||||
// Should set a TXT record for opts.dnsHost with opts.dnsAuthorization for opts.ttl || 300
|
// Should set a TXT record for dnsHost with dnsAuthorization and ttl || 300
|
||||||
set: function (opts) {
|
set: function(opts) {
|
||||||
console.log("set opts:", opts);
|
console.log('set opts:', opts);
|
||||||
throw new Error("set not implemented");
|
throw new Error('set not implemented');
|
||||||
},
|
},
|
||||||
|
|
||||||
// Should remove the *one* TXT record for opts.dnsHost with opts.dnsAuthorization
|
// Should remove the *one* TXT record for dnsHost with dnsAuthorization
|
||||||
// Should NOT remove otherrecords for opts.dnsHost (wildcard shares dnsHost with non-wildcard)
|
// Should NOT remove otherrecords for dnsHost (wildcard shares dnsHost with
|
||||||
remove: function (opts) {
|
// non-wildcard)
|
||||||
console.log("remove opts:", opts);
|
remove: function(opts) {
|
||||||
throw new Error("remove not implemented");
|
console.log('remove opts:', opts);
|
||||||
|
throw new Error('remove not implemented');
|
||||||
},
|
},
|
||||||
|
|
||||||
// Should get the record via the DNS server's API
|
// Should get the record via the DNS server's API
|
||||||
get: function (opts) {
|
get: function(opts) {
|
||||||
console.log("get opts:", opts);
|
console.log('get opts:', opts);
|
||||||
throw new Error("get not implemented");
|
throw new Error('get not implemented');
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}).then(function() {
|
.then(function() {
|
||||||
console.info("PASS");
|
console.info('PASS');
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## dns-01 vs http-01
|
## dns-01 vs http-01
|
||||||
|
@ -105,8 +106,10 @@ For `type` dns-01:
|
||||||
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
|
||||||
tester.test('http-01', 'example.com', {
|
tester
|
||||||
set: function (opts) {
|
.test('http-01', 'example.com', {
|
||||||
|
|
||||||
|
set: function(opts) {
|
||||||
var ch = opts.challenge;
|
var ch = opts.challenge;
|
||||||
// { type: 'http-01' // or 'dns-01'
|
// { type: 'http-01' // or 'dns-01'
|
||||||
// , identifier: { type: 'dns', value: 'example.com' }
|
// , identifier: { type: 'dns', value: 'example.com' }
|
||||||
|
@ -116,9 +119,13 @@ tester.test('http-01', 'example.com', {
|
||||||
// , dnsHost: '_acme-challenge.example.com'
|
// , dnsHost: '_acme-challenge.example.com'
|
||||||
// , dnsAuthorization: 'zzzz' }
|
// , dnsAuthorization: 'zzzz' }
|
||||||
|
|
||||||
return API.set(...);
|
return YourApi('POST', 'https://example.com/api/dns/txt', {
|
||||||
}
|
host: ch.dnsHost,
|
||||||
, get: function (query) {
|
record: ch.dnsAuthorization
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
get: function(query) {
|
||||||
var ch = query.challenge;
|
var ch = query.challenge;
|
||||||
// { type: 'http-01' // or 'dns-01', 'tls-alpn-01', etc
|
// { type: 'http-01' // or 'dns-01', 'tls-alpn-01', etc
|
||||||
// , identifier: { type: 'dns', value: 'example.com' }
|
// , identifier: { type: 'dns', value: 'example.com' }
|
||||||
|
@ -131,22 +138,48 @@ tester.test('http-01', 'example.com', {
|
||||||
// , wildcard: false }
|
// , wildcard: false }
|
||||||
// Note: query.identifier.value is different for http-01 than for dns-01
|
// Note: query.identifier.value is different for http-01 than for dns-01
|
||||||
|
|
||||||
return API.get(...).then(function (secret) {
|
return YourApi('GET', 'https://example.com/api/dns/txt', {
|
||||||
|
host: ch.dnsHost
|
||||||
|
}).then(function(secret) {
|
||||||
// http-01
|
// http-01
|
||||||
return { keyAuthorization: secret };
|
return { keyAuthorization: secret };
|
||||||
// dns-01
|
// dns-01
|
||||||
//return { dnsAuthorization: secret };
|
//return { dnsAuthorization: secret };
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
, remove: function (opts) {
|
|
||||||
|
remove: function(opts) {
|
||||||
var ch = opts.challenge;
|
var ch = opts.challenge;
|
||||||
// same options as in `set()` (which are not the same as `get()`
|
// same options as in `set()` (which are not the same as `get()`
|
||||||
|
|
||||||
return API.remove(...);
|
return YourApi('DELETE', 'https://example.com/api/dns/txt/' + ch.dnsHost);
|
||||||
}
|
}
|
||||||
}).then(function () {
|
})
|
||||||
console.info("PASS");
|
.then(function() {
|
||||||
});
|
console.info('PASS');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `YourApi` might look something like this:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var YourApi = function createApi(config) {
|
||||||
|
var request = require('@root/request');
|
||||||
|
request = require('util').promisify(request);
|
||||||
|
|
||||||
|
return function (method, url, body) {
|
||||||
|
return request({
|
||||||
|
method: method,
|
||||||
|
url: url,
|
||||||
|
json: body || true,
|
||||||
|
headers: {
|
||||||
|
Authorization: 'Bearer ' + config.apiToken
|
||||||
|
}
|
||||||
|
}).then(function(resp) {
|
||||||
|
return resp.body;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Two notes:
|
### Two notes:
|
||||||
|
|
Loading…
Reference in New Issue