Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: keep SCIM configured state across a sheet close
Danny7a9499626d4c
diff --git a/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsx b/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsxindex e710ca4d55..d74c9acc30 100644--- a/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsx+++ b/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsx@@ -251,6 +251,39 @@ describe("AADSyncSheet SCIM token", () => {vi.spyOn(window, "confirm").mockRestore();});+ it("still knows a token exists after closing when the refresh failed", async () => {+ // The sheet stays mounted, and closing clears the one-time plaintext. If+ // that were the only signal, reopening after a failed refresh would offer+ // "Generate" again and skip the warning on the next click.+ mocks.rotate.mockResolvedValue({ token: "tok-first" });+ mocks.loadWorkspaceProfile.mockResolvedValue(undefined);+ mocks.tokenConfigured = false;++ await renderSheet();+ await act(async () => {+ buttonByText(entra("generate-token"))?.click();+ });+ await act(async () => {+ buttonByText("common.cancel")?.click();+ });++ // Reopened: plaintext gone, but the action must still be a regeneration.+ await renderSheet();+ expect(tokenInput()).toBeUndefined();+ expect(buttonByText(entra("regenerate-token"))).toBeTruthy();+ expect(buttonByText(entra("generate-token"))).toBeFalsy();++ const confirmSpy = vi+ .spyOn(window, "confirm")+ .mockReturnValue(false) as unknown as { mock: { calls: unknown[] } };+ await act(async () => {+ buttonByText(entra("regenerate-token"))?.click();+ });+ expect(confirmSpy.mock.calls.length).toBe(1);+ expect(mocks.rotate).toHaveBeenCalledTimes(1);+ vi.spyOn(window, "confirm").mockRestore();+ });+it("hides the rotate control without permission", async () => {mocks.hasRotatePermission = false;await renderSheet();diff --git a/frontend/src/routes/workspace/shared/AADSyncSheet.tsx b/frontend/src/routes/workspace/shared/AADSyncSheet.tsxindex e434ad35aa..ac851fe404 100644--- a/frontend/src/routes/workspace/shared/AADSyncSheet.tsx+++ b/frontend/src/routes/workspace/shared/AADSyncSheet.tsx@@ -71,13 +71,15 @@ export function AADSyncSheet({// out of order and leave the admin copying a token the server has already// replaced. One at a time.const [rotating, setRotating] = useState(false);+ // Set on a successful rotation and deliberately NOT cleared on close, unlike+ // the plaintext above. loadWorkspaceProfile swallows its error and resolves+ // undefined, so a failed refresh leaves the store reporting no token; without+ // a fallback that survives closing, reopening would offer "Generate" again+ // and the next click would skip the regeneration warning and invalidate the+ // token the admin just copied.+ const [rotatedSinceMount, setRotatedSinceMount] = useState(false);- // A successful rotation means a token exists, whatever the profile refresh- // that follows does — loadWorkspaceProfile swallows its error and resolves- // undefined, so relying on the store alone would leave the button offering- // "Generate" after the first token was minted. The next click would then skip- // the regeneration warning and silently invalidate the token just copied.- const tokenConfigured = storedTokenConfigured || mintedToken !== "";+ const tokenConfigured = storedTokenConfigured || rotatedSinceMount;const handleClose = () => {setMintedToken("");@@ -102,6 +104,7 @@ export function AADSyncSheet({}));setMintedToken(resp.token);+ setRotatedSinceMount(true);await useAppStore.getState().loadWorkspaceProfile(true);pushNotification({module: "bytebase",