Public: anyone can read this; the crew can change it.

A test proves the terminal's trusted hosts prompt: only a forge admin is offered it, a save is audited and live at once, a bad host is refused in the page's words #7609

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/7592-a-test-proves-the-terminal-s-trusted-hos → main 2 commits fork 1 thread · 1 unresolved

  • Merged. scout/7592-a-test-proves-the-terminal-s-trusted-hos was merged into main as 420b80d.

Review

Sign in to review this change.
1 file changed +8 −2
test/trusted-hosts-ui.test.ts +8 −2
@@ -9,7 +9,7 @@ import { resolveSource } from "../src/actions/migrate.ts";
99 import { createOrigin } from "../src/core/origins.ts";
1010 import { createUser, getUserByName } from "../src/core/users.ts";
1111 import { serve, type Servers } from "../src/http/server.ts";
12 import { loadTrustedHosts, parseHosts, trustedHosts } from "../src/origins/trusted-hosts.ts";
12 import { loadTrustedHosts, parseHosts, rejectedSentence, trustedHosts } from "../src/origins/trusted-hosts.ts";
1313 import { createForgeApp } from "../src/tui/forge.ts";
1414 import type { TuiIdentity } from "../src/tui/session.ts";
1515 import { headlessTerminal } from "../src/tui/term/terminal.ts";
@@ -167,9 +167,12 @@ describe("trusted internal hosts", () => {
167167 }
168168
169169 test("a non-admin is not offered it", async () => {
170 const before = changes();
170171 const h = boot("bob");
171172 await h.palette();
172173 expect(h.text()).not.toContain("internal hosts an origin may reach");
174 expect(trustedHosts()).toEqual(["git.internal.test"]);
175 expect(changes()).toEqual(before);
173176 h.stop();
174177 });
175178
@@ -181,12 +184,13 @@ describe("trusted internal hosts", () => {
181184 expect(h.text()).toContain("git.internal.test");
182185 await h.type(" 10.1.1.1");
183186 await h.enter();
184 expect(h.text()).toContain("Not host names");
187 expect(h.text()).toContain(rejectedSentence(parseHosts("10.1.1.1").rejected).slice(0, 40));
185188 expect(trustedHosts()).toEqual(["git.internal.test"]);
186189 h.stop();
187190 });
188191
189192 test("an admin saves from the terminal: live and audited", async () => {
193 const before = changes().length;
190194 const h = boot("alice");
191195 await h.palette();
192196 await h.enter();
@@ -194,6 +198,8 @@ describe("trusted internal hosts", () => {
194198 await h.enter();
195199 expect(trustedHosts().sort()).toEqual(["git.internal.test", "second.test"]);
196200 expect(changes().at(-1)).toBe('["git.internal.test","second.test"]');
201 expect(changes()).toHaveLength(before + 1);
202 expect(h.text()).toContain("Trusted: git.internal.test, second.test.");
197203 h.stop();
198204 });
199205 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs