mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-07 08:54:42 +00:00
Recognize Android certificate-path validation failures before the generic not-found classification, so Direct connection no longer tells users to debug DNS for an untrusted certificate. Keep the existing TLS copy and technical details. Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { DaemonConnectionTestError } from "@/utils/test-daemon-connection";
|
|
import { buildConnectionFailureCopy } from "./connection-failure-copy";
|
|
|
|
const labels = {
|
|
hostRequired: "host required",
|
|
invalidPort: "invalid port",
|
|
invalidConnection: "invalid connection",
|
|
failedToConnect: (endpoint: string) => `Failed: ${endpoint}`,
|
|
noAdditionalDetails: (detail: string) => `No details: ${detail}`,
|
|
timedOut: "timeout",
|
|
refused: "refused",
|
|
hostNotFound: "DNS failure",
|
|
hostUnreachable: "unreachable",
|
|
tlsError: "TLS failure",
|
|
unableToConnect: "connection failure",
|
|
};
|
|
|
|
function failure(message: string) {
|
|
return buildConnectionFailureCopy({
|
|
endpoint: "tcp://example.test:443?ssl=true",
|
|
error: new DaemonConnectionTestError(message, {
|
|
reason: "transport error",
|
|
lastError: message,
|
|
}),
|
|
labels,
|
|
});
|
|
}
|
|
|
|
describe("direct connection failure copy", () => {
|
|
it("identifies Android certificate validation errors without calling them DNS failures", () => {
|
|
const message =
|
|
"java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.";
|
|
expect(failure(message)).toEqual({
|
|
title: "Failed: tcp://example.test:443?ssl=true",
|
|
detail: labels.tlsError,
|
|
raw: `transport error — ${message}`,
|
|
});
|
|
});
|
|
|
|
it.each([
|
|
["certificate not found", labels.tlsError],
|
|
["SSL handshake failed", labels.tlsError],
|
|
["TLS handshake failed", labels.tlsError],
|
|
["getaddrinfo ENOTFOUND example.test", labels.hostNotFound],
|
|
["Host not found", labels.hostNotFound],
|
|
["connect ECONNREFUSED", labels.refused],
|
|
["connection timed out", labels.timedOut],
|
|
["EHOSTUNREACH", labels.hostUnreachable],
|
|
["unexpected transport failure", labels.unableToConnect],
|
|
])("classifies %s", (message, expected) => {
|
|
expect(failure(message).detail).toBe(expected);
|
|
});
|
|
|
|
it("preserves authentication failures and their technical details", () => {
|
|
const message = "Invalid daemon password";
|
|
expect(
|
|
buildConnectionFailureCopy({
|
|
endpoint: "example.test:6767",
|
|
error: new DaemonConnectionTestError(message, {
|
|
reason: message,
|
|
lastError: message,
|
|
authFailureReason: "incorrect_password",
|
|
}),
|
|
labels,
|
|
}),
|
|
).toMatchObject({ detail: message, raw: message });
|
|
});
|
|
});
|