Files
mesh-catalog/modules/nextcloud/test/manifest.test.ts
T

36 lines
1.7 KiB
TypeScript

// 1830/AC2 (unit: manifest checks)
// Given the catalogue, when nextcloud's manifest is parsed, then it requires document-server,
// binds it and receives its secret, and its config.json template carries the document server's
// public address, bound address and port, its own route name and the shared secret.
// Run against the manifest and its templates directly — no build needed, they are read as data.
import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
const moduleDir = join(dirname(fileURLToPath(import.meta.url)), "..");
function readJson(path: string): any {
return JSON.parse(readFileSync(join(moduleDir, path), "utf8"));
}
test("the manifest requires document-server, and binds and receives its secret", () => {
const manifest = readJson("module.json");
assert.ok(
Array.isArray(manifest.requires) && manifest.requires.includes("document-server"),
"requires names document-server",
);
assert.equal(manifest.binds?.["document-server"], "${dir:state}/document-server.json");
assert.equal(manifest.secrets?.["document-server"], "${dir:state}/document-server.secret");
});
test("config.json carries the document server's public address, bound address, port, route name and secret", () => {
const config = readJson("files/config.json");
assert.equal(config.onlyofficeUrl, "${bound:document-server:public-root}");
assert.equal(config.onlyofficeInternalUrl, "http://${bound:document-server:at}:${bound:document-server:port}/");
assert.equal(config.onlyofficeStorageUrl, "https://${bound:route:name}/");
assert.equal(config.onlyofficeSecret, "${secret:document-server}");
});