TenantAtlas/database/factories/ProviderCredentialFactory.php
2026-03-13 17:26:49 +01:00

43 lines
1.2 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\ProviderConnection;
use App\Models\ProviderCredential;
use App\Support\Providers\ProviderCredentialKind;
use App\Support\Providers\ProviderCredentialSource;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<ProviderCredential>
*/
class ProviderCredentialFactory extends Factory
{
protected $model = ProviderCredential::class;
public function definition(): array
{
return [
'provider_connection_id' => ProviderConnection::factory()->dedicated(),
'type' => 'client_secret',
'credential_kind' => ProviderCredentialKind::ClientSecret->value,
'source' => ProviderCredentialSource::DedicatedManual->value,
'last_rotated_at' => now(),
'expires_at' => now()->addYear(),
'payload' => [
'client_id' => fake()->uuid(),
'client_secret' => fake()->sha1(),
],
];
}
public function legacyMigrated(): static
{
return $this->state(fn (): array => [
'source' => ProviderCredentialSource::LegacyMigrated->value,
'last_rotated_at' => null,
'expires_at' => null,
]);
}
}