Release Network Tools 0.1.0

This commit is contained in:
2026-09-01 02:44:20 +02:00
commit 729430295b
61 changed files with 8357 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
import { expect, test, type Page } from "@playwright/test";
const ORIGIN = "http://127.0.0.1:4173";
async function localOnly(page: Page) {
const external: string[] = [];
await page.route("**/*", async (route) => {
const url = new URL(route.request().url());
if (url.origin !== ORIGIN) {
external.push(url.href);
await route.abort();
} else await route.continue();
});
return external;
}
test("runs from a nested path without external requests", async ({ page }) => {
const errors: string[] = [];
page.on("pageerror", (error) => errors.push(error.message));
page.on("console", (message) => {
if (message.type() === "error") errors.push(message.text());
});
const external = await localOnly(page);
await page.goto("/deep/nested/network/");
await expect(
page.getByRole("heading", { name: "Network Tools" }),
).toBeVisible();
expect(external).toEqual([]);
expect(errors).toEqual([]);
});
test("calculates a subnet and sanitises a credential-bearing URL", async ({
page,
}) => {
const external = await localOnly(page);
await page.goto("/deep/nested/network/");
await expect(
page.getByText("Network", { exact: true }).locator("..").locator("dd"),
).toHaveText("192.168.10.0");
await expect(
page.getByText("Last address", { exact: true }).locator("..").locator("dd"),
).toHaveText("192.168.10.255");
await page.getByRole("tab", { name: "URL" }).click();
await page
.getByLabel("URL or reference")
.fill("https://alice:secret@example.test/a?q=one&q=two");
await expect(
page.getByText("https://alice@example.test/a?q=one&q=two", { exact: true }),
).toBeVisible();
await expect(page.getByText(/password; it was removed/u)).toBeVisible();
await expect(page.getByText("secret", { exact: false })).toHaveCount(0);
expect(external).toEqual([]);
});
test("serves the release identity and hardened headers", async ({
request,
}) => {
const index = await request.get("/deep/nested/network/");
expect(index.ok()).toBe(true);
expect(index.headers()["content-security-policy"]).toContain(
"default-src 'self'",
);
expect(await index.text()).not.toMatch(/\b(?:src|href)=["']\//u);
const manifest = await request.get("/deep/nested/network/toolbox-app.json");
await expect(manifest.json()).resolves.toMatchObject({
id: "de.add-ideas.network-tools",
version: "0.1.0",
entry: "./",
});
});