Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming. Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
55 lines
2.4 KiB
Go
55 lines
2.4 KiB
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
"pageswiki/internal/store"
|
|
"strconv"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestDomainEntryConfig(t *testing.T) {
|
|
s, token, domain, actor := periodicalFixture(t)
|
|
var id int64
|
|
if err := s.store.DB.QueryRow(`SELECT id FROM domains WHERE uuid=?`, domain).Scan(&id); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
form := url.Values{"section": {"domain-entry"}, "domain_id": {strconv.FormatInt(id, 10)}, "entry_layout": {"diary"}, "diary_enabled": {"1"}, "diary_prefix": {"/"}, "blog_prefix": {"/blog"}}
|
|
w := configRequest(s, token, "POST", "/-/sys/config", form)
|
|
if w.Code != 302 {
|
|
t.Fatal(w.Code, w.Body.String())
|
|
}
|
|
if _, err := s.store.DB.Exec(`INSERT INTO federation_instances(uuid,campus_uuid,fqdn,fingerprint,status,last_seen_at,created_at) SELECT 'old-peer',campus_uuid,'old.example.test','sha256:fixture','approved',0,0 FROM domains WHERE uuid=?`, domain); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if blocked := configRequest(s, token, "POST", "/-/sys/config", form); blocked.Code != 409 {
|
|
t.Fatal("legacy peer not blocked", blocked.Code)
|
|
}
|
|
if _, err := s.store.DB.Exec(`INSERT INTO federation_instance_capabilities VALUES('old-peer',2)`); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if ready := configRequest(s, token, "POST", "/-/sys/config", form); ready.Code != 302 {
|
|
t.Fatal("supported peer blocked", ready.Code)
|
|
}
|
|
if got, _ := s.store.GetConfigInDomain(domain, "home_layout"); got != "diary" {
|
|
t.Fatal(got)
|
|
}
|
|
if w = periodicalRequest(s, token, "POST", "/_/api/v1/extension/content.diary/settings", `{"enabled":false}`); w.Code != 403 {
|
|
t.Fatal("override allowed", w.Code)
|
|
}
|
|
w = configRequest(s, token, "GET", "/-/sys/config?panel=domains", nil)
|
|
if w.Code != 200 || !strings.Contains(w.Body.String(), "data-domain-entry-open") {
|
|
t.Fatal("missing dialog", w.Code)
|
|
}
|
|
if err := s.store.SetDomainEntry(context.Background(), id, "unrelated", store.DomainEntrySettings{Layout: "classic", DiaryPrefix: "/diary", BlogPrefix: "/blog"}); err == nil {
|
|
t.Fatal("unauthorized settings")
|
|
}
|
|
if _, err := s.store.DB.Exec(`UPDATE campuses SET authority_mode='managed' WHERE uuid=(SELECT campus_uuid FROM domains WHERE uuid=?)`, domain); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := s.store.SetDomainEntry(context.Background(), id, actor, store.DomainEntrySettings{Layout: "classic", DiaryPrefix: "/diary", BlogPrefix: "/blog"}); err == nil {
|
|
t.Fatal("managed settings override")
|
|
}
|
|
}
|