feat: manual keyboard mode and ciphertext variables
This commit is contained in:
1 parent
9a5f86c92a
commit
ae4f4a2460
7 files changed
+163
-2
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getHandler } from "../engine/registry";
|
||||
import type { CatalogComponent, FlowNode } from "../../shared/types";
|
||||
import type { RunContext } from "../engine/types";
|
||||
import "./desktop";
|
||||
import "./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("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();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user