Add a Check for updates button under Settings; keep the self edge when settings are saved
CI / test (push) Successful in 4m48s
CI / test (push) Successful in 4m48s
Saving settings replaced the whole Settings value, which would have dropped SelfEdgeID and made the next start create a second self edge with a new token. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da3d7201a1
commit
abf352e6c9
10 files changed
+135
-1
No files matched your search
@@ -96,3 +96,26 @@ func TestNoSelfEdgeUnlessAsked(t *testing.T) {
|
||||
t.Fatal("token file written without HAMMERHEAD_SELF_DOMAIN")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSavingSettingsKeepsTheSelfEdge(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
opts := Options{AdminEmail: "admin@test.local", AdminPassword: "password123", MasterKey: key, SelfDomain: "hh.example.com", SelfTarget: "127.0.0.1:8080"}
|
||||
s, err := New(dir, opts)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
token := tokenFile(t, dir)
|
||||
do := apiClient(t, s)
|
||||
if code, b := do("PUT", "/api/admin/settings", map[string]any{"dashboardUrl": "https://hh.example.com", "acmeEmail": "me@example.com"}); code != 200 {
|
||||
t.Fatalf("settings: %d %s", code, b)
|
||||
}
|
||||
s.Close()
|
||||
s2, err := New(dir, opts)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer s2.Close()
|
||||
if len(s2.st.Edges) != 1 || tokenFile(t, dir) != token {
|
||||
t.Fatalf("saving settings lost the self edge: %d edges", len(s2.st.Edges))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user