Files
portal/app/tests/Feature/Console/CheckSupplierWebhookSecretCommandTest.php
T

45 lines
1.4 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
uses(DatabaseTransactions::class);
test('rejects placeholder seed __SET_ON_DEPLOY__', function () {
DB::table('system_settings')
->updateOrInsert(
['key' => 'supplier_webhook_secret'],
['value' => '__SET_ON_DEPLOY__', 'type' => 'string', 'description' => 'test seed']
);
$this->artisan('supplier:check-webhook-secret')->assertExitCode(1);
});
test('rejects too-short secret (< 32 chars)', function () {
DB::table('system_settings')
->updateOrInsert(
['key' => 'supplier_webhook_secret'],
['value' => 'short-secret-only-20-chars', 'type' => 'string', 'description' => 'test']
);
$this->artisan('supplier:check-webhook-secret')->assertExitCode(1);
});
test('rejects missing seed row', function () {
DB::table('system_settings')->where('key', 'supplier_webhook_secret')->delete();
$this->artisan('supplier:check-webhook-secret')->assertExitCode(1);
});
test('accepts valid secret (>=32 chars and not placeholder)', function () {
DB::table('system_settings')
->updateOrInsert(
['key' => 'supplier_webhook_secret'],
['value' => str_repeat('a', 64), 'type' => 'string', 'description' => 'test seed']
);
$this->artisan('supplier:check-webhook-secret')->assertExitCode(0);
});