40 lines
1.6 KiB
JavaScript
40 lines
1.6 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import test from "node:test";
|
|
|
|
const migrationUrl = new URL(
|
|
"../migrations/012_device_gateway_message_receipts.sql",
|
|
import.meta.url,
|
|
);
|
|
const repositoryUrl = new URL("../src/postgres-repository.mjs", import.meta.url);
|
|
|
|
test("gateway receipts persist only typed bounded Core acceptance evidence", async () => {
|
|
const sql = await readFile(migrationUrl, "utf8");
|
|
|
|
assert.match(sql, /create table if not exists device_gateway_message_receipts/);
|
|
assert.match(sql, /unique \(idempotency_key\)/);
|
|
assert.match(sql, /unique \(edge_ref, session_ref, message_ref\)/);
|
|
assert.match(sql, /identifier_digest text not null/);
|
|
assert.match(sql, /identifier_masked text not null/);
|
|
assert.match(sql, /payload_schema_ref text not null/);
|
|
assert.match(sql, /payload jsonb not null/);
|
|
assert.match(sql, /device_gateway_message_receipts_immutable_guard/);
|
|
assert.doesNotMatch(sql, /raw_packet|raw_identifier|password|token|secret/i);
|
|
assert.doesNotMatch(sql, /insert\s+into|arusnavi|gelios|\bb2\b|imei/i);
|
|
});
|
|
|
|
test("gateway receipt migration follows the generic control resource schema", async () => {
|
|
const repository = await readFile(repositoryUrl, "utf8");
|
|
const controlResourceIndex = repository.indexOf(
|
|
"011_device_control_resource_commands.sql",
|
|
);
|
|
const gatewayReceiptIndex = repository.indexOf(
|
|
"012_device_gateway_message_receipts.sql",
|
|
);
|
|
|
|
assert.notEqual(controlResourceIndex, -1);
|
|
assert.notEqual(gatewayReceiptIndex, -1);
|
|
assert.ok(controlResourceIndex < gatewayReceiptIndex);
|
|
assert.doesNotMatch(repository, /arusnavi-b2-adapter/);
|
|
});
|