dc9cab300c
Code-quality review of Task 4: adds a cross-tenant isolation test (verifies the where(tenant_id) guard, matching ApiKeyControllerTest) and a test()-endpoint failure-path test (HTTP 500 -> ok=false). Drops the @return docblock from OutboundWebhookSubscriptionFactory for consistency with ApiKeyFactory, eliminating a baseline entry at source. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
35 lines
954 B
PHP
35 lines
954 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\OutboundWebhookSubscription;
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<OutboundWebhookSubscription>
|
|
*/
|
|
class OutboundWebhookSubscriptionFactory extends Factory
|
|
{
|
|
protected $model = OutboundWebhookSubscription::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'tenant_id' => Tenant::factory(),
|
|
'user_id' => User::factory(),
|
|
'name' => 'Webhook',
|
|
'target_url' => 'https://'.fake()->domainName().'/webhook',
|
|
'secret_hash' => Hash::make('whsec_'.Str::random(40)),
|
|
'secret_prefix' => 'whsec_'.Str::lower(Str::random(4)),
|
|
'events' => ['deal.created', 'deal.status_changed'],
|
|
'is_active' => true,
|
|
];
|
|
}
|
|
}
|