fix: cap Base64 media transfers at 10 MB, upload limit at most 32 MB
This commit is contained in:
@@ -24,7 +24,7 @@ final class LimitsTest extends TestCase
|
||||
{
|
||||
Functions\when('get_option')->justReturn(['upload_mb' => 500, 'log_retention_days' => 0, 'snapshot_count' => '7']);
|
||||
|
||||
self::assertSame(['upload_mb' => 100, 'log_retention_days' => 1, 'snapshot_count' => 7], (new Limits())->all());
|
||||
self::assertSame(['upload_mb' => 32, 'log_retention_days' => 1, 'snapshot_count' => 7], (new Limits())->all());
|
||||
}
|
||||
|
||||
public function testCorruptOptionFallsBackToDefaults(): void
|
||||
@@ -45,7 +45,7 @@ final class LimitsTest extends TestCase
|
||||
|
||||
public function testBoundsMatchesWhatSanitizeClampsTo(): void
|
||||
{
|
||||
self::assertSame([1, 100], Limits::bounds()['upload_mb']);
|
||||
self::assertSame([1, 32], Limits::bounds()['upload_mb']);
|
||||
self::assertSame([1, 3650], Limits::bounds()['log_retention_days']);
|
||||
self::assertSame([1, 100], Limits::bounds()['snapshot_count']);
|
||||
|
||||
@@ -61,4 +61,23 @@ final class LimitsTest extends TestCase
|
||||
Limits::sanitize($tooHigh)
|
||||
);
|
||||
}
|
||||
|
||||
public function testInlineTransfersAreCappedAtTenMegabytes(): void
|
||||
{
|
||||
Functions\when('get_option')->justReturn(['upload_mb' => 32]);
|
||||
$limits = new Limits();
|
||||
|
||||
self::assertSame(32 * 1024 * 1024, $limits->uploadBytes());
|
||||
self::assertSame(10 * 1024 * 1024, $limits->inlineBytes());
|
||||
self::assertSame(10, $limits->inlineMegabytes());
|
||||
}
|
||||
|
||||
public function testInlineLimitFollowsALowerUploadLimit(): void
|
||||
{
|
||||
Functions\when('get_option')->justReturn(['upload_mb' => 3]);
|
||||
$limits = new Limits();
|
||||
|
||||
self::assertSame(3 * 1024 * 1024, $limits->inlineBytes());
|
||||
self::assertSame(3, $limits->inlineMegabytes());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user