Refactor architecture into eight components and consolidate reliability work
Build and publish container images / images (push) Successful in 9m34s
Release container images / release (push) Successful in 36s

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.
This commit is contained in:
Anya Tokugawa committed 2026-11-01 15:23:31 +09:00
1 parent 9dd425f765
commit d5d21b7841
302 files changed
+20037 -3492

No files matched your search

+86
View File
@@ -0,0 +1,86 @@
package server
import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
func TestPlainTextEditorCanonicalAndExistingHTML(t *testing.T) {
s, token, domain, htmlObject := editorFixture(t)
page := configRequest(s, token, "GET", "/e/-/notes.txt?edittype=plain", nil)
if page.Code != 200 || !strings.Contains(page.Body.String(), `value="plain"`) || !strings.Contains(page.Body.String(), `value="text/plain; charset=utf-8"`) {
t.Fatalf("plain editor: %d %s", page.Code, page.Body.String())
}
object, err := s.store.ResolvePathInDomain(domain, "/notes.txt")
if err != nil {
t.Fatal(err)
}
body := "<script>alert('literal')</script>\n# Not Markdown\n{{children}}\n日本語 & <>\n"
payload, _ := json.Marshal(map[string]any{"object_uuid": object, "body": body, "lang": "und", "content_type": "text/plain; charset=utf-8", "filename": "notes.txt", "base_revision_uuid": ""})
r := httptest.NewRequest("POST", "http://localhost/_/api/v1/revisions/save", bytes.NewReader(payload))
r.Header.Set("Authorization", "Bearer "+token)
r.Header.Set("Content-Type", "application/json")
w := httptest.NewRecorder()
s.withAuthorization(s.mux).ServeHTTP(w, r)
if w.Code != 200 {
t.Fatalf("plain save: %d %s", w.Code, w.Body.String())
}
rev, err := s.store.GetRevisionForExactLanguage(object, "und")
if err != nil {
t.Fatal(err)
}
if rev.Body != body || rev.ContentType != "text/plain; charset=utf-8" {
t.Fatalf("plain content mutated: %#v", rev)
}
if view := revisionContentView(rev, "/notes.txt"); view.Kind != "code" {
t.Fatalf("plain rendered as %s", view.Kind)
}
page = configRequest(s, token, "GET", "/e/-/notes.txt?edittype=markdown", nil)
if page.Code != 200 || !strings.Contains(page.Body.String(), `value="plain"`) || strings.Contains(page.Body.String(), `data-editor-action="markdown"`) {
t.Fatal("reopen switched plain file to HTML")
}
before, _ := s.store.GetRevisionForExactLanguage(htmlObject, "und")
page = configRequest(s, token, "GET", "/e/-/editor-fixture?edittype=plain", nil)
if page.Code != http.StatusConflict {
t.Fatalf("existing HTML converted: %d", page.Code)
}
after, _ := s.store.GetRevisionForExactLanguage(htmlObject, "und")
if before.UUID != after.UUID {
t.Fatal("existing HTML changed")
}
page = configRequest(s, token, "GET", "/e/-/invalid-format?edittype=not-a-format", nil)
if page.Code != http.StatusBadRequest {
t.Fatal("invalid editor format accepted")
}
if _, err = s.store.ResolvePathInDomain(domain, "/invalid-format"); err == nil {
t.Fatal("invalid format created a Page")
}
}
func TestBrowserEditorCreationRequiresPermission(t *testing.T) {
s, _, domain, _ := editorFixture(t)
user, err := s.store.CreatePasswordAccount(domain, "reader", "a long test password", "Reader", "")
if err != nil {
t.Fatal(err)
}
if err := s.store.SetPrincipalState(domain, user.UUID, "readonly"); err != nil {
t.Fatal(err)
}
token, err := s.store.CreateAuthSession(domain, user.UUID)
if err != nil {
t.Fatal(err)
}
for _, format := range []string{"html", "plain"} {
response := configRequest(s, token, "GET", "/e/-/denied?edittype="+format, nil)
if response.Code != http.StatusForbidden {
t.Fatalf("read-only create: %d", response.Code)
}
if _, err := s.store.ResolvePathInDomain(domain, "/denied"); err == nil {
t.Fatal("denied editor created a Page")
}
}
}