TenantAtlas/tests/Unit/Badges/PolicyBadgesTest.php
ahmido c6e7591d19 feat: add Intune RBAC inventory and backup support (#155)
## Summary
- add Intune RBAC role definitions and role assignments as foundation-backed inventory, backup, and versioned snapshot types
- add RBAC-specific normalization, coverage, permission-warning handling, and preview-only restore safety behavior across existing Filament and service surfaces
- add spec 127 artifacts, contracts, audits, and focused regression coverage for inventory, backup, versioning, verification, and authorization behavior

## Testing
- `vendor/bin/sail bin pint --dirty --format agent`
- `vendor/bin/sail artisan test --compact tests/Feature/Inventory/InventorySyncServiceTest.php tests/Feature/Filament/InventoryCoverageTableTest.php tests/Feature/FoundationBackupTest.php tests/Feature/Filament/RestoreExecutionTest.php tests/Feature/RestoreUnknownPolicyTypeSafetyTest.php tests/Unit/GraphContractRegistryTest.php tests/Unit/FoundationSnapshotServiceTest.php tests/Feature/Verification/IntuneRbacPermissionCoverageTest.php tests/Unit/IntuneRoleDefinitionNormalizerTest.php tests/Unit/IntuneRoleAssignmentNormalizerTest.php`

## Notes
- tasks in `specs/127-rbac-inventory-backup/tasks.md` are complete except `T041`, which is the documented manual QA validation step

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #155
2026-03-09 10:40:51 +00:00

53 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
use App\Support\Badges\BadgeCatalog;
use App\Support\Badges\BadgeDomain;
use App\Support\Inventory\InventoryPolicyTypeMeta;
it('maps policy snapshot mode values to canonical badge semantics', function (): void {
$full = BadgeCatalog::spec(BadgeDomain::PolicySnapshotMode, 'full');
expect($full->label)->toBe('Full');
expect($full->color)->toBe('success');
$metadataOnly = BadgeCatalog::spec(BadgeDomain::PolicySnapshotMode, 'metadata_only');
expect($metadataOnly->label)->toBe('Metadata only');
expect($metadataOnly->color)->toBe('warning');
});
it('maps policy restore mode values to canonical badge semantics', function (): void {
$enabled = BadgeCatalog::spec(BadgeDomain::PolicyRestoreMode, 'enabled');
expect($enabled->label)->toBe('Enabled');
expect($enabled->color)->toBe('success');
$previewOnly = BadgeCatalog::spec(BadgeDomain::PolicyRestoreMode, 'preview-only');
expect($previewOnly->label)->toBe('Preview only');
expect($previewOnly->color)->toBe('warning');
});
it('maps policy risk values to canonical badge semantics', function (): void {
$low = BadgeCatalog::spec(BadgeDomain::PolicyRisk, 'low');
expect($low->label)->toBe('Low');
expect($low->color)->toBe('gray');
$mediumHigh = BadgeCatalog::spec(BadgeDomain::PolicyRisk, 'medium-high');
expect($mediumHigh->label)->toBe('Medium-high');
expect($mediumHigh->color)->toBe('danger');
});
it('maps ignored-at presence to canonical badge semantics', function (): void {
$notIgnored = BadgeCatalog::spec(BadgeDomain::IgnoredAt, null);
expect($notIgnored->label)->toBe('No');
expect($notIgnored->color)->toBe('gray');
$ignored = BadgeCatalog::spec(BadgeDomain::IgnoredAt, '2026-01-01T00:00:00Z');
expect($ignored->label)->toBe('Yes');
expect($ignored->color)->toBe('warning');
});
it('maps RBAC foundation restore modes to preview-only metadata', function (): void {
expect(InventoryPolicyTypeMeta::restoreMode('intuneRoleDefinition'))->toBe('preview-only');
expect(InventoryPolicyTypeMeta::restoreMode('intuneRoleAssignment'))->toBe('preview-only');
});