fix(hosts): display protocol credential usernames for non-SSH hosts (#1572)

This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-10-07 16:37:58 -05:00
1 parent bb4b345feb
commit 42c5682243
4 files changed
+88 -4

No files matched your search

@@ -1,3 +1,4 @@
import { registerHostProtocol } from "@/sidebar/host-protocols";
import {
act,
cleanup,
@@ -402,3 +403,42 @@ describe("HostItem row fields", () => {
).toBe("root@10.0.0.5");
});
});
it("uses the enabled protocol username for non-SSH hosts", () => {
const dispose = registerHostProtocol({
id: "rdp",
pluginId: "remote-desktop",
settingKey: "enableRdp",
defaultPort: 3389,
titleKey: "rdp",
icon: () => null,
});
try {
const host: Host = {
...baseHost,
enableSsh: false,
pluginSettings: { "remote-desktop": { enableRdp: true } },
protocolAuth: {
rdp: {
authType: "credential",
credentialId: 6,
username: "Administrator",
fields: {},
},
},
};
const fields = { showUsername: true, showPort: false };
expect(formatHostAddress(host, fields)).toBe("Administrator@10.0.0.5");
expect(formatHostAddress({ ...host, enableSsh: true }, fields)).toBe(
"root@10.0.0.5",
);
expect(formatHostAddress({ ...host, protocolAuth: {} }, fields)).toBe(
"10.0.0.5",
);
expect(formatHostAddress(host, { ...fields, showUsername: false })).toBe(
"10.0.0.5",
);
} finally {
dispose();
}
});