Replaced legacy tenant and environment bindings in the BaselineDriftEngine with the new ProviderResourceIdentity framework as defined in Spec 382. This ensures cross-environment compatibility and deterministic baseline matching. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #453
52 lines
1.7 KiB
PHP
52 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\BaselineSnapshot;
|
|
use App\Models\BaselineSnapshotItem;
|
|
use App\Support\Baselines\BaselineSubjectKey;
|
|
use App\Support\Baselines\SubjectClass;
|
|
use App\Support\Resources\ResourceIdentity;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<BaselineSnapshotItem>
|
|
*/
|
|
class BaselineSnapshotItemFactory extends Factory
|
|
{
|
|
protected $model = BaselineSnapshotItem::class;
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$displayName = fake()->words(3, true);
|
|
$policyType = 'deviceConfiguration';
|
|
$identity = ResourceIdentity::providerResource('fake-provider', 'policy', fake()->uuid());
|
|
|
|
$subjectKey = BaselineSubjectKey::forProviderResourceIdentity(
|
|
subjectDomain: 'baseline',
|
|
subjectClass: SubjectClass::PolicyBacked,
|
|
subjectTypeKey: $policyType,
|
|
identity: $identity,
|
|
);
|
|
$subjectExternalId = BaselineSubjectKey::workspaceSafeSubjectExternalId($policyType, (string) $subjectKey);
|
|
|
|
return [
|
|
'baseline_snapshot_id' => BaselineSnapshot::factory(),
|
|
'subject_type' => 'policy',
|
|
'subject_external_id' => $subjectExternalId,
|
|
'subject_key' => $subjectKey,
|
|
'policy_type' => $policyType,
|
|
'baseline_hash' => hash('sha256', fake()->uuid()),
|
|
'meta_jsonb' => [
|
|
'display_name' => $displayName,
|
|
'provider_key' => $identity->providerKey,
|
|
'provider_resource_identity' => $identity->toArray(),
|
|
'provider_resource_fingerprint' => $identity->fingerprint(),
|
|
],
|
|
];
|
|
}
|
|
}
|