fix(agent): 自愈 HTTPS 直连地址并发布 v1.4.3
CI / verify (push) Canceled after 0s

This commit is contained in:
2026-09-28 14:30:35 +08:00
parent 4a29bcb249
commit 8c07e64e87
9 changed files with 100 additions and 19 deletions
+36
View File
@@ -46,3 +46,39 @@ func TestPinTLSConfigVerification(t *testing.T) {
t.Fatal("错误 pin 应校验失败")
}
}
func TestAgentHTTPSBaseURL(t *testing.T) {
cases := []struct {
name string
server Server
want string
}{
{
name: "旧隧道地址按监听端口重建",
server: Server{AgentURL: "http://127.0.0.1:17701", SSHHost: "agent.example.com", AgentListenAddr: "0.0.0.0:7443"},
want: "https://agent.example.com:7443",
},
{
name: "已是 HTTPS 地址保持不变",
server: Server{AgentURL: "https://agent.example.com:8443", SSHHost: "agent.example.com", AgentListenAddr: "0.0.0.0:7443"},
want: "https://agent.example.com:8443",
},
{
name: "监听地址缺少端口时使用默认端口",
server: Server{AgentURL: "http://127.0.0.1:17701", SSHHost: "agent.example.com"},
want: "https://agent.example.com:7443",
},
{
name: "缺少 SSH 主机时保留原地址",
server: Server{AgentURL: "http://127.0.0.1:17701"},
want: "http://127.0.0.1:17701",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if got := agentHTTPSBaseURL(tc.server); got != tc.want {
t.Fatalf("agentHTTPSBaseURL() = %q, 期望 %q", got, tc.want)
}
})
}
}