diff --git a/src/library/FOSSBilling/Http/ResponseFactory.php b/src/library/FOSSBilling/Http/ResponseFactory.php index 5dddbc46f..26f513a24 100644 --- a/src/library/FOSSBilling/Http/ResponseFactory.php +++ b/src/library/FOSSBilling/Http/ResponseFactory.php @@ -14,6 +14,7 @@ namespace FOSSBilling\Http; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\ResponseHeaderBag; final readonly class ResponseFactory { @@ -51,7 +52,7 @@ final readonly class ResponseFactory { $response = new BinaryFileResponse($path); $response->headers->set('Content-Type', $contentType); - $response->setContentDisposition('attachment', $filename); + $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $filename); return $response; } @@ -59,6 +60,7 @@ final readonly class ResponseFactory public function download(string $filename, mixed $path): BinaryFileResponse { $response = $this->file($filename, 'application/octet-stream', $path); + $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename); $response->headers->set('Content-Description', 'File Transfer'); return $response; diff --git a/src/modules/Invoice/tests/Unit/ServiceTest.php b/src/modules/Invoice/tests/Unit/ServiceTest.php index c7a7a9c5d..e9510fcc8 100644 --- a/src/modules/Invoice/tests/Unit/ServiceTest.php +++ b/src/modules/Invoice/tests/Unit/ServiceTest.php @@ -46,7 +46,7 @@ test('gets search query with various parameters', function (array $data, string expect($result[1])->toBeArray(); expect(str_contains((string) $result[0], $expectedStr))->toBeTrue($result[0]); - expect(array_diff_key($result[1], $expectedParams))->toBe([]); + expect($result[1])->toMatchArray($expectedParams); })->with([ [[], 'FROM invoice p', []], [ @@ -108,31 +108,31 @@ test('gets search query with various parameters', function (array $data, string ], ], [ - ['created_at' => '1353715200'], + ['created_at' => '2012-11-23 12:34:56'], "AND DATE_FORMAT(p.created_at, '%Y-%m-%d') = :created_at", [ - 'created_at' => '1353715200', + 'created_at' => '2012-11-23', ], ], [ - ['date_from' => '1353715200'], + ['date_from' => '2012-11-23 12:34:56'], 'AND UNIX_TIMESTAMP(p.created_at) >= :date_from', [ - 'date_from' => '1353715200', + 'date_from' => 1353674096, ], ], [ - ['date_to' => '1353715200'], + ['date_to' => '2012-11-23 12:34:56'], 'AND UNIX_TIMESTAMP(p.created_at) <= :date_to', [ - 'date_to' => '1353715200', + 'date_to' => 1353674096, ], ], [ - ['paid_at' => '1353715200'], + ['paid_at' => '2012-11-23 12:34:56'], "AND DATE_FORMAT(p.paid_at, '%Y-%m-%d') = :paid_at", [ - 'paid_at' => '1353715200', + 'paid_at' => '2012-11-23', ], ], [ @@ -823,7 +823,6 @@ test('admin mark as paid with custom gateway rejects transaction linked to anoth }); test('counts income', function (): void { - $service = new Service(); $serviceMock = Mockery::mock(Service::class)->makePartial()->shouldAllowMockingProtectedMethods(); $invoiceModel = new Model_Invoice(); diff --git a/src/modules/Massmailer/Service.php b/src/modules/Massmailer/Service.php index 7e50d1131..373d4163f 100644 --- a/src/modules/Massmailer/Service.php +++ b/src/modules/Massmailer/Service.php @@ -117,7 +117,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface `created_at` varchar(35) DEFAULT NULL, `updated_at` varchar(35) DEFAULT NULL, PRIMARY KEY (`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1; '; $this->di['dbal']->executeStatement($sql); diff --git a/src/modules/Staff/tests/Unit/Api/AdminTest.php b/src/modules/Staff/tests/Unit/Api/AdminTest.php index e79b09deb..0ba3e6df0 100644 --- a/src/modules/Staff/tests/Unit/Api/AdminTest.php +++ b/src/modules/Staff/tests/Unit/Api/AdminTest.php @@ -214,6 +214,31 @@ test('change password password do not match', function (): void { ->toThrow(FOSSBilling\Exception::class, 'Passwords do not match'); }); +test('change password weak password', function (): void { + $api = new Box\Mod\Staff\Api\Admin(); + $data = [ + 'id' => '1', + 'password' => 'weak', + 'password_confirm' => 'weak', + ]; + + $validatorMock = Mockery::mock(FOSSBilling\Validate::class); + $validatorMock + ->shouldReceive('passwordsMatch') + ->atLeast()->once(); + $validatorMock + ->shouldReceive('isPasswordStrong') + ->atLeast()->once() + ->andThrow(new FOSSBilling\InformationException('Password is too weak.')); + + $di = container(); + $di['validator'] = $validatorMock; + + $api->setDi($di); + expect(fn () => $api->change_password($data)) + ->toThrow(FOSSBilling\Exception::class); +}); + test('create', function (): void { $api = new Box\Mod\Staff\Api\Admin(); $data = [ diff --git a/tests/Unit/FOSSBilling/ResponseFactoryTest.php b/tests/Unit/FOSSBilling/ResponseFactoryTest.php index 71a37cec5..f7a25068f 100644 --- a/tests/Unit/FOSSBilling/ResponseFactoryTest.php +++ b/tests/Unit/FOSSBilling/ResponseFactoryTest.php @@ -55,9 +55,11 @@ test('response factory creates binary file and download responses', function (): expect($fileResponse)->toBeInstanceOf(BinaryFileResponse::class) ->and($fileResponse->headers->get('Content-Type'))->toBe('text/plain') + ->and($fileResponse->headers->get('Content-Disposition'))->toStartWith('inline;') ->and($fileResponse->headers->get('Content-Disposition'))->toContain('report.txt') ->and($downloadResponse->headers->get('Content-Type'))->toBe('application/octet-stream') ->and($downloadResponse->headers->get('Content-Description'))->toBe('File Transfer') + ->and($downloadResponse->headers->get('Content-Disposition'))->toStartWith('attachment;') ->and($downloadResponse->headers->get('Content-Disposition'))->toContain('archive.zip'); } finally { if (is_string($file) && file_exists($file)) {