bastion 0.55.3
ci / personal-data (push) Successful in 5s
ci / test (push) Successful in 3m51s
ci / fuzz (push) Successful in 2m55s

This commit is contained in:
Privatae
2026-10-25 23:16:45 +00:00
parent 77b7853ae1
commit 8822d5df85
136 changed files with 8638 additions and 1641 deletions
+41
View File
@@ -0,0 +1,41 @@
package main
import (
"encoding/json"
"os"
"path/filepath"
"strings"
"testing"
)
// A pairing whose file this build will not serve reads "invalid" on the
// console, as it does on the setup page and in `status`, even when the state
// stored in the file is empty, the old spelling of active.
func TestTheConsoleShowsAPairingThatIsNotServedAsInvalid(t *testing.T) {
const host = "unserved.host.privatae.ai"
uiTestConfigDir(t)
pd, err := pairingsDir()
if err != nil {
t.Fatal(err)
}
if err := os.MkdirAll(pd, 0o700); err != nil {
t.Fatal(err)
}
b, _ := json.Marshal(Config{HostName: host, ListenAddr: "127.0.0.1:59999",
Endpoint: "203.0.113.7:51820\nallowed_ip=::/0"}) // one the endpoint check refuses
if err := os.WriteFile(filepath.Join(pd, host+".json"), b, 0o600); err != nil {
t.Fatal(err)
}
var got []string
for _, p := range collectUIStatus().Pairings {
got = append(got, p.Host+"="+p.State)
}
if want := host + "=" + pairingInvalid; len(got) != 1 || got[0] != want {
t.Errorf("the console reads %v, want [%s]", got, want)
}
u := uiTestServer(t)
body := uiSetupGet(t, u.handler(), "/fragments/status", uiSignedIn(t, u)).Body.String()
if !strings.Contains(body, "invalid, not served") {
t.Errorf("the console page does not say the pairing is not served: %q", body)
}
}