Add browser-hosted TrustLab security surface
This commit is contained in:
1 parent
1b0f178f37
commit
9830f444ac
9 files changed
+782
-3
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
import { unknownLocalAuthority } from "../fixtures/tls.js";
|
||||
import {
|
||||
createFirefoxValidationPlugin,
|
||||
createUserDecisionPlugin,
|
||||
createVillageCommunityPlugin,
|
||||
} from "../plugins/demo-plugins.js";
|
||||
import { TrustRunner } from "../src/index.js";
|
||||
import { chainRows, subjectName, verdictCopy } from "../ui/model.js";
|
||||
|
||||
test("UI model identifies the failed end of an unknown-authority chain", () => {
|
||||
const rows = chainRows(unknownLocalAuthority);
|
||||
assert.equal(rows.length, 2);
|
||||
assert.equal(rows[0].name, "library.village");
|
||||
assert.equal(rows.at(-1).failed, true);
|
||||
assert.match(rows.at(-1).edge, /Not anchored/);
|
||||
});
|
||||
|
||||
test("certificate display names prefer the common name", () => {
|
||||
assert.equal(subjectName("O=Village,CN=Library CA,C=GE"), "Library CA");
|
||||
assert.equal(subjectName("O=Nameless"), "O=Nameless");
|
||||
});
|
||||
|
||||
test("UI plugins produce attributed evidence and a local Boolean verdict", async () => {
|
||||
const plugins = [
|
||||
createFirefoxValidationPlugin(),
|
||||
createVillageCommunityPlugin(),
|
||||
createUserDecisionPlugin(true),
|
||||
];
|
||||
const result = await new TrustRunner({ plugins }).evaluate(unknownLocalAuthority);
|
||||
|
||||
assert.equal(result.verdict.trusted, true);
|
||||
assert.ok(result.journal.entries.some((entry) => entry.code === "unknown-issuer"));
|
||||
assert.ok(
|
||||
result.journal.entries.some((entry) => entry.code === "community-key-continuity"),
|
||||
);
|
||||
assert.equal(verdictCopy(result, true).title, "You trust this connection");
|
||||
});
|
||||
|
||||
test("security surface contains immutable-frame and simulation labels", async () => {
|
||||
const html = await readFile(new URL("../ui/index.html", import.meta.url), "utf8");
|
||||
assert.match(html, /Browsec security decision/);
|
||||
assert.match(html, /Browser-owned test surface/);
|
||||
assert.match(html, /TRUSTLAB · SYNTHETIC/);
|
||||
assert.match(html, /It cannot alter browser trust/);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user