Bugfix
release-tag / release-image (push) Successful in 2m23s

This commit is contained in:
2026-09-01 08:11:16 +02:00
parent 97004838a3
commit c609c34f16
7 changed files with 80 additions and 12 deletions
+28
View File
@@ -29,3 +29,31 @@ func TestArrayPatch(t *testing.T) {
t.Fatal(out)
}
}
func TestAddTopLevelNamedVolumePreservesServiceMounts(t *testing.T) {
src := "services:\n app:\n volumes:\n - db_data:/var/lib/db\n - /srv/app:/data:ro\n x-future: keep\n"
out, err := Apply(src, Patch{Path: []string{"volumes", "db_data"}, Value: map[string]any{}})
if err != nil {
t.Fatal(err)
}
for _, want := range []string{"db_data:/var/lib/db", "/srv/app:/data:ro", "x-future: keep", "volumes:", "db_data:"} {
if !strings.Contains(out, want) {
t.Fatalf("expected %q to be preserved/added:\n%s", want, out)
}
}
parsed, err := Parse(out)
if err != nil {
t.Fatal(err)
}
root, ok := parsed.Value.(map[string]any)
if !ok {
t.Fatalf("unexpected parse result %#v", parsed.Value)
}
vols, ok := root["volumes"].(map[string]any)
if !ok {
t.Fatalf("top-level volumes missing: %#v", root["volumes"])
}
if _, ok := vols["db_data"]; !ok {
t.Fatalf("db_data declaration missing: %#v", vols)
}
}
+8 -3
View File
@@ -147,9 +147,14 @@ func New(c config.Config, a *auth.Service, ss *stacks.Service, n *nodes.Manager,
mux.Handle("/api/", a.Middleware(mutationOriginGuard(s.auditMiddleware(api))))
assets, _ := fs.Sub(web.FS, ".")
f := http.FileServer(http.FS(assets))
mux.Handle("GET /app.js", f)
mux.Handle("GET /styles.css", f)
mux.Handle("GET /{$}", f)
staticNoStore := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-store")
w.Header().Set("Pragma", "no-cache")
f.ServeHTTP(w, r)
})
mux.Handle("GET /app.js", staticNoStore)
mux.Handle("GET /styles.css", staticNoStore)
mux.Handle("GET /{$}", staticNoStore)
return securityHeaders(mux)
}
func (s *Server) agent(m *http.ServeMux) {
+15
View File
@@ -1,6 +1,8 @@
package httpapi
import (
"net/http/httptest"
"strings"
"testing"
"git.send.nrw/sendnrw/dockwatch/internal/audit"
@@ -16,3 +18,16 @@ func TestRouterPatternsDoNotConflict(t *testing.T) {
}()
_ = New(config.Config{Mode: config.ModeStandalone}, &auth.Service{}, nil, nil, nil, (*audit.Service)(nil), nil, nil, nil)
}
func TestStaticAssetsDisableBrowserCaching(t *testing.T) {
h := New(config.Config{Mode: config.ModeStandalone}, &auth.Service{}, nil, nil, nil, (*audit.Service)(nil), nil, nil, nil)
for _, path := range []string{"/", "/app.js", "/styles.css"} {
t.Run(strings.TrimPrefix(path, "/"), func(t *testing.T) {
rr := httptest.NewRecorder()
h.ServeHTTP(rr, httptest.NewRequest("GET", path, nil))
if got := rr.Header().Get("Cache-Control"); got != "no-store" {
t.Fatalf("Cache-Control for %s = %q, want no-store", path, got)
}
})
}
}