post inicial
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
//go:build live
|
||||
|
||||
// Pruebas contra servicios reales de Internet (NVD, Debian Security Tracker,
|
||||
// buscador, descargas). No se ejecutan con "go test ./...": sirven para
|
||||
// comprobar que los formatos externos no han cambiado.
|
||||
//
|
||||
// go test -tags live -run Live -v ./internal/tools
|
||||
package tools
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLiveCVELookup(t *testing.T) {
|
||||
r, _, _ := newEnv(t, netPolicy)
|
||||
res := call(t, r, "cve_lookup", map[string]any{"cve": "CVE-2024-6387"})
|
||||
t.Log(clip(res.Output, 3000))
|
||||
if i := strings.Index(res.Output, "=== Debian"); i >= 0 {
|
||||
t.Log(clip(res.Output[i:], 2500))
|
||||
}
|
||||
if !strings.Contains(res.Output, "=== Debian Security Tracker ===") || !strings.Contains(res.Output, "openssh") {
|
||||
t.Errorf("unexpected output")
|
||||
}
|
||||
if !strings.Contains(res.Summary, "nvd found: true") {
|
||||
t.Logf("NVD not available (rate limit?): %s", res.Summary)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLiveWebSearch(t *testing.T) {
|
||||
r, _, _ := newEnv(t, netPolicy)
|
||||
res := call(t, r, "web_search", map[string]any{"query": "openssh release notes", "max_results": 5})
|
||||
t.Log(res.Output)
|
||||
if !res.OK {
|
||||
t.Logf("search provider unavailable from this network: %s", res.Summary)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLiveWebFetchAndDownload(t *testing.T) {
|
||||
r, _, _ := newEnv(t, netPolicy)
|
||||
res := call(t, r, "web_fetch", map[string]any{"url": "https://www.debian.org/security/", "max_chars": 2000})
|
||||
t.Log(clip(res.Output, 2500))
|
||||
if !res.OK || !strings.Contains(res.Output, "title:") {
|
||||
t.Errorf("web_fetch failed: %s", res.Summary)
|
||||
}
|
||||
res = call(t, r, "download", map[string]any{
|
||||
"url": "https://deb.debian.org/debian/dists/trixie/Release",
|
||||
"dest": ".agent/downloads/",
|
||||
"max_bytes": 1 << 20,
|
||||
})
|
||||
t.Log(res.Output)
|
||||
if !res.OK {
|
||||
t.Errorf("download failed: %s", res.Summary)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user