-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdnsapi.test.mjs
71 lines (66 loc) · 3.67 KB
/
dnsapi.test.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import * as fs from 'fs';
import test from 'node:test';
import assert from 'node:assert/strict';
import {parseDnsApiInfo, parseFile} from "./dnsapi.mjs";
test('parseDnsApiInfo', (t) => {
let infoText = 'dns_openstack\n' +
'OpenStack Designate API\n' +
' Deprecated. Depends on OpenStackClient and python-desginateclient.\n' +
' You will require Keystone V3 credentials loaded into your environment,\n' +
' which could be either password or v3 application credential type.\n' +
'Domains: openstack.com openstack.net\n' +
'Site: docs.openstack.org/api-ref/dns/\n' +
'Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_openstack\n' +
'Options: usual\n' +
' OS_AUTH_URL Auth URL. E.g. "https://keystone.example.com:5000/"\n' +
' OS_USERNAME Username. Default: "root".\n' +
' OS_PASSWORD Password\n' +
' OS_CODE Code. Optional.\n' +
'OptionsAlt: advanced\n' +
' OS_PROJECT_DOMAIN_NAME Project domain name. E.g. "Default".\n' +
' OS_USER_DOMAIN_NAME User domain name. Default: "Default".\n' +
'Issues: https://github.com/acmesh-official/acme.sh/issues/3054\n' +
'Author: Andy Botting <[email protected]>'
let actual = parseDnsApiInfo(infoText)
assert.deepEqual(actual.Name, 'OpenStack Designate API')
assert.deepEqual(actual.Description, 'Depends on OpenStackClient and python-desginateclient.\n' +
'You will require Keystone V3 credentials loaded into your environment,\n' +
'which could be either password or v3 application credential type.')
assert.deepEqual(actual.Deprecated, true)
assert.deepEqual(actual.Domains, 'openstack.com openstack.net')
assert.deepEqual(actual.Site, 'https://docs.openstack.org/api-ref/dns/')
assert.deepEqual(actual.Docs, 'https://github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_openstack')
assert.deepEqual(actual.Issues, 'https://github.com/acmesh-official/acme.sh/issues/3054')
assert.deepEqual(actual.Author, 'Andy Botting <[email protected]>')
assert.deepEqual(actual.OptsTitle, 'usual')
assert.deepEqual(actual.Opts[0].Name, 'OS_AUTH_URL')
assert.deepEqual(actual.Opts[0].Title, 'Auth URL')
assert.deepEqual(actual.Opts[0].Description, 'E.g. "https://keystone.example.com:5000/"')
assert.deepEqual(actual.Opts[0].Default, '')
assert.deepEqual(actual.Opts[0].Optional, false)
assert.deepEqual(actual.Opts[1].Name, 'OS_USERNAME')
assert.deepEqual(actual.Opts[1].Title, 'Username')
assert.deepEqual(actual.Opts[1].Description, '')
assert.deepEqual(actual.Opts[1].Default, 'root')
assert.deepEqual(actual.Opts[1].Optional, true)
assert.deepEqual(actual.Opts[2].Name, 'OS_PASSWORD')
assert.deepEqual(actual.Opts[2].Title, 'Password')
assert.deepEqual(actual.Opts[2].Description, '')
assert.deepEqual(actual.Opts[2].Default, '')
assert.deepEqual(actual.Opts[2].Optional, false)
assert.deepEqual(actual.Opts[3].Name, 'OS_CODE')
assert.deepEqual(actual.Opts[3].Title, 'Code')
assert.deepEqual(actual.Opts[3].Description, '')
assert.deepEqual(actual.Opts[3].Default, '')
assert.deepEqual(actual.Opts[3].Optional, true)
assert.deepEqual(actual.OptsAltTitle, 'advanced')
assert.deepEqual(actual.OptsAlt[0].Name, 'OS_PROJECT_DOMAIN_NAME')
assert.deepEqual(actual.OptsAlt[0].Title, 'Project domain name')
assert.deepEqual(actual.OptsAlt[0].Description, 'E.g. "Default".')
})
test('parseDnsApiInfoFile', (t) => {
let contents = fs.readFileSync(process.cwd() + "/dnsapi.info.txt").toString()
let infos = parseFile(contents)
assert.deepEqual(infos.length, 151)
assert.deepEqual(infos[0].Name, '1984.hosting')
})