Files
fscan/webscan/lib/client_test.go
T
ZacharyZcR 5ad914a1bb feat: 统一服务缓存 + 指纹驱动插件匹配
将 webServiceCache 扩展为通用 serviceCache,所有指纹识别结果
统一缓存,插件匹配时端口不命中则回退到服务名称匹配。

删除多余的 service_cache.go,复用已有的 ServiceInfo 体系。
补充 nil 防御、Explicit 标记、大量单元/集成/回归测试。
2026-06-14 22:23:47 +08:00

25 lines
680 B
Go

package lib
import "testing"
func TestNormalizeHTTPProxyURL(t *testing.T) {
tests := []struct {
name string
in string
want string
}{
{name: "port shortcut", in: "8080", want: "http://127.0.0.1:8080"},
{name: "ipv4 host port", in: "127.0.0.1:8080", want: "http://127.0.0.1:8080"},
{name: "hostname port", in: "proxy.local:8080", want: "http://proxy.local:8080"},
{name: "bracketed ipv6 port", in: "[::1]:8080", want: "http://[::1]:8080"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := normalizeHTTPProxyURL(tt.in); got != tt.want {
t.Fatalf("normalizeHTTPProxyURL(%q) = %q, want %q", tt.in, got, tt.want)
}
})
}
}