Lines 13–19 at 151 (were 13–19 at 150)
1313import { join } from "node:path"; 1414import { after, before, describe, it } from "node:test"; 1515import { readConfig, readMachineServers } from "../src/config.ts"; 16−import { issuesServerFor, tokenGoesTo } from "../src/core.ts";
16+import { issuesServerFor, tokenGoesTo, tokenGoesToIssues } from "../src/core.ts"; 1717import { issuePage, searchLines } from "../src/issues.ts"; 1818import type { IssuePage } from "../src/issues-wire.ts"; 1919import { main } from "../src/main.ts"; Lines 176–217 at 151 (were 176–191 at 150)
176176 assert.equal(r.exit, 1, r.out); 177177 assert.match(r.out, /sends your token only to its own servers and this machine/); 178178 assert.equal(seen.length, before); 179− // A server with no Issues Worker beside it, and none named.
180− const { AVCS_ISSUES_SERVER: _, ...without } = ENV();
181− const none = await avcs(dave, ["waiting"], without);
182− assert.notEqual(none.exit, 0);
183− assert.match(
184− none.out,
185− /has no Issues Worker beside it that abso knows; ~\/\.abso\/servers\.json or ABSO_ISSUES_SERVER names one/,
186− );
181+ it("with no Issues Worker named, uses the server's own /issues, as the open server keeps them", () => { 182+ assert.equal(issuesServerFor("https://abso.example"), "https://abso.example/issues"); 183+ assert.equal(issuesServerFor("https://Abso.Example/"), "https://abso.example/issues"); 184+ assert.equal(issuesServerFor("http://localhost:8787"), "http://localhost:8787/issues"); 185+ assert.equal(issuesServerFor("not a server"), undefined); 186+ // abso's hosted server keeps its own Issues Worker, and servers.json still comes first. 187+ assert.equal(issuesServerFor("https://api.abso.dev"), "https://issues.abso.dev"); 190+ issues: { "https://staging.abso.example": "https://issues-staging.abso.example" }, 192+ assert.equal(issuesServerFor("https://staging.abso.example", machine), "https://issues-staging.abso.example"); 193+ // The token goes to <server>/issues exactly where it goes to <server>. 194+ assert.ok(tokenGoesToIssues("https://api.abso.dev/issues")); 195+ assert.ok(tokenGoesToIssues("http://localhost:8787/issues")); 196+ assert.ok(tokenGoesToIssues("https://mine.example/issues", "https://mine.example")); 197+ assert.equal(tokenGoesToIssues("https://evil.example/issues"), false); 198+ assert.equal(tokenGoesToIssues("https://api.abso.dev@evil.example/issues"), false); 199+ assert.equal(tokenGoesToIssues("https://api.abso.dev/issues?x=1"), false); 200+ assert.equal(tokenGoesToIssues("http://mine.example/issues", "http://mine.example"), false, "plain http only here"); 201+ // The server itself still takes no path. 202+ assert.equal(tokenGoesTo("https://api.abso.dev/issues"), false); 205+ it("calls <issues server>/p/<project>/... when the Issues Worker is at a path", async () => { 206+ const fay = await folder("fay"); 207+ const before = seen.length; 208+ const env = { ...ENV(), AVCS_ISSUES_SERVER: `${issuesUrl}/issues` }; 209+ const r = await main(["ask", "7"], { cwd: fay, env, write: () => {} }); 210+ assert.equal(r.exit, 0, r.stdout + r.stderr); 211+ const { project } = readConfig(fay); 212+ assert.deepEqual(seen.slice(before), [`GET /issues/p/${project}/ask/7`]); 189215 it("finds a server's Issues Worker in this machine's servers.json, and may send it the token", async () => { 190216 const dir = mkdtempSync(join(tmpdir(), "abso-servers-")); Lines 224–230 at 151 (were 198–204 at 150)
198224 assert.ok(seen.length > before, "the call went to the Issues Worker servers.json names"); 199225 const machine = readMachineServers({ AVCS_SERVERS_FILE: file }); 200226 assert.equal(issuesServerFor(fake.url, machine), issuesUrl); 201− assert.equal(issuesServerFor("https://abso.example", machine), undefined);
227+ assert.equal(issuesServerFor("https://abso.example", machine), "https://abso.example/issues"); 202228 // abso's own server and its Issues Worker are built in. 203229 assert.ok(tokenGoesTo("https://api.abso.dev")); 204230 assert.ok(tokenGoesTo("https://issues.abso.dev"));