feat(ssh): prompt to reset a changed host fingerprint
This commit is contained in:
1 parent
fd44331876
commit
c30fc33305
14 files changed
+418
-32
No files matched your search
@@ -168,6 +168,77 @@ describe("SshHostKeyPromptDialog web bridge", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("shows a changed host-key prompt and updates the saved fingerprint", async () => {
|
||||
await mountDialog();
|
||||
|
||||
const eventSource = MockEventSource.instances[0];
|
||||
eventSource?.emit({
|
||||
type: "prompt",
|
||||
request: {
|
||||
id: "changed-1",
|
||||
kind: "HostKeyChanged",
|
||||
host: "192.168.1.111",
|
||||
port: 22,
|
||||
key_type: "ssh-ed25519",
|
||||
fingerprint: "SHA256:new-fingerprint",
|
||||
previous_fingerprint: "SHA256:old-fingerprint",
|
||||
},
|
||||
});
|
||||
await nextTick();
|
||||
|
||||
expect(document.body.textContent).toContain("Host fingerprint has changed");
|
||||
expect(document.body.textContent).toContain("new-fingerprint");
|
||||
expect(document.body.textContent).toContain("old-fingerprint");
|
||||
expect(document.body.textContent).toContain("Saved fingerprint");
|
||||
|
||||
const buttons = [...document.body.querySelectorAll("button")].map((button) => button.textContent?.trim());
|
||||
expect(buttons).toContain("Close");
|
||||
expect(buttons).toContain("Continue");
|
||||
expect(buttons).toContain("Update and Continue");
|
||||
|
||||
const update = [...document.body.querySelectorAll<HTMLButtonElement>("button")].find((button) => button.textContent?.trim() === "Update and Continue");
|
||||
update?.click();
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(resolveSshPromptMock).toHaveBeenCalledWith({
|
||||
id: "changed-1",
|
||||
action: "accept",
|
||||
remember: true,
|
||||
secret: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("continues a changed host key for this session only", async () => {
|
||||
await mountDialog();
|
||||
|
||||
MockEventSource.instances[0]?.emit({
|
||||
type: "prompt",
|
||||
request: {
|
||||
id: "changed-2",
|
||||
kind: "HostKeyChanged",
|
||||
host: "board.example.test",
|
||||
port: 22,
|
||||
key_type: "ssh-ed25519",
|
||||
fingerprint: "SHA256:new",
|
||||
previous_fingerprint: "SHA256:old",
|
||||
},
|
||||
});
|
||||
await nextTick();
|
||||
|
||||
const cont = [...document.body.querySelectorAll<HTMLButtonElement>("button")].find((button) => button.textContent?.trim() === "Continue");
|
||||
cont?.click();
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(resolveSshPromptMock).toHaveBeenCalledWith({
|
||||
id: "changed-2",
|
||||
action: "accept",
|
||||
remember: false,
|
||||
secret: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("clears prompts that are no longer pending after an SSE reconnect snapshot", async () => {
|
||||
await mountDialog();
|
||||
|
||||
|
||||
Reference in new issue
Block a user