High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
cleanup: remove dead query-param routes, add endpoint checks to test plan
Mario1d8078bac6b5
diff --git a/internal/orchestrator/handlers.go b/internal/orchestrator/handlers.goindex e9225d6a..4bd98254 100644--- a/internal/orchestrator/handlers.go+++ b/internal/orchestrator/handlers.go@@ -9,10 +9,7 @@ import ()func (o *Orchestrator) RegisterHandlers(mux *http.ServeMux) {- mux.HandleFunc("POST /launch", o.handleLaunch)- mux.HandleFunc("POST /stop", o.handleStop)mux.HandleFunc("GET /instances", o.handleList)- mux.HandleFunc("GET /instances/logs", o.handleLogs)// Agent-friendly routes: start/stop by profile IDmux.HandleFunc("POST /start/{id}", o.handleStartByID)@@ -28,74 +25,6 @@ func (o *Orchestrator) RegisterHandlers(mux *http.ServeMux) {mux.HandleFunc("GET /instances/{id}/proxy/screencast", o.handleProxyScreencast)}-func (o *Orchestrator) handleLaunch(w http.ResponseWriter, r *http.Request) {- var req struct {- Profile string `json:"profile"`- Port string `json:"port"`- Headless bool `json:"headless"`- }- if err := json.NewDecoder(r.Body).Decode(&req); err != nil {- web.Error(w, 400, err)- return- }-- if req.Profile == "" {- web.Error(w, 400, fmt.Errorf("profile name required"))- return- }-- // Resolve profile ID if provided- if len(req.Profile) == 12 {- if pm := o.profiles; pm != nil {- if name, err := pm.FindByID(req.Profile); err == nil {- req.Profile = name- }- }- }-- if req.Port == "" {- req.Port = "0"- }-- inst, err := o.Launch(req.Profile, req.Port, req.Headless)- if err != nil {- web.Error(w, 500, err)- return- }-- web.JSON(w, 200, inst)-}--func (o *Orchestrator) handleStop(w http.ResponseWriter, r *http.Request) {- id := r.URL.Query().Get("id")- profile := r.URL.Query().Get("profile")-- if id != "" {- if err := o.Stop(id); err != nil {- web.Error(w, 500, err)- return- }- } else if profile != "" {- // Resolve profile ID if provided- if len(profile) == 12 {- if pm := o.profiles; pm != nil {- if name, err := pm.FindByID(profile); err == nil {- profile = name- }- }- }- if err := o.StopProfile(profile); err != nil {- web.Error(w, 500, err)- return- }- } else {- web.Error(w, 400, fmt.Errorf("id or profile required"))- return- }-- web.JSON(w, 200, map[string]string{"status": "stopped"})-}-func (o *Orchestrator) handleList(w http.ResponseWriter, r *http.Request) {web.JSON(w, 200, o.List())}@@ -242,16 +171,4 @@ func (o *Orchestrator) handleProxyScreencast(w http.ResponseWriter, r *http.Requweb.JSON(w, 200, map[string]string{"wsUrl": targetURL})}-func (o *Orchestrator) handleLogs(w http.ResponseWriter, r *http.Request) {- id := r.URL.Query().Get("id")- if id == "" {- web.Error(w, 400, fmt.Errorf("id required"))- return- }- logs, err := o.Logs(id)- if err != nil {- web.Error(w, 404, err)- return- }- web.JSON(w, 200, map[string]string{"id": id, "logs": logs})-}+// handleLogs removed — use handleLogsByID (path-param) insteaddiff --git a/internal/profiles/handlers.go b/internal/profiles/handlers.goindex 87617b3a..a389abb9 100644--- a/internal/profiles/handlers.go+++ b/internal/profiles/handlers.go@@ -11,16 +11,9 @@ import (func (pm *ProfileManager) RegisterHandlers(mux *http.ServeMux) {mux.HandleFunc("GET /profiles", pm.handleList)- mux.HandleFunc("POST /profiles", pm.handleCreate)+ mux.HandleFunc("POST /profiles/create", pm.handleCreate)mux.HandleFunc("POST /profiles/import", pm.handleImport)- mux.HandleFunc("POST /profiles/reset", pm.handleReset)- mux.HandleFunc("DELETE /profiles", pm.handleDelete)- mux.HandleFunc("GET /profiles/logs", pm.handleLogs)- mux.HandleFunc("GET /profiles/analytics", pm.handleAnalytics)mux.HandleFunc("PATCH /profiles/meta", pm.handleUpdateMeta)-- // Dashboard-compatible aliases (path-param style)- mux.HandleFunc("POST /profiles/create", pm.handleCreate)mux.HandleFunc("DELETE /profiles/{name}", pm.handleDeleteByPath)mux.HandleFunc("PATCH /profiles/{name}", pm.handleUpdateByPath)mux.HandleFunc("POST /profiles/{name}/reset", pm.handleResetByPath)@@ -92,53 +85,6 @@ func (pm *ProfileManager) handleImport(w http.ResponseWriter, r *http.Request) {web.JSON(w, 200, map[string]string{"status": "imported", "name": req.Name})}-func (pm *ProfileManager) handleReset(w http.ResponseWriter, r *http.Request) {- name := r.URL.Query().Get("name")- if name == "" {- web.Error(w, 400, fmt.Errorf("name required"))- return- }- if err := pm.Reset(name); err != nil {- web.Error(w, 500, err)- return- }- web.JSON(w, 200, map[string]string{"status": "reset", "name": name})-}--func (pm *ProfileManager) handleDelete(w http.ResponseWriter, r *http.Request) {- name := r.URL.Query().Get("name")- if name == "" {- web.Error(w, 400, fmt.Errorf("name required"))- return- }- if err := pm.Delete(name); err != nil {- web.Error(w, 500, err)- return- }- web.JSON(w, 200, map[string]string{"status": "deleted", "name": name})-}--func (pm *ProfileManager) handleLogs(w http.ResponseWriter, r *http.Request) {- name := r.URL.Query().Get("name")- if name == "" {- web.Error(w, 400, fmt.Errorf("name required"))- return- }- limit, _ := strconv.Atoi(r.URL.Query().Get("limit"))- logs := pm.Logs(name, limit)- web.JSON(w, 200, logs)-}--func (pm *ProfileManager) handleAnalytics(w http.ResponseWriter, r *http.Request) {- name := r.URL.Query().Get("name")- if name == "" {- web.Error(w, 400, fmt.Errorf("name required"))- return- }- report := pm.Analytics(name)- web.JSON(w, 200, report)-}-func (pm *ProfileManager) handleUpdateMeta(w http.ResponseWriter, r *http.Request) {var req struct {Name string `json:"name"`diff --git a/internal/profiles/profiles_test.go b/internal/profiles/profiles_test.goindex 58fb0ee6..d11439c7 100644--- a/internal/profiles/profiles_test.go+++ b/internal/profiles/profiles_test.go@@ -250,7 +250,7 @@ func TestProfileHandlerCreate(t *testing.T) {pm.RegisterHandlers(mux)body := `{"name": "new-profile"}`- req := httptest.NewRequest("POST", "/profiles", strings.NewReader(body))+ req := httptest.NewRequest("POST", "/profiles/create", strings.NewReader(body))w := httptest.NewRecorder()mux.ServeHTTP(w, req)@@ -265,7 +265,7 @@ func TestProfileHandlerReset(t *testing.T) {mux := http.NewServeMux()pm.RegisterHandlers(mux)- req := httptest.NewRequest("POST", "/profiles/reset?name=resettable", nil)+ req := httptest.NewRequest("POST", "/profiles/resettable/reset", nil)w := httptest.NewRecorder()mux.ServeHTTP(w, req)@@ -280,7 +280,7 @@ func TestProfileHandlerDelete(t *testing.T) {mux := http.NewServeMux()pm.RegisterHandlers(mux)- req := httptest.NewRequest("DELETE", "/profiles?name=deletable", nil)+ req := httptest.NewRequest("DELETE", "/profiles/deletable", nil)w := httptest.NewRecorder()mux.ServeHTTP(w, req)@@ -339,7 +339,7 @@ func TestProfileCreateWithUseWhen(t *testing.T) {// Create profile with useWhenbody := `{"name":"test-usewhen","useWhen":"For testing purposes"}`- req := httptest.NewRequest("POST", "/profiles", strings.NewReader(body))+ req := httptest.NewRequest("POST", "/profiles/create", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")w := httptest.NewRecorder()mux.ServeHTTP(w, req)diff --git a/tests/TEST-PLAN-dashboard.md b/tests/TEST-PLAN-dashboard.mdindex bbbdb169..ea3f8bbd 100644--- a/tests/TEST-PLAN-dashboard.md+++ b/tests/TEST-PLAN-dashboard.md@@ -123,6 +123,78 @@ All tests use `__test_profile__` — cleaned up at end.---+## 9. Endpoint Existence Checks++Verify every registered route returns a non-404 status (may return 400/503 for missing params, but not 404 routing failures).++### Dashboard / Health++| # | Route | Method | Expected | Auto |+|---|-------|--------|----------|------|+| RE1 | `/health` | GET | 200 | ✅ |+| RE2 | `/dashboard` | GET | 200 (HTML) | ✅ |+| RE3 | `/dashboard/agents` | GET | 200 | ✅ |+| RE4 | `/dashboard/events` | GET | 200 (SSE stream) | ✅ |+| RE5 | `/shutdown` | POST | 200 (⚠️ kills dashboard) | 🔧 Manual |++### Profiles++| # | Route | Method | Expected | Auto |+|---|-------|--------|----------|------|+| RE6 | `/profiles` | GET | 200 | ✅ |+| RE7 | `/profiles/create` | POST | 400 (no body) | ✅ |+| RE8 | `/profiles/import` | POST | 400 (no body) | ✅ |+| RE9 | `/profiles/meta` | PATCH | 400 (no body) | ✅ |+| RE10 | `/profiles/__nonexistent__` | DELETE | 404 | ✅ |+| RE11 | `/profiles/__nonexistent__` | PATCH | 400 (no body) | ✅ |+| RE12 | `/profiles/__nonexistent__/reset` | POST | 404 | ✅ |+| RE13 | `/profiles/__nonexistent__/logs` | GET | 200 (empty) | ✅ |+| RE14 | `/profiles/__nonexistent__/analytics` | GET | 200 | ✅ |+| RE15 | `/profiles/__nonexistent__/instance` | GET | 200 (running=false) | ✅ |+| RE16 | `/profiles/__nonexistent__/stop` | POST | 404 | ✅ |++### Orchestrator++| # | Route | Method | Expected | Auto |+|---|-------|--------|----------|------|+| RE17 | `/instances` | GET | 200 | ✅ |+| RE18 | `/instances/tabs` | GET | 200 | ✅ |+| RE19 | `/instances/launch` | POST | 400 (no body) | ✅ |+| RE20 | `/instances/nonexistent/stop` | POST | 404 | ✅ |+| RE21 | `/instances/nonexistent/logs` | GET | 404 | ✅ |+| RE22 | `/instances/nonexistent/proxy/screencast?tabId=x` | GET | 404 | ✅ |++### Agent-friendly routes++| # | Route | Method | Expected | Auto |+|---|-------|--------|----------|------|+| RE23 | `/start/000000000000` | POST | 404 (unknown profile ID) | ✅ |+| RE24 | `/stop/000000000000` | POST | 404 (unknown profile ID) | ✅ |++### Proxy endpoints (503 when no instance running)++| # | Route | Method | Expected (no instance) | Auto |+|---|-------|--------|------------------------|------|+| RE25 | `/tabs` | GET | 503 | ✅ |+| RE26 | `/snapshot` | GET | 503 | ✅ |+| RE27 | `/screenshot` | GET | 503 | ✅ |+| RE28 | `/text` | GET | 503 | ✅ |+| RE29 | `/navigate` | POST | 503 | ✅ |+| RE30 | `/action` | POST | 503 | ✅ |+| RE31 | `/actions` | POST | 503 | ✅ |+| RE32 | `/evaluate` | POST | 503 | ✅ |+| RE33 | `/tab` | POST | 503 | ✅ |+| RE34 | `/tab/lock` | POST | 503 | ✅ |+| RE35 | `/tab/unlock` | POST | 503 | ✅ |+| RE36 | `/cookies` | GET | 503 | ✅ |+| RE37 | `/cookies` | POST | 503 | ✅ |+| RE38 | `/stealth/status` | GET | 503 | ✅ |+| RE39 | `/fingerprint/rotate` | POST | 503 | ✅ |+| RE40 | `/screencast` | GET | 503 | ✅ |+| RE41 | `/screencast/tabs` | GET | 503 | ✅ |++---+## Release Criteria### Must Pass@@ -130,6 +202,7 @@ All tests use `__test_profile__` — cleaned up at end.- All Section 2 (profile CRUD) — no side effects on existing profiles- Section 3 DO1-DO11 (basic instance lifecycle)- Section 4 DX1-DX4 (proxy basics)+- Section 9 RE1-RE41 (all endpoints reachable)### Should Pass- Section 3 DO12-DO15 (advanced orchestration)