Files
Reims-Go/diagnostics_test.go
T
Nwflower fc284e99ab feat: complete M3.4-M3.7, M4 CI/smoke pipeline, and fix Guest Tools UTF-8 clipboard
- Fix macOS Guest Tools LaunchAgent UTF-8 encoding (__CF_USER_TEXT_ENCODING=0x08000100 + LANG/LC_ALL=en_US.UTF-8) so pbpaste/pbcopy never outputs GBK mojibake on Chinese macOS, plus server-side UTF-8 validation
- M3.4: Auto-upgrade legacy AHCI to NVMe on Exit recovery mode + one-click Upgrade to NVMe banner + Windows USB/external drive (IOCTL_STORAGE_QUERY_PROPERTY BusTypeUsb) and high-RAM diagnostics
- M3.5: One-click redacted diagnostics .zip export (host report, runtime manifest, VM detail, serial/QEMU/app logs with MAC, serial, SMC OSK, and Bearer token redaction)
- M3.6: Automatic qemu-img convert for .vmdk/.raw disk imports in CreateWizard
- M3.7: Instant CoW VM derivation (CloneVMCoW + CloneDialog) preserving golden backing image untouched
- M4.2/M4.3: Add GitHub Actions CI & candidate runtime build workflows + scripts/smoke-runtime.ps1
2026-11-28 08:50:16 -07:00

63 lines
1.7 KiB
Go

package main
import (
"archive/zip"
"io"
"path/filepath"
"strings"
"testing"
"github.com/Nwflower/reims-go/internal/driver/reims"
"github.com/Nwflower/reims-go/internal/host"
)
func TestWriteDiagnosticsZipRedactsSensitiveData(t *testing.T) {
zipPath := filepath.Join(t.TempDir(), "reports", "diag.zip")
err := writeDiagnosticsZip(zipPath, diagnosticsBundle{
HostReport: host.Report{OS: "windows", LogicalCPUs: 16, DataRootDriveType: "fixed"},
VMDetail: &reims.VMDetail{
Name: "macos-tahoe",
NetworkSummary: "user, mac 52:54:00:ab:cd:ef, ssh on 127.0.0.1:2222",
ExtraArgs: "-device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal",
},
SerialLog: "OpenCore presents iMac20,1, serial C02FAKE123456\n",
QEMULog: "Authorization: Bearer 0123456789abcdef0123456789abcdef\n",
AppLogs: []string{`REIMS_TOKEN="abcdef0123456789abcdef0123456789"`},
})
if err != nil {
t.Fatalf("writeDiagnosticsZip: %v", err)
}
zr, err := zip.OpenReader(zipPath)
if err != nil {
t.Fatal(err)
}
defer zr.Close()
var all strings.Builder
for _, f := range zr.File {
rc, err := f.Open()
if err != nil {
t.Fatal(err)
}
b, _ := io.ReadAll(rc)
rc.Close()
all.WriteString(f.Name + ":\n" + string(b) + "\n")
}
text := all.String()
for _, secret := range []string{
"52:54:00:ab:cd:ef",
"C02FAKE123456",
"ourhardworkbythesewordsguardedpleasedontsteal",
"0123456789abcdef0123456789abcdef",
"abcdef0123456789abcdef0123456789",
} {
if strings.Contains(text, secret) {
t.Fatalf("diagnostics zip leaked secret %q\n%s", secret, text)
}
}
if !strings.Contains(text, "[redacted]") {
t.Fatalf("expected [redacted] markers in zip output")
}
}