29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import test from "node:test";
|
|
|
|
const migrationUrl = new URL(
|
|
"../migrations/014_device_registry_profile_commands.sql",
|
|
import.meta.url,
|
|
);
|
|
const repositoryUrl = new URL("../src/postgres-repository.mjs", import.meta.url);
|
|
|
|
test("registry profile command migration enables the bounded device update", async () => {
|
|
const sql = await readFile(migrationUrl, "utf8");
|
|
|
|
assert.match(sql, /'device\.update'/);
|
|
assert.doesNotMatch(sql, /insert\s+into/i);
|
|
assert.doesNotMatch(sql, /dcctouch|arusnavi|\bb2\b|imei|gelios/i);
|
|
assert.doesNotMatch(sql, /password|secret|private_key|private-key|token\s*=/i);
|
|
});
|
|
|
|
test("repository applies the profile command after edge channel schema", async () => {
|
|
const source = await readFile(repositoryUrl, "utf8");
|
|
const edgeChannelIndex = source.indexOf("013_device_edge_channels.sql");
|
|
const profileCommandIndex = source.indexOf("014_device_registry_profile_commands.sql");
|
|
|
|
assert.notEqual(edgeChannelIndex, -1);
|
|
assert.notEqual(profileCommandIndex, -1);
|
|
assert.ok(edgeChannelIndex < profileCommandIndex);
|
|
});
|