@@ -18,7 +18,7 @@ async function listen(): Promise<{ url: string; buffered: () => number }> {
1818 let buffered = 0 ;
1919 const app = express ( ) ;
2020 app . use ( dashboardAgentBodyCap ) ;
21- app . post ( "*" , async ( req , res ) => {
21+ app . all ( "*" , async ( req , res ) => {
2222 try {
2323 for await ( const chunk of req ) buffered += ( chunk as Buffer ) . byteLength ;
2424 } catch {
@@ -114,6 +114,28 @@ describe("the dashboard agent's ingress cap", () => {
114114 expect ( await response . json ( ) ) . toEqual ( { bytes : size } ) ;
115115 } ) ;
116116
117+ it ( "caps a mixed-case path, because Remix matches routes case-insensitively" , async ( ) => {
118+ const { url } = await listen ( ) ;
119+
120+ const response = await postChunked (
121+ `${ url } /api/v1/Dashboard-Agent/watches/batch-check` ,
122+ DASHBOARD_AGENT_MAX_INGRESS_BYTES * 4
123+ ) ;
124+
125+ expect ( response . status ) . toBe ( 413 ) ;
126+ } ) ;
127+
128+ it ( "caps a DELETE, which reads a body on the alerts route" , async ( ) => {
129+ const { url } = await listen ( ) ;
130+
131+ const response = await fetch ( `${ url } /api/v1/dashboard-agent/alerts/ch_1` , {
132+ method : "DELETE" ,
133+ body : "x" . repeat ( DASHBOARD_AGENT_MAX_INGRESS_BYTES + 1024 ) ,
134+ } ) ;
135+
136+ expect ( response . status ) . toBe ( 413 ) ;
137+ } ) ;
138+
117139 it ( "leaves every other path alone" , async ( ) => {
118140 const { url, buffered } = await listen ( ) ;
119141 const size = DASHBOARD_AGENT_MAX_INGRESS_BYTES + 1024 ;
0 commit comments