From 5bd13b80254c9db16a35082c8b9cd53b6b3705eb Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 16 Nov 2026 12:13:44 +0800 Subject: [PATCH] gui: TestProviderSaveClientCert expects the system's separator (#5928) On Windows the editor shows a saved certificate path as "~\Downloads\magpie-laptop\client.pem", and the test wanted the "/" form, so it was red on Windows since efb75ad1f (11-10). Windows CI only compiles the tests, and 023a56373 still listed it today. The product is right: provider.CertPath reads "~\" as the home folder, so the shown value saves back to the same file. The test now wants the system's separator and checks that read-back. Run: - win-run (xiaomi-gpu, Windows 11) go test -count=1 -run TestProviderSaveClientCert ./internal/gui: ok (red at main before, "shown true \"~\\Downloads\\magpie-laptop\\client.pem\"", #5928). - mote: go test -count=1 -run 'TestProviderSaveClientCert|TestMTLS' ./internal/gui: ok. gofmt -l clean. Not tried: the rest of the Windows reds in #6068; test-only change, no full suite. --- internal/gui/mtls_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/gui/mtls_test.go b/internal/gui/mtls_test.go index d28f3545d..893a916bb 100644 --- a/internal/gui/mtls_test.go +++ b/internal/gui/mtls_test.go @@ -173,9 +173,14 @@ func TestProviderSaveClientCert(t *testing.T) { t.Fatalf("saved %q %q", p.ClientCert, p.ServerCA) } info := providerInfo(*p, nil) - if !info.TakesClientCert || info.ClientCert != "~/Downloads/magpie-laptop/client.pem" { + // shown with the system's separator: "~\Downloads\…" on Windows, + // which CertPath reads back the same (#5928) + if want := "~" + string(filepath.Separator) + filepath.Join("Downloads", "magpie-laptop", "client.pem"); !info.TakesClientCert || info.ClientCert != want { t.Fatalf("shown %v %q", info.TakesClientCert, info.ClientCert) } + if back, err := provider.CertPath(info.ClientCert); err != nil || back != p.ClientCert { + t.Fatalf("shown %q reads back as %q (%v), saved %q", info.ClientCert, back, err, p.ClientCert) + } if code, out := post(base + `,"from":"home","models":[],"headers":{}}`); code != 200 { t.Fatalf("%d %s", code, out) }