mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-03 22:01:00 +00:00
* refactor: stabilize model identities for domain migration * refactor: extract module platform context * refactor: assign models to domain contexts * refactor: extract ai platform context * refactor: extract storage platform context * refactor: extract mail platform context * refactor: extract pdf platform context * refactor: extract operations platform context * refactor: move installation into operations platform * refactor: extract money domain context * refactor: extract taxation domain context * refactor: extract catalog domain context * refactor: extract metadata domain context * refactor: extract reporting domain context * refactor: extract purchases domain context * refactor: extract receivables domain context * refactor: extract accounts domain context * refactor: complete reporting statement boundary * refactor: extract contacts domain context * refactor: extract sales domain context * refactor: remove legacy application layers * fix: migrate legacy bouncer role identities
27 lines
929 B
PHP
27 lines
929 B
PHP
<?php
|
|
|
|
use App\Platform\Ai\Drivers\OpenRouterDriver;
|
|
use App\Platform\Ai\Exceptions\AiException;
|
|
|
|
/**
|
|
* Runtime SSRF backstop: even if a private base URL slips past validation (e.g.
|
|
* config saved before the rule existed, or DNS rebinding), the driver must refuse
|
|
* to make the request.
|
|
*/
|
|
test('rejects a private base URL before making any request', function () {
|
|
$driver = new OpenRouterDriver('test-key', ['base_url' => 'http://169.254.169.254']);
|
|
|
|
expect(fn () => $driver->validateConnection())->toThrow(AiException::class);
|
|
});
|
|
|
|
test('the thrown AI exception carries the invalid_base_url error key', function () {
|
|
$driver = new OpenRouterDriver('test-key', ['base_url' => 'http://127.0.0.1:11434']);
|
|
|
|
try {
|
|
$driver->validateConnection();
|
|
test()->fail('Expected AiException was not thrown');
|
|
} catch (AiException $e) {
|
|
expect($e->errorKey)->toBe('invalid_base_url');
|
|
}
|
|
});
|