@@ -100,7 +100,10 @@ public function test_update_unauth(): void
100100 public function test_update_forbidden (): void
101101 {
102102 $ w = Webhook::factory ()->create (['space_id ' => $ this ->space ->id ]);
103- $ this ->actingAs ($ this ->userWithoutPermission )->put (route ('admin.webhooks.update ' , $ w ), ['url ' => 'https://new.com/hook ' ])->assertNotFound () /* IDOR fix: cross-space returns 404 */ ;
103+ $ this ->actingAs ($ this ->userWithoutPermission )
104+ ->withHeaders (['X-Space-Id ' => $ this ->anotherSpace ->id ])
105+ ->put (route ('admin.webhooks.update ' , $ w ), ['url ' => 'https://new.com/hook ' ])
106+ ->assertNotFound () /* IDOR fix: cross-space returns 404 */ ;
104107 }
105108
106109 public function test_update_url (): void
@@ -130,7 +133,10 @@ public function test_destroy_unauth(): void
130133 public function test_destroy_forbidden (): void
131134 {
132135 $ w = Webhook::factory ()->create (['space_id ' => $ this ->space ->id ]);
133- $ this ->actingAs ($ this ->userWithoutPermission )->delete (route ('admin.webhooks.destroy ' , $ w ))->assertNotFound () /* IDOR fix: cross-space returns 404 */ ;
136+ $ this ->actingAs ($ this ->userWithoutPermission )
137+ ->withHeaders (['X-Space-Id ' => $ this ->anotherSpace ->id ])
138+ ->delete (route ('admin.webhooks.destroy ' , $ w ))
139+ ->assertNotFound () /* IDOR fix: cross-space returns 404 */ ;
134140 }
135141
136142 public function test_destroy_deletes (): void
@@ -150,7 +156,10 @@ public function test_rotate_unauth(): void
150156 public function test_rotate_forbidden (): void
151157 {
152158 $ w = Webhook::factory ()->create (['space_id ' => $ this ->space ->id ]);
153- $ this ->actingAs ($ this ->userWithoutPermission )->post (route ('admin.webhooks.rotate-secret ' , $ w ))->assertNotFound () /* IDOR fix: cross-space returns 404 */ ;
159+ $ this ->actingAs ($ this ->userWithoutPermission )
160+ ->withHeaders (['X-Space-Id ' => $ this ->anotherSpace ->id ])
161+ ->post (route ('admin.webhooks.rotate-secret ' , $ w ))
162+ ->assertNotFound () /* IDOR fix: cross-space returns 404 */ ;
154163 }
155164
156165 public function test_rotate_changes (): void
@@ -178,7 +187,10 @@ public function test_deliveries_unauth(): void
178187 public function test_deliveries_forbidden (): void
179188 {
180189 $ w = Webhook::factory ()->create (['space_id ' => $ this ->space ->id ]);
181- $ this ->actingAs ($ this ->userWithoutPermission )->get (route ('admin.webhooks.deliveries ' , $ w ))->assertNotFound () /* IDOR fix: cross-space returns 404 */ ;
190+ $ this ->actingAs ($ this ->userWithoutPermission )
191+ ->withHeaders (['X-Space-Id ' => $ this ->anotherSpace ->id ])
192+ ->get (route ('admin.webhooks.deliveries ' , $ w ))
193+ ->assertNotFound () /* IDOR fix: cross-space returns 404 */ ;
182194 }
183195
184196 public function test_deliveries_json (): void
@@ -216,7 +228,10 @@ public function test_redeliver_forbidden(): void
216228 {
217229 $ w = Webhook::factory ()->create (['space_id ' => $ this ->space ->id ]);
218230 $ d = WebhookDelivery::factory ()->create (['webhook_id ' => $ w ->id ]);
219- $ this ->actingAs ($ this ->userWithoutPermission )->post (route ('admin.webhooks.redeliver ' , ['id ' => $ w ->id , 'deliveryId ' => $ d ->id ]))->assertNotFound () /* IDOR fix: cross-space returns 404 */ ;
231+ $ this ->actingAs ($ this ->userWithoutPermission )
232+ ->withHeaders (['X-Space-Id ' => $ this ->anotherSpace ->id ])
233+ ->post (route ('admin.webhooks.redeliver ' , ['id ' => $ w ->id , 'deliveryId ' => $ d ->id ]))
234+ ->assertNotFound () /* IDOR fix: cross-space returns 404 */ ;
220235 }
221236
222237 public function test_redeliver_queues (): void
0 commit comments