Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts. Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation. Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
90 lines
3.8 KiB
Go
90 lines
3.8 KiB
Go
package schutzaria
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestPublicationCeilings(t *testing.T) {
|
|
values := []string{"public", "authenticated_acl", "inherit", "invalid"}
|
|
for _, domain := range values {
|
|
for _, quartier := range values {
|
|
for _, street := range values {
|
|
for _, spot := range values {
|
|
chain := []LocalityPolicy{{Kind: "domain", Policy: domain}, {Kind: "quartier", Policy: quartier}, {Kind: "street", Policy: street}, {Kind: "spot", Policy: spot}}
|
|
wantAllows := domain == "public" && quartier != "authenticated_acl" && street != "authenticated_acl" && spot != "authenticated_acl" && quartier != "invalid" && street != "invalid" && spot != "invalid"
|
|
wantIntent := wantAllows && (quartier == "public" || street == "public" || spot == "public")
|
|
a, p := EvaluateLocalityPublication(chain)
|
|
if a != wantAllows || p != wantIntent {
|
|
t.Fatalf("%+v got=%v/%v", chain, a, p)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Preserve the legacy neutral empty-chain result; it is never a grant.
|
|
if a, p := EvaluateLocalityPublication(nil); !a || p {
|
|
t.Fatal("empty chain semantics changed")
|
|
}
|
|
if a, p := EvaluateLocalityPublication([]LocalityPolicy{{Kind: "domain", Policy: "public"}}); !a || p {
|
|
t.Fatal("Domain ceiling published content")
|
|
}
|
|
}
|
|
|
|
func TestPublicNamespaceEligibility(t *testing.T) {
|
|
for _, p := range []string{"/", "/life/home", "/blog/2026/11/01", "/日本語", "/user"} {
|
|
if !PublicSemanticPath(p) {
|
|
t.Fatal(p)
|
|
}
|
|
}
|
|
for _, p := range []string{"", "relative", "/a/../b", "/a/./b", "/a//b", "/a\\b", "/a\x00b", "/a\nb", "/a\rb"} {
|
|
if PublicSemanticPath(p) {
|
|
t.Fatal(p)
|
|
}
|
|
}
|
|
for _, root := range []string{"_", "-", ":", "o", "r", "v", "l", "e", "s", "u", "g", "static", "health", "new"} {
|
|
if PublicSemanticPath("/"+root) || PublicSemanticPath("/"+root+"/child") {
|
|
t.Fatal(root)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestApprovalStateTransitionNotPublicationAuthorization(t *testing.T) {
|
|
for _, state := range []string{"pending", "approved", "rejected", "withdrawn", "expired", "superseded", ""} {
|
|
for _, decision := range []string{"approved", "rejected", "changes_requested", "unknown", ""} {
|
|
for _, generation := range []int64{-1, 0, 1, 2} {
|
|
next, err := ApprovalNextState(state, 1, generation, decision)
|
|
valid := state == "pending" && generation == 1 && (decision == "approved" || decision == "rejected" || decision == "changes_requested")
|
|
if valid {
|
|
want := decision
|
|
if want == "changes_requested" {
|
|
want = "rejected"
|
|
}
|
|
if err != nil || next != want {
|
|
t.Fatal(state, decision, next, err)
|
|
}
|
|
} else if !errors.Is(err, ErrApprovalTransition) || next != "" {
|
|
t.Fatal(state, decision, generation, next, err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestUserSpaceNarrowing(t *testing.T) {
|
|
p := UserSpacePolicy{Username: "alice", RootVisibility: "domain", DescendantVisibility: "public", Overrides: []UserSpacePathPolicy{{Path: "/u/alice/work", Visibility: "domain"}, {Path: "/u/alice/work/private", Visibility: "private"}, {Path: "/u/alice/work/private/reopen", Visibility: "public"}}}
|
|
for path, want := range map[string]string{"/u/alice": "domain", "/u/alice/blog": "public", "/u/alice/work": "domain", "/u/alice/work/page": "domain", "/u/alice/work/private": "private", "/u/alice/work/private/reopen/page": "private", "/u/bob/blog": "private", "/u/alice/_/edit": "private", "/u/alice/a/../blog": "private", "/u/alice/blog/": "private"} {
|
|
if got := EffectiveUserSpaceVisibility(p, path); got != want {
|
|
t.Fatal(path, got, want)
|
|
}
|
|
}
|
|
// Existing semantics: root and descendants have independent settings.
|
|
p.RootVisibility = "private"
|
|
if EffectiveUserSpaceVisibility(p, "/u/alice/blog") != "public" {
|
|
t.Fatal("root incorrectly became subtree cap")
|
|
}
|
|
if UserSpaceVisibilityRank("unknown") != -1 || UserSpaceDocumentPath("alice", "/u/alice/_", true) {
|
|
t.Fatal("invalid user-space policy/path")
|
|
}
|
|
}
|