2020-12-13 15:06:17 +00:00
|
|
|
import pkg from 'chai'
|
2021-02-08 05:40:28 +00:00
|
|
|
import { AliyunDnsProvider } from '../../src/dns-providers/aliyun.js'
|
2021-02-07 16:21:36 +00:00
|
|
|
import { createOptions } from '../../../../../test/options.js'
|
2020-12-13 15:06:17 +00:00
|
|
|
const { expect } = pkg
|
2021-02-08 05:40:28 +00:00
|
|
|
|
|
|
|
export function getPluginOptions () {
|
|
|
|
const options = createOptions()
|
|
|
|
return { accessProviders: options.accessProviders, props: options.cert.dnsProvider }
|
|
|
|
}
|
|
|
|
|
2020-12-13 15:06:17 +00:00
|
|
|
describe('AliyunDnsProvider', function () {
|
|
|
|
it('#getDomainList', async function () {
|
2021-02-08 05:40:28 +00:00
|
|
|
const options = getPluginOptions()
|
|
|
|
const aliyunDnsProvider = new AliyunDnsProvider(options)
|
2020-12-13 15:06:17 +00:00
|
|
|
const domainList = await aliyunDnsProvider.getDomainList()
|
|
|
|
console.log('domainList', domainList)
|
|
|
|
expect(domainList.length).gt(0)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('#getRecords', async function () {
|
2021-02-08 05:40:28 +00:00
|
|
|
const options = getPluginOptions()
|
|
|
|
const aliyunDnsProvider = new AliyunDnsProvider(options)
|
2020-12-13 15:06:17 +00:00
|
|
|
const recordList = await aliyunDnsProvider.getRecords('docmirror.cn', '*')
|
|
|
|
console.log('recordList', recordList)
|
|
|
|
expect(recordList.length).gt(0)
|
|
|
|
})
|
|
|
|
|
2020-12-23 16:49:31 +00:00
|
|
|
it('#createAndRemoveRecord', async function () {
|
2021-02-08 05:40:28 +00:00
|
|
|
const options = getPluginOptions()
|
|
|
|
const aliyunDnsProvider = new AliyunDnsProvider(options)
|
2020-12-23 16:49:31 +00:00
|
|
|
const record = await aliyunDnsProvider.createRecord({ fullRecord: '___certd___.__test__.docmirror.cn', type: 'TXT', value: 'aaaa' })
|
|
|
|
console.log('recordId', record)
|
|
|
|
expect(record != null).ok
|
|
|
|
|
|
|
|
const recordId = await aliyunDnsProvider.removeRecord({ fullRecord: '___certd___.__test__.docmirror.cn', type: 'TXT', value: 'aaaa', record })
|
2020-12-13 15:06:17 +00:00
|
|
|
console.log('recordId', recordId)
|
|
|
|
expect(recordId != null).ok
|
|
|
|
})
|
|
|
|
})
|