3266909346
Audit J5/D4/D5: the outbound_webhook_subscriptions table existed in schema but had zero code. Adds the OutboundWebhookSubscription model + factory and WebhookSettingsController with GET/PUT /api/tenants/me/webhook-settings (one subscription per tenant; secret generated + returned once on creation, bcrypt-hashed) and POST /api/webhooks/test (unsigned connectivity check — HMAC-signed event delivery is a separate post-MVP epic). Tenant-scoped via auth:sanctum + tenant middleware. phpstan-baseline.neon: additive-only entries for new test file (Pest\PendingCalls\TestCall false-positives — documented project pattern) and OutboundWebhookSubscriptionFactory method.childReturnType (same pattern as ProjectFactory/TenantFactory/UserFactory already in baseline). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1006 B
PHP
38 lines
1006 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;
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
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,
|
|
];
|
|
}
|
|
}
|