mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
refactor: 1
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { AbstractPlugin, IsTask, TaskInput, TaskOutput, TaskPlugin } from "../src";
|
||||
|
||||
@IsTask(() => {
|
||||
return {
|
||||
name: "EchoPlugin",
|
||||
title: "测试插件【echo】",
|
||||
input: {
|
||||
cert: {
|
||||
title: "cert",
|
||||
component: {
|
||||
name: "pi-output-selector",
|
||||
},
|
||||
helper: "输出选择",
|
||||
},
|
||||
},
|
||||
output: {},
|
||||
};
|
||||
})
|
||||
export class EchoPlugin extends AbstractPlugin implements TaskPlugin {
|
||||
async execute(input: TaskInput): Promise<TaskOutput> {
|
||||
for (const key in input) {
|
||||
this.logger.info("input :", key, input[key]);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
import { expect } from "chai";
|
||||
import "mocha";
|
||||
import { EchoPlugin } from "../src/plugin/plugins";
|
||||
import { EchoPlugin } from "./echo-plugin";
|
||||
describe("task_plugin", function () {
|
||||
it("#taskplugin", function () {
|
||||
const echoPlugin = new EchoPlugin();
|
||||
const define = echoPlugin.define;
|
||||
echoPlugin.execute({ context: {}, props: { test: 111 } });
|
||||
// @ts-ignore
|
||||
const define = echoPlugin.getDefine();
|
||||
echoPlugin.execute({ context: {}, input: { test: 111 } });
|
||||
expect(define.name).eq("EchoPlugin");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { IAccessService } from "../../src/access/access-service";
|
||||
import { AbstractAccess, AliyunAccess } from "../../src";
|
||||
import { AbstractAccess, IAccessService } from "../../src";
|
||||
import { aliyunSecret } from "../user.secret";
|
||||
export class AccessServiceTest implements IAccessService {
|
||||
async getById(id: any): Promise<AbstractAccess> {
|
||||
return {
|
||||
...aliyunSecret,
|
||||
} as AliyunAccess;
|
||||
} as any;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import { expect } from "chai";
|
||||
import "mocha";
|
||||
import { CertApplyPlugin } from "../../../src/plugin/plugins";
|
||||
import { pluginInitProps } from "../init.test";
|
||||
describe("CertApply", function () {
|
||||
it("#execute", async function () {
|
||||
this.timeout(120000);
|
||||
const plugin = new CertApplyPlugin();
|
||||
// @ts-ignore
|
||||
delete plugin.define;
|
||||
await plugin.doInit(pluginInitProps);
|
||||
const output = await plugin.execute({
|
||||
domains: ["*.docmirror.cn", "docmirror.cn"],
|
||||
email: "xiaojunnuo@qq.com",
|
||||
dnsProviderType: "aliyun",
|
||||
accessId: "111",
|
||||
forceUpdate: true,
|
||||
});
|
||||
const cert = output.cert;
|
||||
expect(plugin.getDefine().name).eq("CertApply");
|
||||
expect(cert.crt != null).eq(true);
|
||||
});
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
import { expect } from "chai";
|
||||
import "mocha";
|
||||
import { DeployCertToAliyunCDN } from "../../../src/plugin/plugins";
|
||||
import { pluginInitProps } from "../init.test";
|
||||
|
||||
describe("DeployToAliyunCDN", function () {
|
||||
it("#execute", async function () {
|
||||
this.timeout(120000);
|
||||
const plugin = new DeployCertToAliyunCDN();
|
||||
// @ts-ignore
|
||||
delete plugin.define;
|
||||
|
||||
await plugin.doInit(pluginInitProps);
|
||||
|
||||
const cert = await pluginInitProps.pipelineContext.get("cert");
|
||||
|
||||
await plugin.execute({
|
||||
cert,
|
||||
domainName: "certd-cdn-upload.docmirror.cn",
|
||||
});
|
||||
expect(plugin.getDefine().name).eq("DeployCertToAliyunCDN");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user