fix web result protocol output (#577)
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled

This commit is contained in:
ZacharyZcR
2026-05-11 18:37:40 +08:00
parent 5a8583a195
commit 265e855fc3
5 changed files with 84 additions and 15 deletions
+21
View File
@@ -7,6 +7,7 @@ import (
"testing"
"github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
)
/*
@@ -35,6 +36,26 @@ scanner_test.go - Scanner核心逻辑测试
// 核心逻辑测试:策略选择
// =============================================================================
func TestWebResultSerializerPreservesDetectedProtocol(t *testing.T) {
serializer := resultSerializers[plugins.ResultTypeWeb]
details := map[string]interface{}{}
result := &plugins.Result{
Type: plugins.ResultTypeWeb,
Success: true,
Output: "https://192.168.1.1:8443",
}
info := &common.HostInfo{Host: "192.168.1.1", Port: 8443}
serializer.fillDetail(result, info, details)
if details["protocol"] != "https" {
t.Fatalf("protocol = %v, 期望 https", details["protocol"])
}
if details["url"] != "https://192.168.1.1:8443" {
t.Fatalf("url = %v, 期望检测出的URL", details["url"])
}
}
// TestSelectStrategy 测试策略选择逻辑
func TestSelectStrategy(t *testing.T) {
// 保存原始配置