44 lines
1.5 KiB
JavaScript
44 lines
1.5 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import test from "node:test";
|
|
|
|
const migrationUrl = new URL(
|
|
"../migrations/005_device_registry_commands.sql",
|
|
import.meta.url,
|
|
);
|
|
const repositoryUrl = new URL("../src/postgres-repository.mjs", import.meta.url);
|
|
|
|
test("registry command migration extends the durable receipt allowlist", async () => {
|
|
const sql = await readFile(migrationUrl, "utf8");
|
|
|
|
for (const kind of [
|
|
"adapter_package.ensure",
|
|
"adapter_version.register",
|
|
"model_profile.register",
|
|
"edge.ensure",
|
|
"route.ensure",
|
|
"enrollment_intent.ensure",
|
|
]) {
|
|
assert.match(sql, new RegExp(`'${kind.replace(".", "\\.")}'`));
|
|
}
|
|
assert.doesNotMatch(sql, /session\.(ensure|create|upsert)/);
|
|
});
|
|
|
|
test("registry command migration contains no environment or device data", async () => {
|
|
const sql = await readFile(migrationUrl, "utf8");
|
|
|
|
assert.doesNotMatch(sql, /insert\s+into/i);
|
|
assert.doesNotMatch(sql, /dcctouch|arusnavi|\bb2\b|imei|gelios/i);
|
|
assert.doesNotMatch(sql, /password|secret|credential|private_key/i);
|
|
});
|
|
|
|
test("repository applies registry commands after registry schema", async () => {
|
|
const source = await readFile(repositoryUrl, "utf8");
|
|
const schemaIndex = source.indexOf("004_device_registry_foundation.sql");
|
|
const commandsIndex = source.indexOf("005_device_registry_commands.sql");
|
|
|
|
assert.notEqual(schemaIndex, -1);
|
|
assert.notEqual(commandsIndex, -1);
|
|
assert.ok(schemaIndex < commandsIndex);
|
|
});
|