Files
Anya Tokugawa 5321d613b4
Build and publish container images / images (push) Successful in 11m45s
Release container images / release (push) Successful in 21s
feat(feeds): add opt-in Gecko relay and folder shortcuts
Document engine redistribution requirements; exclude upstream engine assets and keep the viewer disabled by default.
2026-11-08 16:14:34 +09:00

42 lines
1.5 KiB
Go

package middleware
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestNormalizePathDAVCollections(t *testing.T) {
for _, path := range []string{"/_/api/v1/caldav/", "/_/api/v1/caldav/tasks/", "/_/api/v1/caldav/tasks/default/", "/_/api/v1/caldav/calendar-id/", "/_/api/v1/carddav/", "/_/api/v1/carddav/actor/contacts/"} {
mux := http.NewServeMux()
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(401) })
for _, method := range []string{"GET", "OPTIONS", "PROPFIND", "REPORT"} {
w := httptest.NewRecorder()
NormalizePath(mux).ServeHTTP(w, httptest.NewRequest(method, path, nil))
if w.Code != 401 || w.Header().Get("Location") != "" {
t.Fatalf("%s %s: %d %v", method, path, w.Code, w.Header())
}
}
}
w := httptest.NewRecorder()
NormalizePath(http.NotFoundHandler()).ServeHTTP(w, httptest.NewRequest("GET", "/wiki/path/", nil))
if w.Code != 301 || w.Header().Get("Location") != "/wiki/path" {
t.Fatal("Wiki canonicalization changed", w.Code, w.Header())
}
}
func TestNormalizePathGeckoWebsocket(t *testing.T) {
for _, path := range []string{"/_/api/v1/extension/organizer.feeds/browser/", "/_/api/v1/extension/organizer.feeds/browser/wisp/"} {
w := httptest.NewRecorder()
NormalizePath(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != path {
t.Fatal(r.URL.Path)
}
w.WriteHeader(401)
})).ServeHTTP(w, httptest.NewRequest("GET", path, nil))
if w.Code != 401 || w.Header().Get("Location") != "" {
t.Fatal("redirected browser endpoint", w.Code)
}
}
}