diff --git a/dashboard/e2e/aws-install-options.spec.ts b/dashboard/e2e/aws-install-options.spec.ts index b4aa23fd..4cc1cedf 100644 --- a/dashboard/e2e/aws-install-options.spec.ts +++ b/dashboard/e2e/aws-install-options.spec.ts @@ -175,60 +175,29 @@ async function shot(page: Page, name: string) { await page.setViewportSize({ width: 1280, height: 800 }); } -test("a permission the next release adds: Update now to add it, then it arrives with the update installing now", async ({ page }) => { - const db = await backend(page, { missing: ["logs:StopQuery"], latest: "v1.5.0" }); - await page.goto("/settings/integrations/aws/"); - const panel = page.getByTestId(`aws-perms-${INSTALL}`); - await expect(panel.getByRole("heading", { name: "1 permission arrives with the next update" })).toBeVisible(); - await expect(panel.locator("section")).toHaveAttribute("data-case", "install"); - // Needed now is only the missing permission; the optional reads are apart and collapsed. - const needed = panel.getByTestId(`aws-needed-${INSTALL}`); - await expect(needed).toContainText("logs:StopQuery"); - await expect(needed).not.toContainText("Amazon Inspector"); - const optional = panel.getByTestId(`aws-optional-${INSTALL}`); - await expect(optional).toContainText("Optional, off: 2 reads"); - await expect(optional.getByTestId("aws-optional-inspector")).toBeHidden(); - // Never "go to another page and figure it out": the update is right here. - await expect(panel.getByRole("link", { name: /Open Version and updates/ })).toHaveCount(0); - await expect(panel.getByTestId("install-needed-update")).toContainText("v1.5.0 adds it"); - await shot(page, "aws-install-update-available"); - - await panel.getByRole("button", { name: "Update now to add it" }).click(); - const press = db.calls.find((c) => c.path === "/api/system/update"); - expect(press?.body).toEqual({ accept_permissions: true }); - await expect(panel.getByRole("heading", { name: "1 permission arrives with the update installing now" })).toBeVisible(); - await expect(panel.getByTestId("install-needed-running")).toContainText("Arrives with the update to v1.5.0 installing now"); - await shot(page, "aws-install-update-running"); -}); - -test("this version already grants it: the card says exactly why and offers the fix", async ({ page }) => { - await backend(page, { - missing: ["logs:StopQuery"], - problem: { code: "install_boundary", message: "This install's permission limit doesn't allow 1 of these read-only permissions yet.", fix: "An AWS admin applies the install's access update once (Settings, System, Version, Permissions: one link to the AWS console). No version update can change the limit." }, - access: { state: "pending", link: "https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/quickcreate?stackName=coderhelm-prod-access" }, - }); - await page.goto("/settings/integrations/aws/"); - const panel = page.getByTestId(`aws-perms-${INSTALL}`); - await expect(panel.getByRole("heading", { name: "1 permission is blocked by this install's permission limit" })).toBeVisible(); - const why = panel.getByTestId("install-needed-boundary"); - await expect(why).toContainText("v1.4.0 grants it, but this install's permission limit doesn't allow 1"); - await expect(why.getByRole("link", { name: /Open the access update in AWS/ })).toHaveAttribute("href", /stackName=coderhelm-prod-access/); - await expect(panel.getByRole("button", { name: "Update now to add it" })).toHaveCount(0); - await shot(page, "aws-install-current-boundary"); -}); - -test("no newer version and nothing blocks it: what IAM says is missing, on which role, never a claim about the stack", async ({ page }) => { - await backend(page, { missing: ["logs:StopQuery"] }); - await page.goto("/settings/integrations/aws/"); - const panel = page.getByTestId(`aws-perms-${INSTALL}`); - await expect(panel.getByRole("heading", { name: "1 permission missing from this install's read role" })).toBeVisible(); - const why = panel.getByTestId("install-needed-current"); - await expect(why).toContainText("IAM's policy simulator says coderhelm-prod-ServiceRole-0a1b2c3d isn't allowed logs:StopQuery"); - await expect(why).toContainText("no newer version is out yet"); - // Nothing it didn't read: no "your stack grants it", no drift. - await expect(why).not.toContainText(/grants it, yet|drift|changed in AWS/); - await expect(why.getByRole("button", { name: "Check again" })).toBeVisible(); - await shot(page, "aws-install-missing-no-update"); +test("the install's own account: it updates with the release, and there is nothing to do", async ({ page }) => { + // Whatever is out (a newer version, none) and whatever the check says: never an action. + for (const latest of ["v1.5.0", null]) { + await backend(page, { missing: ["logs:StopQuery"], latest }); + await page.goto("/settings/integrations/aws/"); + const panel = page.getByTestId(`aws-perms-${INSTALL}`); + await expect(panel.getByRole("heading", { name: "Updates with the release" })).toBeVisible(); + await expect(panel.locator("section").first()).toHaveAttribute("data-case", "install"); + await expect(panel.getByTestId(`aws-install-reads-${INSTALL}`)).toContainText("Each version update brings it to"); + await expect(panel.getByTestId(`aws-install-reads-${INSTALL}`)).toContainText("so there is nothing to do"); + // What arrives is listed; the optional reads stay apart and collapsed. + const needed = panel.getByTestId(`aws-needed-${INSTALL}`); + await expect(needed).toContainText("logs:StopQuery"); + await expect(needed).not.toContainText("Amazon Inspector"); + await expect(panel.getByTestId(`aws-optional-${INSTALL}`)).toContainText("Optional, off: 2 reads"); + // Nothing to press and nowhere to go: no update stack, no update button, no warning. + const card = panel.locator("section").first(); + await expect(card.getByRole("button")).toHaveCount(0); + await expect(card.getByRole("link")).toHaveCount(0); + await expect(panel.getByRole("link", { name: /Update in AWS/ })).toHaveCount(0); + await expect(panel.getByRole("heading", { name: /Update needed/ })).toHaveCount(0); + await shot(page, latest ? "aws-install-updates-with-release" : "aws-install-updates-with-release-no-newer"); + } }); test("an optional read switches on the install's own stack: review of exactly what it adds, confirm, progress, result", async ({ page }) => { diff --git a/dashboard/e2e/integrations-page.spec.ts b/dashboard/e2e/integrations-page.spec.ts index 980181cd..5fdeb71e 100644 --- a/dashboard/e2e/integrations-page.spec.ts +++ b/dashboard/e2e/integrations-page.spec.ts @@ -372,7 +372,7 @@ test("an AWS role without the permissions offers the one-click stack", async ({ await expect(aws.getByRole("switch", { name: "Let agents read Airflow" })).toBeDisabled(); }); -test("a self-hosted install's own account never asks for a stack in AWS: the version update brings the permissions", async ({ page }) => { +test("a self-hosted install's own account never asks for anything: the release brings the permissions", async ({ page }) => { const list = items().map((i) => i.id === `aws-${ACCOUNT}` ? { @@ -391,8 +391,10 @@ test("a self-hosted install's own account never asks for a stack in AWS: the ver const aws = row(page, `aws-${ACCOUNT}`); await control(page, `aws-${ACCOUNT}`, `AWS account ${ACCOUNT}`).click(); const panel = aws.getByTestId(`aws-panel-${ACCOUNT}`); - await expect(panel.getByText(/read-only permissions? arrives? with the next update/)).toBeVisible(); - await expect(panel.getByRole("link", { name: "Update from the AWS page" })).toHaveAttribute("href", /\/settings\/integrations\/aws\/?#aws-account-/); + await expect(panel.getByText(/Updates with the release: 12 read-only permissions arrive with the next update/)).toBeVisible(); + await expect(panel.getByText(/^Nothing to do\./)).toBeVisible(); + // Nothing to press: no update stack, no "update from the AWS page". + await expect(panel.getByRole("link", { name: "Update from the AWS page" })).toHaveCount(0); await expect(panel.getByText("the install's own AWS account", { exact: false })).toBeVisible(); await expect(aws.getByRole("link", { name: "Update in AWS" })).toHaveCount(0); await expect(panel.getByText("CoderHelmLogReader")).toHaveCount(0); diff --git a/dashboard/src/components/aws-permissions.tsx b/dashboard/src/components/aws-permissions.tsx index 32d86332..a15db969 100644 --- a/dashboard/src/components/aws-permissions.tsx +++ b/dashboard/src/components/aws-permissions.tsx @@ -7,7 +7,7 @@ import { Callout } from "./callout"; import { CheckIcon, ExternalLinkIcon, WarningIcon, AlertCircleIcon } from "./icons"; import { buttonClass, primaryButton, secondaryButton } from "./ui"; import { Code } from "./settings/code"; -import { InstallNeededNow, OptionalReads, installHeader, useInstallStatus } from "./aws-install-options"; +import { OptionalReads, useInstallStatus } from "./aws-install-options"; // Whether each connected AWS account's read-only role has every permission // this release uses, checked live (IAM's policy simulator on the role, or one @@ -115,8 +115,8 @@ export function stateLabel(s: AccountPermissions): string { if (!v) return s.checking ? "Checking permissions" : s.error ? "Couldn't check permissions" : "Not checked yet"; if (v.status === "up_to_date") return "Permissions up to date"; if (v.status === "error") return "Can't check: Coderhelm can't take on the role"; - // The install's own account: nothing to do in AWS, its next update brings them. - if (v.install_account) return `${v.missing_count} permission${v.missing_count === 1 ? "" : "s"} ${v.missing_count === 1 ? "arrives" : "arrive"} with the next update`; + // The install's own account: the release brings them to its reader by itself. + if (v.install_account) return "Updates with the release"; return `Update needed: ${v.missing_count} new read-only permission${v.missing_count === 1 ? "" : "s"}`; } @@ -269,13 +269,47 @@ export function PermissionsPanel({ account, perms, canEdit }: { account: string; const neededGroups = v.abilities.filter((a) => !a.optional && a.missing.length > 0); const waiting = !!s.pressedAt && !v.problem; - const title = install ? installHeader(v.missing_count, status, v.problem?.code) : stateLabel(s); + + // The install's own account: each version update brings this release's + // reads to its CoderHelmLogReader (the access stack's reader update), so + // there is nothing to do here: no update stack, no button, no warning. + if (install) { + const n = v.missing_count; + return ( +
+ This install's own account. This release reads a little more from it: {n} read-only permission{n === 1 ? "" : "s"}. Each version
+ update brings {n === 1 ? "it" : "them"} to {v.role || "CoderHelmLogReader"} here by itself, so there is nothing to do. Until
+ then, Coderhelm skips what needs {n === 1 ? "it" : "them"} and keeps working with the rest.
+
+ {v.missing.map((m) => (
+
+ {m.action}
+
+ ))}
+
- {install - ? "This install's own account. This release reads a little more from it; everything stays read-only, and nothing is needed in AWS." - : `This release reads a little more from account ${v.account}. Everything stays read-only: Coderhelm can list, describe and query, never change anything.`}{" "} + {`This release reads a little more from account ${v.account}. Everything stays read-only: Coderhelm can list, describe and query, never change anything.`}{" "} Until the role has it, Coderhelm skips what needs it and keeps working with the rest.
An admin adds it from this card with the install's next version update.
- )} -An admin can update the role in one click from this page.
} - > - )} + >Nothing is needed in AWS. The AWS page updates Coderhelm in one press, and the install's own role has them once it finishes.
-- - Update from the AWS page - -
+Nothing to do. Each version update brings this release's read-only permissions to this account's read role by itself.