Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Stub slow syscheck/listen-port probes in agent tests, fix ai_snapshot mutex deadlock, reorder fleet clearance vs connectivity checks, and add AI control precedence plus LotlTimeline vitest coverage.
37 lines
1008 B
Go
37 lines
1008 B
Go
package client
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"crypto-miner-agent/vulnprobe"
|
|
)
|
|
|
|
func TestRunVulnLOTLProbeMockedContext(t *testing.T) {
|
|
SetPostureCollector(func() *PostureReport { return nil })
|
|
defer SetPostureCollector(nil)
|
|
SetListenPortsCollector(func() *ListenPortsReport {
|
|
return &ListenPortsReport{Ports: []ListenPort{{Port: 443, Proto: "tcp"}}}
|
|
})
|
|
defer SetListenPortsCollector(nil)
|
|
|
|
origProbe := vulnprobeProbeHost
|
|
vulnprobeProbeHost = func(_ map[int]bool, _ string) vulnprobe.HostContext {
|
|
return vulnprobe.HostContext{
|
|
Platform: "windows",
|
|
ExchangeInstalled: true,
|
|
LastPatchDays: 150,
|
|
ListeningPorts: map[int]bool{443: true},
|
|
}
|
|
}
|
|
defer func() { vulnprobeProbeHost = origProbe }()
|
|
|
|
report := RunVulnLOTLProbe()
|
|
if report == nil || len(report.Findings) == 0 {
|
|
t.Fatal("expected vuln findings from mocked probe")
|
|
}
|
|
cached := LastVulnScan()
|
|
if cached == nil || cached.RiskScore != report.RiskScore {
|
|
t.Fatalf("cache mismatch: %+v vs %+v", cached, report)
|
|
}
|
|
}
|