32 lines
1.7 KiB
TypeScript
32 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { getHandler } from "../../src/engine/registry";
|
|
import type { CatalogComponent, FlowNode } from "../../src/types";
|
|
import type { RunContext } from "../../src/engine/types";
|
|
import "../../src/capabilities/desktop";
|
|
import "../../src/capabilities/basic-encryption";
|
|
|
|
const context = {} as RunContext;
|
|
const component = {} as CatalogComponent;
|
|
const node = (id: string): FlowNode => ({ id, componentId: id, position: { x: 0, y: 0 }, values: {}, options: {} });
|
|
async function run(id: string, args: Record<string, unknown>) {
|
|
const handler = getHandler(id);
|
|
expect(handler, id).toBeTruthy();
|
|
return handler!(context, node(id), args, component);
|
|
}
|
|
|
|
describe.skipIf(process.platform !== "win32")("manual keyboard and encrypted variables", () => {
|
|
it("registers manual keyboard switches", async () => {
|
|
await expect(run("Keyboard_EnableManualOperation", { random_move: true, random_click: true, random_sleep: false, min_time: 0, max_time: 0 })).resolves.toMatchObject({ enabled: true });
|
|
await expect(run("Keyboard_DisableManualOperation", {})).resolves.toEqual({ enabled: false });
|
|
});
|
|
|
|
it("decodes base64 and SM4 ciphertext", async () => {
|
|
await expect(run("Basic_Dodecryption", { words: Buffer.from("hello", "utf8").toString("base64") })).resolves.toBe("hello");
|
|
const { sm4 } = await import("sm-crypto");
|
|
const key = Buffer.from("INPUT_PARAM_KEY4", "utf8").toString("hex");
|
|
const cipher = sm4.encrypt("secret", key, { padding: "pkcs#7" });
|
|
await expect(run("Basic_Dodecryption", { words: cipher })).resolves.toBe("secret");
|
|
await expect(run("Basic_Dodecryption", {})).rejects.toThrow();
|
|
});
|
|
});
|