Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Stabilize setup wizard release gate

rcourtmane78b14f51624
diff --git a/frontend-modern/src/components/SetupWizard/__tests__/WelcomeStep.test.tsx b/frontend-modern/src/components/SetupWizard/__tests__/WelcomeStep.test.tsx
index a656798b08..c7f69a794d 100644
--- a/frontend-modern/src/components/SetupWizard/__tests__/WelcomeStep.test.tsx
+++ b/frontend-modern/src/components/SetupWizard/__tests__/WelcomeStep.test.tsx
@@ -113,6 +113,45 @@ describe('WelcomeStep', () => {
).toBeInTheDocument();
});
+ it('validates raw bootstrap tokens with an unauthenticated JSON request', async () => {
+ const rawToken = '0123456789abcdef0123456789abcdef0123456789abcdef';
+ const onNext = vi.fn();
+ const setIsUnlocked = vi.fn();
+
+ apiFetchMock.mockResolvedValue({ ok: true });
+
+ render(() => (
+ <WelcomeStep
+ onNext={onNext}
+ bootstrapToken={` ${rawToken} `}
+ setBootstrapToken={vi.fn()}
+ isUnlocked={false}
+ setIsUnlocked={setIsUnlocked}
+ />
+ ));
+
+ await waitFor(() => {
+ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/security/status');
+ });
+
+ fireEvent.click(screen.getByRole('button', { name: 'Verify bootstrap token →' }));
+
+ await waitFor(() => {
+ expect(apiFetchMock).toHaveBeenCalledWith('/api/security/validate-bootstrap-token', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ skipAuth: true,
+ skipOrgContext: true,
+ body: JSON.stringify({ token: rawToken }),
+ });
+ });
+ expect(setIsUnlocked).toHaveBeenCalledWith(true);
+ expect(onNext).toHaveBeenCalledTimes(1);
+ expect(showErrorMock).not.toHaveBeenCalled();
+ });
+
it('blocks encrypted bootstrap snapshot pastes with a specific error', async () => {
const onNext = vi.fn();
diff --git a/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx b/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx
index a57497d4a5..9f18689297 100644
--- a/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx
+++ b/frontend-modern/src/components/SetupWizard/steps/WelcomeStep.tsx
@@ -94,6 +94,11 @@ export const WelcomeStep: Component<WelcomeStepProps> = (props) => {
try {
const response = await apiFetch('/api/security/validate-bootstrap-token', {
method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ skipAuth: true,
+ skipOrgContext: true,
body: JSON.stringify({ token: trimmedToken }),
});
diff --git a/tests/integration/tests/helpers.ts b/tests/integration/tests/helpers.ts
index aa856a379e..d28d5afbbb 100644
--- a/tests/integration/tests/helpers.ts
+++ b/tests/integration/tests/helpers.ts
@@ -275,9 +275,11 @@ async function completeSetupWizard(
name: "Install Pulse Agent",
exact: true,
});
- const securePulseHeading = wizard.getByText("Secure Pulse");
- const continueButton = wizard.getByRole("button", {
- name: /verify bootstrap token|continue to setup|continue/i,
+ const securityStepHeading = wizard.getByRole("heading", {
+ name: /secure pulse|create your admin account/i,
+ });
+ const unlockButton = wizard.getByRole("button", {
+ name: /verify bootstrap token|continue to setup|continue to security/i,
});
const finishButton = wizard.getByRole("button", {
name: /open infrastructure|skip for now/i,
@@ -299,19 +301,26 @@ async function completeSetupWizard(
};
const clickContinueIfReady = async (): Promise<boolean> => {
- if (!(await continueButton.isVisible({ timeout: 250 }).catch(() => false))) {
+ if (!(await unlockButton.isVisible({ timeout: 250 }).catch(() => false))) {
return false;
}
- if (!(await continueButton.isEnabled().catch(() => false))) {
+ if (!(await unlockButton.isEnabled().catch(() => false))) {
+ if (
+ !(await bootstrapTokenInput
+ .isVisible({ timeout: 250 })
+ .catch(() => false))
+ ) {
+ return false;
+ }
if ((await bootstrapTokenInput.inputValue().catch(() => "")) !== bootstrapToken) {
await enterBootstrapToken();
}
}
- if (!(await continueButton.isEnabled().catch(() => false))) {
+ if (!(await unlockButton.isEnabled().catch(() => false))) {
return false;
}
try {
- await continueButton.click({ timeout: 1_000 });
+ await unlockButton.click({ timeout: 1_000 });
return true;
} catch {
return false;
@@ -337,7 +346,7 @@ async function completeSetupWizard(
return "completion";
}
if (
- await securePulseHeading.isVisible({ timeout: 100 }).catch(() => false)
+ await securityStepHeading.isVisible({ timeout: 100 }).catch(() => false)
) {
return "security";
}