8661615717
API CI/CD / Validate (composer + pint) (push) Successful in 2m46s
API CI/CD / Test (PHPUnit) (push) Failing after 3m3s
API CI/CD / Build frontend assets (push) Failing after 5m22s
API CI/CD / Security audit (push) Failing after 34s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
49 lines
1.9 KiB
PHP
49 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Api\V1\FullSurface;
|
|
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use Tests\Feature\Api\V1\FullSurface\Support\FullSurfaceE2EContractCase;
|
|
|
|
class ApiNestedPayloadAndArrayAbuseContractTest extends FullSurfaceE2EContractCase
|
|
{
|
|
#[Test]
|
|
public function mutation_routes_fail_cleanly_for_deeply_nested_payloads(): void
|
|
{
|
|
$routes = array_slice(array_filter($this->apiRoutes(), fn ($route) => in_array($this->primaryMethod($route), ['POST', 'PUT', 'PATCH'], true)), 0, 90);
|
|
|
|
$nested = ['level_1' => ['level_2' => ['level_3' => ['level_4' => ['level_5' => ['level_6' => ['value' => 'too deep']]]]]]];
|
|
|
|
foreach ($routes as $route) {
|
|
$method = $this->primaryMethod($route);
|
|
$uri = $route->uri();
|
|
|
|
$response = $this->requestAs($this->actorFor($uri), $method, $uri, $this->payloadFor($method, $uri) + $nested);
|
|
|
|
$this->assertControlled($response, $method, $uri);
|
|
$this->assertLessThan(500, $response->getStatusCode(), "$method $uri should reject or ignore deep nesting without collapsing dramatically.");
|
|
}
|
|
}
|
|
|
|
#[Test]
|
|
public function mutation_routes_fail_cleanly_for_large_sparse_arrays(): void
|
|
{
|
|
$routes = array_slice(array_filter($this->apiRoutes(), fn ($route) => in_array($this->primaryMethod($route), ['POST', 'PUT', 'PATCH'], true)), 0, 90);
|
|
|
|
$sparse = [
|
|
'ids' => [0 => $this->ids['studentId'], 1000 => 999999, 9999 => null],
|
|
'students' => array_fill(0, 150, ['id' => 999999, 'status' => 'present']),
|
|
'permissions' => array_fill(0, 80, '*'),
|
|
];
|
|
|
|
foreach ($routes as $route) {
|
|
$method = $this->primaryMethod($route);
|
|
$uri = $route->uri();
|
|
|
|
$response = $this->requestAs($this->actorFor($uri), $method, $uri, $this->payloadFor($method, $uri) + $sparse);
|
|
|
|
$this->assertControlled($response, $method, $uri);
|
|
}
|
|
}
|
|
}
|