aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/web_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/web_test.go')
-rw-r--r--internal/web/web_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/web/web_test.go b/internal/web/web_test.go
index 6324443..49915f4 100644
--- a/internal/web/web_test.go
+++ b/internal/web/web_test.go
@@ -962,3 +962,16 @@ func TestLoginThrottled(t *testing.T) {
t.Errorf("got %d, want 429", rec.Code)
}
}
+
+// The login form is the one POST outside guardPOST; it caps its own body.
+func TestLoginBodyCapped(t *testing.T) {
+ s := NewServer(&config.Config{BaseDomain: "example.com", JWTSecret: []byte("x")}, nil)
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest("POST", "/webadmin", strings.NewReader("username=a&password="+strings.Repeat("x", maxLoginBody)))
+ req.Host = "example.com"
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ s.ServeHTTP(rec, req)
+ if rec.Code != http.StatusBadRequest {
+ t.Errorf("got %d, want 400", rec.Code)
+ }
+}