Files
fscan/plugins/services/tftp_test.go
T
ZacharyZcR 8d30ee334c
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
Add native protocol service plugins
2026-05-23 15:51:50 +08:00

22 lines
595 B
Go

//go:build plugin_tftp || !plugin_selective
package services
import (
"strings"
"testing"
)
func TestTFTPReadRequestAndResponse(t *testing.T) {
req := buildTFTPReadRequest("probe")
want := []byte{0x00, 0x01, 'p', 'r', 'o', 'b', 'e', 0x00, 'o', 'c', 't', 'e', 't', 0x00}
if string(req) != string(want) {
t.Fatalf("unexpected tftp request: %#v", req)
}
banner, ok := parseTFTPResponse([]byte{0x00, 0x05, 0x00, 0x01, 'n', 'o', 't', ' ', 'f', 'o', 'u', 'n', 'd', 0x00})
if !ok || !strings.Contains(banner, "not found") {
t.Fatalf("unexpected tftp banner: %q ok=%v", banner, ok)
}
}