mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 21:32:10 +03:00
- audit-high-level-actions.test.ts: replace old provider.added/combo/apikey assertions with new provider.credentials.*, auth.login.*, sync.token.* and settings assertions. Count still 26. - audit-activity-icons.test.ts: replace provider.added spec check with provider.credentials.created + auth.login.success spot checks. - audit-allowlist-real-actions.test.ts (new): strict 1:1 HIGH_LEVEL_ACTIONS <-> ACTIVITY_ICONS, all 26 real repo actions present, isHighLevelAction/getActivityIcon spot assertions.
88 lines
2.4 KiB
TypeScript
88 lines
2.4 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { HIGH_LEVEL_ACTIONS, isHighLevelAction } from "../../src/lib/audit/highLevelActions";
|
|
|
|
const ALL = HIGH_LEVEL_ACTIONS as readonly string[];
|
|
|
|
// B/G3: allowlist now has 26 real actions aligned with logAuditEvent emitters.
|
|
test("HIGH_LEVEL_ACTIONS has exactly 26 entries", () => {
|
|
assert.equal(ALL.length, 26);
|
|
});
|
|
|
|
test("HIGH_LEVEL_ACTIONS has no duplicates", () => {
|
|
assert.equal(new Set(ALL).size, ALL.length);
|
|
});
|
|
|
|
test("isHighLevelAction true for every entry in allowlist", () => {
|
|
for (const a of ALL) {
|
|
assert.ok(isHighLevelAction(a), `Expected true for '${a}'`);
|
|
}
|
|
});
|
|
|
|
test("isHighLevelAction false for 'random.event'", () => {
|
|
assert.equal(isHighLevelAction("random.event"), false);
|
|
});
|
|
|
|
test("isHighLevelAction false for empty string", () => {
|
|
assert.equal(isHighLevelAction(""), false);
|
|
});
|
|
|
|
test("isHighLevelAction false for partial 'provider'", () => {
|
|
assert.equal(isHighLevelAction("provider"), false);
|
|
});
|
|
|
|
test("includes all 5 quota.* actions from B26", () => {
|
|
for (const a of [
|
|
"quota.pool.created",
|
|
"quota.pool.updated",
|
|
"quota.pool.deleted",
|
|
"quota.plan.updated",
|
|
"quota.store.driver_changed",
|
|
]) {
|
|
assert.ok(ALL.includes(a), `Missing ${a}`);
|
|
}
|
|
});
|
|
|
|
test("includes real provider credential actions", () => {
|
|
for (const a of [
|
|
"provider.credentials.created",
|
|
"provider.credentials.applied",
|
|
"provider.credentials.updated",
|
|
"provider.credentials.revoked",
|
|
"provider.credentials.batch_revoked",
|
|
"provider.credentials.bulk_created",
|
|
"provider.credentials.bulk_imported",
|
|
"provider.credentials.imported",
|
|
"provider.validation.ssrf_blocked",
|
|
]) {
|
|
assert.ok(ALL.includes(a), `Missing ${a}`);
|
|
}
|
|
});
|
|
|
|
test("includes real auth actions", () => {
|
|
for (const a of [
|
|
"auth.login.success",
|
|
"auth.login.error",
|
|
"auth.login.failed",
|
|
"auth.login.locked",
|
|
"auth.login.misconfigured",
|
|
"auth.login.setup_required",
|
|
"auth.logout.success",
|
|
]) {
|
|
assert.ok(ALL.includes(a), `Missing ${a}`);
|
|
}
|
|
});
|
|
|
|
test("includes sync token actions", () => {
|
|
for (const a of ["sync.token.created", "sync.token.revoked"]) {
|
|
assert.ok(ALL.includes(a), `Missing ${a}`);
|
|
}
|
|
});
|
|
|
|
test("includes real settings and service actions", () => {
|
|
for (const a of ["settings.update", "settings.update_failed", "service.reveal_api_key"]) {
|
|
assert.ok(ALL.includes(a), `Missing ${a}`);
|
|
}
|
|
});
|