@app-vitals/agent-admin 1.48.0 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/e2e/agents-page.e2e.ts +61 -21
- package/e2e/marketplaces-section.e2e.ts +5 -24
- package/e2e/plugins-section.e2e.ts +6 -27
- package/package.json +2 -2
- package/src/admin-ui-agent-sections.unit.test.ts +95 -0
- package/src/admin-ui-agent-template.smoke.test.ts +421 -0
- package/src/admin-ui-github-identity-pages.unit.test.ts +22 -1
- package/src/admin-ui-github-identity.smoke.test.ts +1 -1
- package/src/admin-ui-installation-repos.smoke.test.ts +7 -7
- package/src/admin-ui-pages.ts +269 -119
- package/src/admin-ui-pages.unit.test.ts +166 -225
- package/src/admin-ui-styles.ts +8 -65
- package/src/admin-ui.smoke.test.ts +171 -69
- package/src/admin-ui.ts +325 -86
- package/src/agent-envs.ts +5 -1
- package/src/agents.ts +3 -0
|
@@ -28,13 +28,13 @@ import {
|
|
|
28
28
|
} from "./admin-ui.fixtures.ts";
|
|
29
29
|
import { createAdminUIApp } from "./admin-ui.ts";
|
|
30
30
|
import { AnthropicCredentialsBlockedError } from "./anthropic-credential-guard.ts";
|
|
31
|
+
import { UnprocessableEntityError } from "./errors.ts";
|
|
31
32
|
import type { PushService } from "./push-service.ts";
|
|
32
33
|
import {
|
|
33
34
|
resolveDefaultSpecialtyName,
|
|
34
35
|
SPECIALIST_TYPE,
|
|
35
36
|
SpecialtyTypes,
|
|
36
37
|
} from "./specialty-types.ts";
|
|
37
|
-
import { UnprocessableEntityError } from "./errors.ts";
|
|
38
38
|
|
|
39
39
|
// The specialty the create-agent flows use: the configured default type (the
|
|
40
40
|
// platform test run points it at the fixture specialty; the monorepo falls
|
|
@@ -960,17 +960,53 @@ describe("admin UI — authenticated pages", () => {
|
|
|
960
960
|
|
|
961
961
|
it("authenticated GET /admin/agents/:id returns 200 with agent detail sections", async () => {
|
|
962
962
|
const app = createAdminUIApp(makeMockDeps());
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
const
|
|
968
|
-
expect(
|
|
969
|
-
expect(
|
|
970
|
-
expect(
|
|
971
|
-
expect(
|
|
972
|
-
expect(
|
|
973
|
-
|
|
963
|
+
const get = (path: string) =>
|
|
964
|
+
app.request(`/admin/agents/${AGENT_ID}${path}`, {
|
|
965
|
+
headers: { Cookie: `admin_session=${cookie}` },
|
|
966
|
+
});
|
|
967
|
+
const general = await get("");
|
|
968
|
+
expect(general.status).toBe(200);
|
|
969
|
+
expect(await general.text()).toContain("admin@example.com");
|
|
970
|
+
expect(await (await get("/general")).text()).toContain("Danger Zone");
|
|
971
|
+
expect(await (await get("/configuration")).text()).toContain("Env Vars");
|
|
972
|
+
expect(await (await get("/automation")).text()).toContain("Cron Jobs");
|
|
973
|
+
const access = await (await get("/access")).text();
|
|
974
|
+
expect(access).toContain("Tokens");
|
|
975
|
+
const extensions = await (await get("/extensions")).text();
|
|
976
|
+
expect(extensions).toContain("Tools");
|
|
977
|
+
expect(extensions).toContain("Plugins");
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
it("section routes: sidebar active item follows the section; unknown section 404s", async () => {
|
|
981
|
+
const app = createAdminUIApp(makeMockDeps());
|
|
982
|
+
const get = (path: string, c = cookie) =>
|
|
983
|
+
app.request(`/admin/agents/${AGENT_ID}${path}`, {
|
|
984
|
+
headers: { Cookie: `admin_session=${c}` },
|
|
985
|
+
});
|
|
986
|
+
for (const section of [
|
|
987
|
+
"general",
|
|
988
|
+
"automation",
|
|
989
|
+
"configuration",
|
|
990
|
+
"access",
|
|
991
|
+
"extensions",
|
|
992
|
+
]) {
|
|
993
|
+
const html = await (await get(`/${section}`)).text();
|
|
994
|
+
const active = html.match(/href="([^"]*)" aria-current="page"/);
|
|
995
|
+
expect(active?.[1]).toBe(
|
|
996
|
+
section === "general"
|
|
997
|
+
? `/admin/agents/${AGENT_ID}`
|
|
998
|
+
: `/admin/agents/${AGENT_ID}/${section}`,
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
expect((await get("/bogus")).status).toBe(404);
|
|
1002
|
+
const outsider = await makeSessionCookie(
|
|
1003
|
+
SESSION_SECRET,
|
|
1004
|
+
"google-sub-outsider",
|
|
1005
|
+
"outsider@example.com",
|
|
1006
|
+
false,
|
|
1007
|
+
);
|
|
1008
|
+
expect((await get("/automation", outsider)).status).toBe(403);
|
|
1009
|
+
expect((await get("/general", outsider)).status).toBe(403);
|
|
974
1010
|
});
|
|
975
1011
|
|
|
976
1012
|
describe("connect-later actions (UAP-2.3)", () => {
|
|
@@ -986,7 +1022,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
986
1022
|
},
|
|
987
1023
|
}),
|
|
988
1024
|
);
|
|
989
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1025
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
990
1026
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
991
1027
|
});
|
|
992
1028
|
expect(res.status).toBe(200);
|
|
@@ -1025,7 +1061,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1025
1061
|
},
|
|
1026
1062
|
}),
|
|
1027
1063
|
);
|
|
1028
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1064
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
1029
1065
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1030
1066
|
});
|
|
1031
1067
|
expect(res.status).toBe(200);
|
|
@@ -1051,7 +1087,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1051
1087
|
},
|
|
1052
1088
|
}),
|
|
1053
1089
|
);
|
|
1054
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1090
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
1055
1091
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1056
1092
|
});
|
|
1057
1093
|
expect(res.status).toBe(200);
|
|
@@ -1077,7 +1113,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1077
1113
|
},
|
|
1078
1114
|
}),
|
|
1079
1115
|
);
|
|
1080
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1116
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
1081
1117
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1082
1118
|
});
|
|
1083
1119
|
expect(res.status).toBe(200);
|
|
@@ -1103,7 +1139,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1103
1139
|
},
|
|
1104
1140
|
}),
|
|
1105
1141
|
);
|
|
1106
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1142
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
1107
1143
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1108
1144
|
});
|
|
1109
1145
|
expect(res.status).toBe(200);
|
|
@@ -1156,7 +1192,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1156
1192
|
},
|
|
1157
1193
|
}),
|
|
1158
1194
|
);
|
|
1159
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1195
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
1160
1196
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1161
1197
|
});
|
|
1162
1198
|
const html = await res.text();
|
|
@@ -1184,7 +1220,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1184
1220
|
},
|
|
1185
1221
|
}),
|
|
1186
1222
|
);
|
|
1187
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1223
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
1188
1224
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1189
1225
|
});
|
|
1190
1226
|
const html = await res.text();
|
|
@@ -1212,7 +1248,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1212
1248
|
},
|
|
1213
1249
|
}),
|
|
1214
1250
|
);
|
|
1215
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1251
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
1216
1252
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1217
1253
|
});
|
|
1218
1254
|
const html = await res.text();
|
|
@@ -1347,7 +1383,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1347
1383
|
},
|
|
1348
1384
|
}),
|
|
1349
1385
|
);
|
|
1350
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1386
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/automation`, {
|
|
1351
1387
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1352
1388
|
});
|
|
1353
1389
|
expect(res.status).toBe(200);
|
|
@@ -1412,7 +1448,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1412
1448
|
|
|
1413
1449
|
it("authenticated GET /admin/agents/:id includes an add-cron form with enabled checkbox", async () => {
|
|
1414
1450
|
const app = createAdminUIApp(makeMockDeps());
|
|
1415
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1451
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/automation`, {
|
|
1416
1452
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1417
1453
|
});
|
|
1418
1454
|
expect(res.status).toBe(200);
|
|
@@ -1465,13 +1501,19 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1465
1501
|
body: form,
|
|
1466
1502
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1467
1503
|
});
|
|
1468
|
-
//
|
|
1504
|
+
// Redirects back to the Configuration section that owns the env card
|
|
1469
1505
|
expect(postRes.status).toBe(302);
|
|
1506
|
+
expect(postRes.headers.get("Location")).toBe(
|
|
1507
|
+
`/admin/agents/${AGENT_ID}/configuration`,
|
|
1508
|
+
);
|
|
1470
1509
|
|
|
1471
1510
|
// Fetch the agent detail page — the mock getByAgentId returns the secret key
|
|
1472
|
-
const getRes = await app.request(
|
|
1473
|
-
|
|
1474
|
-
|
|
1511
|
+
const getRes = await app.request(
|
|
1512
|
+
`/admin/agents/${AGENT_ID}/configuration`,
|
|
1513
|
+
{
|
|
1514
|
+
headers: { Cookie: `admin_session=${cookie}` },
|
|
1515
|
+
},
|
|
1516
|
+
);
|
|
1475
1517
|
expect(getRes.status).toBe(200);
|
|
1476
1518
|
const html = await getRes.text();
|
|
1477
1519
|
// Lock icon should appear for secret keys
|
|
@@ -1514,7 +1556,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1514
1556
|
|
|
1515
1557
|
it("managed agent (selfHosted=false) shows Env Vars card", async () => {
|
|
1516
1558
|
const app = createAdminUIApp(makeMockDeps());
|
|
1517
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1559
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/configuration`, {
|
|
1518
1560
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1519
1561
|
});
|
|
1520
1562
|
expect(res.status).toBe(200);
|
|
@@ -1562,7 +1604,7 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1562
1604
|
|
|
1563
1605
|
it("managed agent (selfHosted=false) shows Tools card", async () => {
|
|
1564
1606
|
const app = createAdminUIApp(makeMockDeps());
|
|
1565
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
1607
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/extensions`, {
|
|
1566
1608
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
1567
1609
|
});
|
|
1568
1610
|
expect(res.status).toBe(200);
|
|
@@ -1687,9 +1729,12 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1687
1729
|
},
|
|
1688
1730
|
}),
|
|
1689
1731
|
);
|
|
1690
|
-
const res = await app.request(
|
|
1691
|
-
|
|
1692
|
-
|
|
1732
|
+
const res = await app.request(
|
|
1733
|
+
`/admin/agents/${SELFHOSTED_AGENT_ID}/automation`,
|
|
1734
|
+
{
|
|
1735
|
+
headers: { Cookie: `admin_session=${cookie}` },
|
|
1736
|
+
},
|
|
1737
|
+
);
|
|
1693
1738
|
expect(res.status).toBe(200);
|
|
1694
1739
|
const html = await res.text();
|
|
1695
1740
|
// System crons section should be present for self-hosted agents
|
|
@@ -1734,9 +1779,12 @@ describe("admin UI — authenticated pages", () => {
|
|
|
1734
1779
|
},
|
|
1735
1780
|
}),
|
|
1736
1781
|
);
|
|
1737
|
-
const res = await app.request(
|
|
1738
|
-
|
|
1739
|
-
|
|
1782
|
+
const res = await app.request(
|
|
1783
|
+
`/admin/agents/${SELFHOSTED_AGENT_ID}/extensions`,
|
|
1784
|
+
{
|
|
1785
|
+
headers: { Cookie: `admin_session=${cookie}` },
|
|
1786
|
+
},
|
|
1787
|
+
);
|
|
1740
1788
|
expect(res.status).toBe(200);
|
|
1741
1789
|
const html = await res.text();
|
|
1742
1790
|
// Tools card should appear for self-hosted agents
|
|
@@ -1773,7 +1821,9 @@ describe("admin UI — cron job mutation routes", () => {
|
|
|
1773
1821
|
},
|
|
1774
1822
|
});
|
|
1775
1823
|
expect(res.status).toBe(302);
|
|
1776
|
-
expect(res.headers.get("Location")).toBe(
|
|
1824
|
+
expect(res.headers.get("Location")).toBe(
|
|
1825
|
+
`/admin/agents/${AGENT_ID}/automation`,
|
|
1826
|
+
);
|
|
1777
1827
|
});
|
|
1778
1828
|
|
|
1779
1829
|
it("POST /admin/agents/:id/crons with missing schedule redirects with error", async () => {
|
|
@@ -1890,7 +1940,9 @@ describe("admin UI — cron job mutation routes", () => {
|
|
|
1890
1940
|
},
|
|
1891
1941
|
);
|
|
1892
1942
|
expect(res.status).toBe(302);
|
|
1893
|
-
expect(res.headers.get("Location")).toBe(
|
|
1943
|
+
expect(res.headers.get("Location")).toBe(
|
|
1944
|
+
`/admin/agents/${AGENT_ID}/automation`,
|
|
1945
|
+
);
|
|
1894
1946
|
expect(capturedInput?.user).toBe("U999");
|
|
1895
1947
|
expect(capturedInput?.silent).toBe(false);
|
|
1896
1948
|
expect(capturedInput?.preCheck).toBe("shipwright:check-dev-task.ts");
|
|
@@ -1982,7 +2034,9 @@ describe("admin UI — cron job mutation routes", () => {
|
|
|
1982
2034
|
},
|
|
1983
2035
|
);
|
|
1984
2036
|
expect(res.status).toBe(302);
|
|
1985
|
-
expect(res.headers.get("Location")).toBe(
|
|
2037
|
+
expect(res.headers.get("Location")).toBe(
|
|
2038
|
+
`/admin/agents/${AGENT_ID}/automation`,
|
|
2039
|
+
);
|
|
1986
2040
|
});
|
|
1987
2041
|
|
|
1988
2042
|
it("POST /admin/agents/:id/crons/:cronId/delete redirects with error for system crons", async () => {
|
|
@@ -2022,7 +2076,9 @@ describe("admin UI — cron job mutation routes", () => {
|
|
|
2022
2076
|
},
|
|
2023
2077
|
);
|
|
2024
2078
|
expect(res.status).toBe(302);
|
|
2025
|
-
expect(res.headers.get("Location")).toBe(
|
|
2079
|
+
expect(res.headers.get("Location")).toBe(
|
|
2080
|
+
`/admin/agents/${AGENT_ID}/automation`,
|
|
2081
|
+
);
|
|
2026
2082
|
});
|
|
2027
2083
|
});
|
|
2028
2084
|
|
|
@@ -2047,7 +2103,9 @@ describe("admin UI — tool mutation routes", () => {
|
|
|
2047
2103
|
},
|
|
2048
2104
|
});
|
|
2049
2105
|
expect(res.status).toBe(302);
|
|
2050
|
-
expect(res.headers.get("Location")).toBe(
|
|
2106
|
+
expect(res.headers.get("Location")).toBe(
|
|
2107
|
+
`/admin/agents/${AGENT_ID}/extensions`,
|
|
2108
|
+
);
|
|
2051
2109
|
});
|
|
2052
2110
|
|
|
2053
2111
|
it("POST /admin/agents/:id/tools with missing pattern redirects with error", async () => {
|
|
@@ -2063,7 +2121,7 @@ describe("admin UI — tool mutation routes", () => {
|
|
|
2063
2121
|
});
|
|
2064
2122
|
expect(res.status).toBe(302);
|
|
2065
2123
|
expect(res.headers.get("Location")).toBe(
|
|
2066
|
-
`/admin/agents/${AGENT_ID}?error=missing_fields`,
|
|
2124
|
+
`/admin/agents/${AGENT_ID}/extensions?error=missing_fields`,
|
|
2067
2125
|
);
|
|
2068
2126
|
});
|
|
2069
2127
|
|
|
@@ -2077,7 +2135,9 @@ describe("admin UI — tool mutation routes", () => {
|
|
|
2077
2135
|
},
|
|
2078
2136
|
);
|
|
2079
2137
|
expect(res.status).toBe(302);
|
|
2080
|
-
expect(res.headers.get("Location")).toBe(
|
|
2138
|
+
expect(res.headers.get("Location")).toBe(
|
|
2139
|
+
`/admin/agents/${AGENT_ID}/extensions`,
|
|
2140
|
+
);
|
|
2081
2141
|
});
|
|
2082
2142
|
|
|
2083
2143
|
it("POST /admin/agents/:id/tools/:toolId/toggle redirects to agent detail", async () => {
|
|
@@ -2095,7 +2155,9 @@ describe("admin UI — tool mutation routes", () => {
|
|
|
2095
2155
|
},
|
|
2096
2156
|
);
|
|
2097
2157
|
expect(res.status).toBe(302);
|
|
2098
|
-
expect(res.headers.get("Location")).toBe(
|
|
2158
|
+
expect(res.headers.get("Location")).toBe(
|
|
2159
|
+
`/admin/agents/${AGENT_ID}/extensions`,
|
|
2160
|
+
);
|
|
2099
2161
|
});
|
|
2100
2162
|
});
|
|
2101
2163
|
|
|
@@ -2150,7 +2212,7 @@ describe("admin UI — owner and Anthropic identity section (PAI-2.5)", () => {
|
|
|
2150
2212
|
anthropicFederationRuleId: "fdrl_01XYZ",
|
|
2151
2213
|
}),
|
|
2152
2214
|
);
|
|
2153
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
2215
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
2154
2216
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
2155
2217
|
});
|
|
2156
2218
|
expect(res.status).toBe(200);
|
|
@@ -2175,7 +2237,7 @@ describe("admin UI — owner and Anthropic identity section (PAI-2.5)", () => {
|
|
|
2175
2237
|
anthropicIdentityName: "<img src=x onerror=alert(1)>",
|
|
2176
2238
|
}),
|
|
2177
2239
|
);
|
|
2178
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
2240
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
2179
2241
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
2180
2242
|
});
|
|
2181
2243
|
expect(res.status).toBe(200);
|
|
@@ -2188,7 +2250,7 @@ describe("admin UI — owner and Anthropic identity section (PAI-2.5)", () => {
|
|
|
2188
2250
|
|
|
2189
2251
|
it("GET /admin/agents/:id renders an em dash placeholder for each unset identity field", async () => {
|
|
2190
2252
|
const app = createAdminUIApp(identityDeps({}));
|
|
2191
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
2253
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
2192
2254
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
2193
2255
|
});
|
|
2194
2256
|
expect(res.status).toBe(200);
|
|
@@ -2211,7 +2273,7 @@ describe("admin UI — agent policy fields", () => {
|
|
|
2211
2273
|
|
|
2212
2274
|
it("GET /admin/agents/:id renders the Agent Policy card with default field values", async () => {
|
|
2213
2275
|
const app = createAdminUIApp(makeMockDeps());
|
|
2214
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
2276
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/configuration`, {
|
|
2215
2277
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
2216
2278
|
});
|
|
2217
2279
|
expect(res.status).toBe(200);
|
|
@@ -2274,7 +2336,7 @@ describe("admin UI — agent policy fields", () => {
|
|
|
2274
2336
|
},
|
|
2275
2337
|
}),
|
|
2276
2338
|
);
|
|
2277
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
2339
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/configuration`, {
|
|
2278
2340
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
2279
2341
|
});
|
|
2280
2342
|
expect(res.status).toBe(200);
|
|
@@ -2313,7 +2375,7 @@ describe("admin UI — agent policy fields", () => {
|
|
|
2313
2375
|
// test below that exercises the actual two-entries-same-key submission
|
|
2314
2376
|
// order a browser produces.
|
|
2315
2377
|
const app = createAdminUIApp(makeMockDeps());
|
|
2316
|
-
const res = await app.request(`/admin/agents/${AGENT_ID}`, {
|
|
2378
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}/configuration`, {
|
|
2317
2379
|
headers: { Cookie: `admin_session=${cookie}` },
|
|
2318
2380
|
});
|
|
2319
2381
|
const html = await res.text();
|
|
@@ -2709,6 +2771,10 @@ describe("admin UI — token mutation routes", () => {
|
|
|
2709
2771
|
expect(res.status).toBe(200);
|
|
2710
2772
|
const responseHtml = await res.text();
|
|
2711
2773
|
expect(responseHtml).toContain("sw_raw123456");
|
|
2774
|
+
// The new-token page is the Access section: its nav entry is active.
|
|
2775
|
+
expect(responseHtml).toContain(
|
|
2776
|
+
`<a class="settings-nav-link" href="/admin/agents/${AGENT_ID}/access" aria-current="page"`,
|
|
2777
|
+
);
|
|
2712
2778
|
});
|
|
2713
2779
|
|
|
2714
2780
|
it("POST /admin/agents/:id/tokens/:tokenId/revoke redirects to agent detail", async () => {
|
|
@@ -2721,7 +2787,9 @@ describe("admin UI — token mutation routes", () => {
|
|
|
2721
2787
|
},
|
|
2722
2788
|
);
|
|
2723
2789
|
expect(res.status).toBe(302);
|
|
2724
|
-
expect(res.headers.get("Location")).toBe(
|
|
2790
|
+
expect(res.headers.get("Location")).toBe(
|
|
2791
|
+
`/admin/agents/${AGENT_ID}/access`,
|
|
2792
|
+
);
|
|
2725
2793
|
});
|
|
2726
2794
|
});
|
|
2727
2795
|
|
|
@@ -3602,6 +3670,9 @@ describe("admin UI — member management routes", () => {
|
|
|
3602
3670
|
},
|
|
3603
3671
|
});
|
|
3604
3672
|
expect(res.status).toBe(302);
|
|
3673
|
+
expect(res.headers.get("Location")).toBe(
|
|
3674
|
+
`/admin/agents/${AGENT_ID}/access`,
|
|
3675
|
+
);
|
|
3605
3676
|
expect(created).not.toBeNull();
|
|
3606
3677
|
expect((created as { agentId: string; email: string } | null)?.email).toBe(
|
|
3607
3678
|
"newmember@example.com",
|
|
@@ -3694,6 +3765,9 @@ describe("admin UI — member management routes", () => {
|
|
|
3694
3765
|
},
|
|
3695
3766
|
});
|
|
3696
3767
|
expect(res.status).toBe(302);
|
|
3768
|
+
expect(res.headers.get("Location")).toBe(
|
|
3769
|
+
`/admin/agents/${AGENT_ID}/access`,
|
|
3770
|
+
);
|
|
3697
3771
|
expect(deletedId as string | null).toBe("m1");
|
|
3698
3772
|
});
|
|
3699
3773
|
|
|
@@ -3871,7 +3945,9 @@ describe("admin UI — plugin add/remove (PUI-1.2)", () => {
|
|
|
3871
3945
|
form({ spec: " foo@mkt " }, await makeSessionCookie()),
|
|
3872
3946
|
);
|
|
3873
3947
|
expect(res.status).toBe(302);
|
|
3874
|
-
expect(res.headers.get("location")).toBe(
|
|
3948
|
+
expect(res.headers.get("location")).toBe(
|
|
3949
|
+
`/admin/agents/${AGENT_ID}/extensions`,
|
|
3950
|
+
);
|
|
3875
3951
|
expect(calls).toEqual([[AGENT_ID, "foo@mkt"]]);
|
|
3876
3952
|
});
|
|
3877
3953
|
|
|
@@ -3919,7 +3995,9 @@ describe("admin UI — plugin add/remove (PUI-1.2)", () => {
|
|
|
3919
3995
|
`/admin/agents/${AGENT_ID}/plugins`,
|
|
3920
3996
|
form({ spec: "foo@bar" }, await makeSessionCookie()),
|
|
3921
3997
|
);
|
|
3922
|
-
expect(res.headers.get("location")).toContain(
|
|
3998
|
+
expect(res.headers.get("location")).toContain(
|
|
3999
|
+
`/admin/agents/${AGENT_ID}/extensions?error=bad%20plugin%20spec`,
|
|
4000
|
+
);
|
|
3923
4001
|
});
|
|
3924
4002
|
|
|
3925
4003
|
it("remove calls the service with pluginId", async () => {
|
|
@@ -3932,6 +4010,9 @@ describe("admin UI — plugin add/remove (PUI-1.2)", () => {
|
|
|
3932
4010
|
form({ pluginId: "pl1" }, await makeSessionCookie()),
|
|
3933
4011
|
);
|
|
3934
4012
|
expect(res.status).toBe(302);
|
|
4013
|
+
expect(res.headers.get("location")).toBe(
|
|
4014
|
+
`/admin/agents/${AGENT_ID}/extensions`,
|
|
4015
|
+
);
|
|
3935
4016
|
expect(removed).toEqual(["pl1"]);
|
|
3936
4017
|
});
|
|
3937
4018
|
|
|
@@ -5527,7 +5608,7 @@ describe("admin UI — GET /admin/agents/:id/connect-github/add-org", () => {
|
|
|
5527
5608
|
);
|
|
5528
5609
|
expect(res.status).toBe(302);
|
|
5529
5610
|
const location = res.headers.get("location") ?? "";
|
|
5530
|
-
expect(location).toContain(`/admin/agents/${AGENT_ID}?error=`);
|
|
5611
|
+
expect(location).toContain(`/admin/agents/${AGENT_ID}/access?error=`);
|
|
5531
5612
|
expect(location).not.toContain("github.com/apps");
|
|
5532
5613
|
});
|
|
5533
5614
|
|
|
@@ -5538,7 +5619,7 @@ describe("admin UI — GET /admin/agents/:id/connect-github/add-org", () => {
|
|
|
5538
5619
|
);
|
|
5539
5620
|
expect(res.status).toBe(302);
|
|
5540
5621
|
expect(res.headers.get("location")).toContain(
|
|
5541
|
-
`/admin/agents/${AGENT_ID}?error=`,
|
|
5622
|
+
`/admin/agents/${AGENT_ID}/access?error=`,
|
|
5542
5623
|
);
|
|
5543
5624
|
});
|
|
5544
5625
|
});
|
|
@@ -6062,7 +6143,7 @@ describe("admin UI — repos mutation routes", () => {
|
|
|
6062
6143
|
});
|
|
6063
6144
|
expect(res.status).toBe(302);
|
|
6064
6145
|
expect(res.headers.get("Location")).toBe(
|
|
6065
|
-
`/admin/agents/${AGENT_ID}?error=invalid_repo_format`,
|
|
6146
|
+
`/admin/agents/${AGENT_ID}/configuration?error=invalid_repo_format`,
|
|
6066
6147
|
);
|
|
6067
6148
|
});
|
|
6068
6149
|
|
|
@@ -6143,7 +6224,9 @@ describe("admin UI — repos mutation routes", () => {
|
|
|
6143
6224
|
},
|
|
6144
6225
|
});
|
|
6145
6226
|
expect(res.status).toBe(302);
|
|
6146
|
-
expect(res.headers.get("Location")).toBe(
|
|
6227
|
+
expect(res.headers.get("Location")).toBe(
|
|
6228
|
+
`/admin/agents/${AGENT_ID}/configuration`,
|
|
6229
|
+
);
|
|
6147
6230
|
});
|
|
6148
6231
|
|
|
6149
6232
|
it("POST /admin/agents/:id/repos/add deduplicates — does not add the same repo twice", async () => {
|
|
@@ -6213,7 +6296,9 @@ describe("admin UI — repos mutation routes", () => {
|
|
|
6213
6296
|
},
|
|
6214
6297
|
});
|
|
6215
6298
|
expect(res.status).toBe(302);
|
|
6216
|
-
expect(res.headers.get("Location")).toBe(
|
|
6299
|
+
expect(res.headers.get("Location")).toBe(
|
|
6300
|
+
`/admin/agents/${AGENT_ID}/configuration`,
|
|
6301
|
+
);
|
|
6217
6302
|
});
|
|
6218
6303
|
});
|
|
6219
6304
|
|
|
@@ -6263,7 +6348,7 @@ describe("admin UI — author allowlist mutation routes", () => {
|
|
|
6263
6348
|
);
|
|
6264
6349
|
expect(res.status).toBe(302);
|
|
6265
6350
|
expect(res.headers.get("Location")).toBe(
|
|
6266
|
-
`/admin/agents/${AGENT_ID}?error=invalid_author_allowlist_format`,
|
|
6351
|
+
`/admin/agents/${AGENT_ID}/access?error=invalid_author_allowlist_format`,
|
|
6267
6352
|
);
|
|
6268
6353
|
});
|
|
6269
6354
|
|
|
@@ -6304,7 +6389,9 @@ describe("admin UI — author allowlist mutation routes", () => {
|
|
|
6304
6389
|
},
|
|
6305
6390
|
);
|
|
6306
6391
|
expect(res.status).toBe(302);
|
|
6307
|
-
expect(res.headers.get("Location")).toBe(
|
|
6392
|
+
expect(res.headers.get("Location")).toBe(
|
|
6393
|
+
`/admin/agents/${AGENT_ID}/access`,
|
|
6394
|
+
);
|
|
6308
6395
|
});
|
|
6309
6396
|
|
|
6310
6397
|
it("POST /admin/agents/:id/review-author-allowlist/add deduplicates — does not add the same login twice", async () => {
|
|
@@ -6437,7 +6524,9 @@ describe("admin UI — author allowlist mutation routes", () => {
|
|
|
6437
6524
|
},
|
|
6438
6525
|
);
|
|
6439
6526
|
expect(res.status).toBe(302);
|
|
6440
|
-
expect(res.headers.get("Location")).toBe(
|
|
6527
|
+
expect(res.headers.get("Location")).toBe(
|
|
6528
|
+
`/admin/agents/${AGENT_ID}/access`,
|
|
6529
|
+
);
|
|
6441
6530
|
});
|
|
6442
6531
|
|
|
6443
6532
|
it("old route path /admin/agents/:id/author-allowlist/add no longer exists", async () => {
|
|
@@ -6521,7 +6610,7 @@ describe("admin UI — patch author allowlist mutation routes", () => {
|
|
|
6521
6610
|
);
|
|
6522
6611
|
expect(res.status).toBe(302);
|
|
6523
6612
|
expect(res.headers.get("Location")).toBe(
|
|
6524
|
-
`/admin/agents/${AGENT_ID}?error=invalid_author_allowlist_format`,
|
|
6613
|
+
`/admin/agents/${AGENT_ID}/access?error=invalid_author_allowlist_format`,
|
|
6525
6614
|
);
|
|
6526
6615
|
});
|
|
6527
6616
|
|
|
@@ -6562,7 +6651,9 @@ describe("admin UI — patch author allowlist mutation routes", () => {
|
|
|
6562
6651
|
},
|
|
6563
6652
|
);
|
|
6564
6653
|
expect(res.status).toBe(302);
|
|
6565
|
-
expect(res.headers.get("Location")).toBe(
|
|
6654
|
+
expect(res.headers.get("Location")).toBe(
|
|
6655
|
+
`/admin/agents/${AGENT_ID}/access`,
|
|
6656
|
+
);
|
|
6566
6657
|
});
|
|
6567
6658
|
|
|
6568
6659
|
it("POST /admin/agents/:id/patch-author-allowlist/add deduplicates — does not add the same login twice", async () => {
|
|
@@ -6695,7 +6786,9 @@ describe("admin UI — patch author allowlist mutation routes", () => {
|
|
|
6695
6786
|
},
|
|
6696
6787
|
);
|
|
6697
6788
|
expect(res.status).toBe(302);
|
|
6698
|
-
expect(res.headers.get("Location")).toBe(
|
|
6789
|
+
expect(res.headers.get("Location")).toBe(
|
|
6790
|
+
`/admin/agents/${AGENT_ID}/access`,
|
|
6791
|
+
);
|
|
6699
6792
|
});
|
|
6700
6793
|
|
|
6701
6794
|
it("POST /admin/agents/:id/patch-author-allowlist/delete removes the login from patchAuthorAllowlist", async () => {
|
|
@@ -6844,7 +6937,7 @@ describe("admin UI — Slack access settings route (restrictSlackToMembers)", ()
|
|
|
6844
6937
|
});
|
|
6845
6938
|
expect(res.status).toBe(302);
|
|
6846
6939
|
expect(res.headers.get("Location")).toBe(
|
|
6847
|
-
`/admin/agents/${AGENT_ID}?warning=restrict_slack_no_members`,
|
|
6940
|
+
`/admin/agents/${AGENT_ID}/access?warning=restrict_slack_no_members`,
|
|
6848
6941
|
);
|
|
6849
6942
|
});
|
|
6850
6943
|
|
|
@@ -6892,7 +6985,9 @@ describe("admin UI — Slack access settings route (restrictSlackToMembers)", ()
|
|
|
6892
6985
|
},
|
|
6893
6986
|
});
|
|
6894
6987
|
expect(res.status).toBe(302);
|
|
6895
|
-
expect(res.headers.get("Location")).toBe(
|
|
6988
|
+
expect(res.headers.get("Location")).toBe(
|
|
6989
|
+
`/admin/agents/${AGENT_ID}/access`,
|
|
6990
|
+
);
|
|
6896
6991
|
});
|
|
6897
6992
|
|
|
6898
6993
|
it("POST /admin/agents/:id/settings with restrictSlackToMembers:false never redirects with a warning, even with zero members", async () => {
|
|
@@ -6912,7 +7007,9 @@ describe("admin UI — Slack access settings route (restrictSlackToMembers)", ()
|
|
|
6912
7007
|
},
|
|
6913
7008
|
});
|
|
6914
7009
|
expect(res.status).toBe(302);
|
|
6915
|
-
expect(res.headers.get("Location")).toBe(
|
|
7010
|
+
expect(res.headers.get("Location")).toBe(
|
|
7011
|
+
`/admin/agents/${AGENT_ID}/configuration`,
|
|
7012
|
+
);
|
|
6916
7013
|
});
|
|
6917
7014
|
|
|
6918
7015
|
it("GET /admin/agents/:id with warning=restrict_slack_no_members renders a warning banner", async () => {
|
|
@@ -7698,11 +7795,14 @@ describe("admin UI — self-serve agent management (SSP-4.3)", () => {
|
|
|
7698
7795
|
callerScopeResolver: scopedTo([AGENT_ID]),
|
|
7699
7796
|
}),
|
|
7700
7797
|
);
|
|
7701
|
-
const
|
|
7702
|
-
|
|
7798
|
+
const headers = { Cookie: `admin_session=${cookie}` };
|
|
7799
|
+
const res = await app.request(`/admin/agents/${AGENT_ID}`, { headers });
|
|
7800
|
+
const accessRes = await app.request(`/admin/agents/${AGENT_ID}/access`, {
|
|
7801
|
+
headers,
|
|
7703
7802
|
});
|
|
7704
7803
|
expect(res.status).toBe(200);
|
|
7705
|
-
|
|
7804
|
+
expect(accessRes.status).toBe(200);
|
|
7805
|
+
const html = `${await res.text()}${await accessRes.text()}`;
|
|
7706
7806
|
expect(html.includes("Danger Zone")).toBe(shown);
|
|
7707
7807
|
expect(html.includes('<div class="card-title">Slack access</div>')).toBe(
|
|
7708
7808
|
shown,
|
|
@@ -7754,7 +7854,9 @@ describe("admin UI — Anthropic federation credential guards (WIF-2.1)", () =>
|
|
|
7754
7854
|
});
|
|
7755
7855
|
expect(res.status).toBe(302);
|
|
7756
7856
|
const location = res.headers.get("Location") ?? "";
|
|
7757
|
-
expect(location).toContain(
|
|
7857
|
+
expect(location).toContain(
|
|
7858
|
+
`/admin/agents/${FED_COOKIE_AGENT}/configuration?error=`,
|
|
7859
|
+
);
|
|
7758
7860
|
expect(decodeURIComponent(location)).toContain(
|
|
7759
7861
|
"anthropic_credentials_blocked_federation",
|
|
7760
7862
|
);
|