Release 3.8.2.4: unify Windows/macOS GUI on glaze HTTP host.
Auto-bump build number on each compile; ship versioned Windows artifacts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package apphost
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"vpnclient/internal/config"
|
||||
"vpnclient/internal/core"
|
||||
"vpnclient/internal/logbuf"
|
||||
)
|
||||
|
||||
func TestHTTPBridgeGetState(t *testing.T) {
|
||||
cfg := &config.Config{
|
||||
Active: "demo",
|
||||
Profiles: []config.Profile{
|
||||
{Name: "demo", Protocol: config.ProtocolNaive, Proxy: "https://u:p@example.com"},
|
||||
},
|
||||
}
|
||||
mgr, err := core.NewManager("", cfg, logbuf.New(0))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a := New(mgr, "", logbuf.New(0))
|
||||
a.APIToken = "test-token"
|
||||
|
||||
body, _ := json.Marshal(map[string]any{"args": []any{}})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/getState", bytes.NewReader(body))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("X-Navis-Token", "test-token")
|
||||
rr := httptest.NewRecorder()
|
||||
a.Handler().ServeHTTP(rr, req)
|
||||
if rr.Code != http.StatusOK {
|
||||
t.Fatalf("status %d body %s", rr.Code, rr.Body.String())
|
||||
}
|
||||
var resp struct {
|
||||
Result UIState `json:"result"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if resp.Error != "" {
|
||||
t.Fatalf("api error: %s", resp.Error)
|
||||
}
|
||||
if resp.Result.ActiveProfile != "demo" {
|
||||
t.Fatalf("active_profile=%q", resp.Result.ActiveProfile)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPBridgeRejectsBadToken(t *testing.T) {
|
||||
cfg := &config.Config{}
|
||||
mgr, err := core.NewManager("", cfg, logbuf.New(0))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a := New(mgr, "", logbuf.New(0))
|
||||
a.APIToken = "secret"
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/getState", bytes.NewReader([]byte(`{"args":[]}`)))
|
||||
req.Header.Set("X-Navis-Token", "wrong")
|
||||
rr := httptest.NewRecorder()
|
||||
a.Handler().ServeHTTP(rr, req)
|
||||
if rr.Code != http.StatusUnauthorized {
|
||||
t.Fatalf("want 401, got %d", rr.Code)
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ var appCSS string
|
||||
//go:embed app.js
|
||||
var appJS string
|
||||
|
||||
// IndexHTML is the full GUI document (CSS/JS inlined for WebView2 / glaze).
|
||||
// IndexHTML is the full GUI document (CSS/JS inlined for glaze HTTP UI).
|
||||
var IndexHTML = buildIndexHTML()
|
||||
|
||||
func buildIndexHTML() string {
|
||||
|
||||
@@ -22,7 +22,7 @@ const CurrentVersion = "3.8.2"
|
||||
|
||||
// BuildNumber is the monotonic build within CurrentVersion (Windows FileVersion 4th part,
|
||||
// macOS CFBundleVersion suffix, Android versionCode low digits). Bump on every release build.
|
||||
const BuildNumber = 3
|
||||
const BuildNumber = 4
|
||||
|
||||
// DefaultManifestURL is the update feed (hosted in the project git repo).
|
||||
const DefaultManifestURL = "https://git.evilfox.cc/test2/navi/raw/branch/main/dist/update.json"
|
||||
|
||||
Reference in New Issue
Block a user