## Summary Implements Spec 284 for provider-neutral artifact source taxonomy. - add shared artifact source descriptor, resolver, taxonomy, and provider-detail support - update findings, evidence snapshots, stored reports, inventory items, and tenant review surfaces to disclose descriptor-first artifact summaries - add bounded Pest unit, feature, guard, and browser coverage for the taxonomy slice - include the completed Spec 284 package artifacts under `specs/284-provider-neutral-artifact-source-taxonomy/` ## Notes - branch: `284-provider-neutral-artifact-source-taxonomy` - commit: `bf8d59e0` - this PR was created as part of the requested commit/push/PR flow against `platform-dev` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #343
59 lines
2.6 KiB
PHP
59 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Finding;
|
|
use App\Services\Evidence\Sources\FindingsSummarySource;
|
|
|
|
it('derives descriptor-first source taxonomy for findings and summaries', function (): void {
|
|
[$user, $tenant] = createUserWithTenant(ensureDefaultMicrosoftProviderConnection: true);
|
|
$connection = $tenant->providerConnections()->where('provider', 'microsoft')->where('is_default', true)->firstOrFail();
|
|
|
|
$finding = Finding::factory()->create([
|
|
'managed_environment_id' => (int) $tenant->getKey(),
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'finding_type' => Finding::FINDING_TYPE_DRIFT,
|
|
'subject_external_id' => 'device-compliance-policy-1',
|
|
'evidence_jsonb' => [
|
|
'provider_key' => 'microsoft',
|
|
'provider_connection_id' => (int) $connection->getKey(),
|
|
'policy_type' => 'deviceCompliancePolicy',
|
|
'policy_id' => 'device-compliance-policy-1',
|
|
],
|
|
]);
|
|
|
|
$descriptor = $finding->artifactSourceDescriptor()->toArray();
|
|
$providerDetail = $finding->artifactProviderDetail()->toArray();
|
|
|
|
expect($descriptor)->toMatchArray([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'tenant_id' => (int) $tenant->getKey(),
|
|
'managed_environment_id' => (int) $tenant->getKey(),
|
|
'source_family' => 'finding',
|
|
'source_kind' => 'model_summary',
|
|
'provider_key' => 'microsoft',
|
|
'provider_connection_id' => (int) $connection->getKey(),
|
|
'source_target_kind' => 'governed_subject',
|
|
'source_target_identifier' => 'device-compliance-policy-1',
|
|
'detector_key' => 'intune.device_compliance_policy',
|
|
'control_key' => 'endpoint_hardening_compliance',
|
|
'package_run_id' => null,
|
|
])
|
|
->and($descriptor)->not->toHaveKeys(['finding_type', 'policy_type', 'report_type'])
|
|
->and($providerDetail)->toMatchArray([
|
|
'legacy_finding_type' => Finding::FINDING_TYPE_DRIFT,
|
|
'legacy_policy_type' => 'deviceCompliancePolicy',
|
|
'provider_object_type' => 'deviceCompliancePolicy',
|
|
'provider_display_type' => 'Device Compliance',
|
|
]);
|
|
|
|
$summary = app(FindingsSummarySource::class)->collect($tenant);
|
|
$entry = collect($summary['summary_payload']['entries'])->firstWhere('id', (int) $finding->getKey());
|
|
|
|
expect($entry['source_descriptor'])->toMatchArray($descriptor)
|
|
->and($entry['provider_detail'])->toMatchArray($providerDetail)
|
|
->and($entry['control_key'])->toBe('endpoint_hardening_compliance');
|
|
|
|
$this->actingAs($user);
|
|
});
|