mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
refactor: 重构
This commit is contained in:
1052
packages/plugins/plugin-aliyun/package-lock.json
generated
1052
packages/plugins/plugin-aliyun/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,8 @@
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"mocha": "^8.2.1"
|
||||
"mocha": "^8.2.1",
|
||||
"@certd/certd": "^0.1.13"
|
||||
},
|
||||
"author": "Greper",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,33 +1,16 @@
|
||||
|
||||
import _ from 'lodash-es'
|
||||
|
||||
import { AliyunDnsProvider, AliyunAccessProvider } from './access-providers/aliyun'
|
||||
import { AliyunDnsProvider } from './dns-providers/aliyun.js'
|
||||
import { AliyunAccessProvider } from './access-providers/aliyun.js'
|
||||
import { UploadCertToAliyun } from './plugins/upload-to-aliyun/index.js'
|
||||
import { DeployCertToAliyunCDN } from './plugins/deploy-to-cdn/index.js'
|
||||
|
||||
import { UploadCertToAliyun } from './plugins/upload-to-aliyun'
|
||||
import { DeployCertToAliyunCDN } from './plugins/deploy-to-cdn'
|
||||
|
||||
import { UploadCertToTencent } from './tencent/upload-to-tencent/index.js'
|
||||
|
||||
import { DeployCertToTencentCDN } from './tencent/deploy-to-cdn/index.js'
|
||||
|
||||
import { DeployCertToTencentCLB } from './tencent/deploy-to-clb/index.js'
|
||||
|
||||
import { DeployCertToTencentTKEIngress } from './tencent/deploy-to-tke-ingress/index.js'
|
||||
|
||||
import { UploadCertToHost } from './host/upload-to-host/index.js'
|
||||
import { HostShellExecute } from './host/host-shell-execute/index.js'
|
||||
|
||||
import { pluginRegistry, accessProviderRegister, dnsProviderRegistry } from '@certd/api'
|
||||
import { pluginRegistry, accessProviderRegistry, dnsProviderRegistry } from '@certd/api'
|
||||
|
||||
export const Plugins = {
|
||||
UploadCertToAliyun,
|
||||
DeployCertToAliyunCDN,
|
||||
UploadCertToTencent,
|
||||
DeployCertToTencentTKEIngress,
|
||||
DeployCertToTencentCDN,
|
||||
DeployCertToTencentCLB,
|
||||
UploadCertToHost,
|
||||
HostShellExecute
|
||||
DeployCertToAliyunCDN
|
||||
}
|
||||
export default {
|
||||
install () {
|
||||
@@ -35,8 +18,7 @@ export default {
|
||||
pluginRegistry.install(item)
|
||||
})
|
||||
|
||||
accessProviderRegister.install(AliyunAccessProvider)
|
||||
|
||||
accessProviderRegistry.install(AliyunAccessProvider)
|
||||
dnsProviderRegistry.install(AliyunDnsProvider)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import pkg from 'chai'
|
||||
import { createOptions } from '../../../../../test/options.js'
|
||||
import { Certd } from '@certd/certd'
|
||||
import PluginAliyun from '../../src/index.js'
|
||||
|
||||
// 安装默认插件和授权提供者
|
||||
PluginAliyun.install()
|
||||
const { expect } = pkg
|
||||
describe('AliyunDnsProvider', function () {
|
||||
it('#申请证书-aliyun', async function () {
|
||||
this.timeout(300000)
|
||||
const options = createOptions()
|
||||
options.args = { forceCert: true, test: false }
|
||||
const certd = new Certd(options)
|
||||
const cert = await certd.certApply()
|
||||
expect(cert).ok
|
||||
expect(cert.crt).ok
|
||||
expect(cert.key).ok
|
||||
expect(cert.detail).ok
|
||||
expect(cert.expires).ok
|
||||
})
|
||||
})
|
||||
@@ -1,27 +1,33 @@
|
||||
import pkg from 'chai'
|
||||
import AliyunDnsProvider from '../../src/dns-providers/aliyun.js'
|
||||
import { AliyunDnsProvider } from '../../src/dns-providers/aliyun.js'
|
||||
import { createOptions } from '../../../../../test/options.js'
|
||||
const { expect } = pkg
|
||||
|
||||
export function getPluginOptions () {
|
||||
const options = createOptions()
|
||||
return { accessProviders: options.accessProviders, props: options.cert.dnsProvider }
|
||||
}
|
||||
|
||||
describe('AliyunDnsProvider', function () {
|
||||
it('#getDomainList', async function () {
|
||||
const options = createOptions()
|
||||
const aliyunDnsProvider = new AliyunDnsProvider(options.accessProviders.aliyun)
|
||||
const options = getPluginOptions()
|
||||
const aliyunDnsProvider = new AliyunDnsProvider(options)
|
||||
const domainList = await aliyunDnsProvider.getDomainList()
|
||||
console.log('domainList', domainList)
|
||||
expect(domainList.length).gt(0)
|
||||
})
|
||||
|
||||
it('#getRecords', async function () {
|
||||
const options = createOptions()
|
||||
const aliyunDnsProvider = new AliyunDnsProvider(options.accessProviders.aliyun)
|
||||
const options = getPluginOptions()
|
||||
const aliyunDnsProvider = new AliyunDnsProvider(options)
|
||||
const recordList = await aliyunDnsProvider.getRecords('docmirror.cn', '*')
|
||||
console.log('recordList', recordList)
|
||||
expect(recordList.length).gt(0)
|
||||
})
|
||||
|
||||
it('#createAndRemoveRecord', async function () {
|
||||
const options = createOptions()
|
||||
const aliyunDnsProvider = new AliyunDnsProvider(options.accessProviders.aliyun)
|
||||
const options = getPluginOptions()
|
||||
const aliyunDnsProvider = new AliyunDnsProvider(options)
|
||||
const record = await aliyunDnsProvider.createRecord({ fullRecord: '___certd___.__test__.docmirror.cn', type: 'TXT', value: 'aaaa' })
|
||||
console.log('recordId', record)
|
||||
expect(record != null).ok
|
||||
|
||||
@@ -24,7 +24,7 @@ const defaultOptions = {
|
||||
cert: {
|
||||
domains: ['*.docmirror.club', 'docmirror.club'],
|
||||
email: 'xiaojunnuo@qq.com',
|
||||
dnsProvider: 'aliyun',
|
||||
dnsProvider: { type: 'aliyun', accessProvider: 'aliyun' },
|
||||
certProvider: 'letsencrypt',
|
||||
csrInfo: {
|
||||
country: 'CN',
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
import pkg from 'chai'
|
||||
import { DeployCertToAliyunCDN } from '../../src/plugins/deploy-to-cdn/index.js'
|
||||
import { Certd } from '@certd/certd'
|
||||
import createOptions from '../../../../../test/options.js'
|
||||
import { createOptions } from '../../../../../test/options.js'
|
||||
const { expect } = pkg
|
||||
|
||||
describe('DeployToAliyunCDN', function () {
|
||||
it('#execute', async function () {
|
||||
this.timeout(5000)
|
||||
const options = createOptions()
|
||||
const plugin = new DeployCertToAliyunCDN()
|
||||
const plugin = new DeployCertToAliyunCDN(options)
|
||||
options.cert.domains = ['*.docmirror.cn', 'docmirror.cn']
|
||||
const certd = new Certd(options)
|
||||
const cert = await certd.readCurrentCert()
|
||||
const ret = await plugin.doExecute({
|
||||
accessProviders: options.accessProviders,
|
||||
cert,
|
||||
props: { domainName: 'certd-cdn-upload.docmirror.cn', certName: 'certd部署测试', certType: 'cas', accessProvider: 'aliyun' }
|
||||
props: { domainName: 'certd-cdn-upload.docmirror.cn', certName: 'certd部署测试', from: 'cas', accessProvider: 'aliyun' }
|
||||
})
|
||||
console.log('context:', context, ret)
|
||||
})
|
||||
|
||||
@@ -9,12 +9,11 @@ describe('PluginUploadToAliyun', function () {
|
||||
const options = createOptions()
|
||||
options.cert.email = 'xiaojunnuo@qq.com'
|
||||
options.cert.domains = ['_.docmirror.cn']
|
||||
const plugin = new UploadCertToAliyun()
|
||||
const plugin = new UploadCertToAliyun(options)
|
||||
const certd = new Certd(options)
|
||||
const cert = await certd.readCurrentCert()
|
||||
const context = {}
|
||||
const deployOpts = {
|
||||
accessProviders: options.accessProviders,
|
||||
cert,
|
||||
props: { accessProvider: 'aliyun' },
|
||||
context
|
||||
@@ -22,7 +21,7 @@ describe('PluginUploadToAliyun', function () {
|
||||
await plugin.doExecute(deployOpts)
|
||||
console.log('context:', context)
|
||||
|
||||
// await plugin.sleep(1000)
|
||||
// await plugin.sleep(1000)
|
||||
// await plugin.rollback(deployOpts)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user