Files
AetherForge/server/internal/builder/uninstall_test.go
AetherForge 5fc601b564 feat: fleet ops, KEV scan, tunnels, beacon fallback, persistence
Extend owned-fleet control with scheduled tasks, audit log, file browser,
HTTPS beacon when WS drops, protocol tunnels, registry/autostart forge
options, KEV exposure in full sys check with Telegram alerts, and UI/tests.
2026-06-04 09:34:33 -07:00

61 lines
1.8 KiB
Go

package builder
import (
"strings"
"testing"
)
func TestGenerateUninstallScriptContainsPersistenceKey(t *testing.T) {
req := &BuildRequest{
WorkerName: "office-pc",
ProcessName: "RuntimeHelper",
StealthMode: false,
InstallBase: "localappdata",
}
script := generateUninstallScript("abc12345-uuid", req)
if !strings.Contains(script, "CryptoMiner-office-pc") {
t.Fatalf("expected normal persistence key in script, got: %s", script)
}
if !strings.Contains(script, "RuntimeHelper") {
t.Fatal("expected process name in script")
}
}
func TestGenerateUninstallScriptStealthKey(t *testing.T) {
req := &BuildRequest{
WorkerName: "office-pc",
ProcessName: "RuntimeHelper",
StealthMode: true,
}
script := generateUninstallScript("abc12345-uuid", req)
if !strings.Contains(script, "RuntimeHelper") {
t.Fatalf("expected stealth persistence key to match process name")
}
}
func TestGenerateUninstallScriptAutostartExtras(t *testing.T) {
req := &BuildRequest{WorkerName: "lab", ProcessName: "Worker", StealthMode: false}
script := generateUninstallScript("build-id", req)
for _, frag := range []string{"-Boot", "-Logon", "Programs\\Startup", ".lnk"} {
if !strings.Contains(script, frag) {
t.Fatalf("expected autostart cleanup fragment %q in script", frag)
}
}
}
func TestGenerateUninstallScriptInstallPathTokens(t *testing.T) {
req := &BuildRequest{
WorkerName: "office-pc",
ProcessName: "RuntimeHelper",
InstallBase: "localappdata",
InstallRelativePath: "CryptoMiner/{worker}-{build_short}",
}
script := generateUninstallScript("abc12345-uuid", req)
if !strings.Contains(script, "office-pc-abc12345") {
t.Fatalf("expected expanded install relative path in script, got fragment missing")
}
if !strings.Contains(script, "$env:LOCALAPPDATA") {
t.Fatal("expected LOCALAPPDATA base in script")
}
}