feat/004-assignments-scope-tags #4
@ -273,6 +273,22 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('detects orphaned groups', function () {
|
test('detects orphaned groups', function () {
|
||||||
|
// Mock PolicySnapshotService
|
||||||
|
$this->mock(PolicySnapshotService::class, function (MockInterface $mock) {
|
||||||
|
$mock->shouldReceive('fetch')
|
||||||
|
->once()
|
||||||
|
->andReturn([
|
||||||
|
'payload' => [
|
||||||
|
'id' => 'policy-456',
|
||||||
|
'name' => 'Test Policy',
|
||||||
|
'roleScopeTagIds' => ['0', '123'],
|
||||||
|
'settings' => [],
|
||||||
|
],
|
||||||
|
'metadata' => [],
|
||||||
|
'warnings' => [],
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
// Mock AssignmentFetcher
|
// Mock AssignmentFetcher
|
||||||
$this->mock(AssignmentFetcher::class, function (MockInterface $mock) {
|
$this->mock(AssignmentFetcher::class, function (MockInterface $mock) {
|
||||||
$mock->shouldReceive('fetch')
|
$mock->shouldReceive('fetch')
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
use App\Services\Graph\GraphClientInterface;
|
use App\Services\Graph\GraphClientInterface;
|
||||||
use App\Services\Graph\GraphResponse;
|
use App\Services\Graph\GraphResponse;
|
||||||
use App\Services\Graph\ScopeTagResolver;
|
use App\Services\Graph\ScopeTagResolver;
|
||||||
|
use App\Services\Intune\PolicySnapshotService;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Livewire\Livewire;
|
use Livewire\Livewire;
|
||||||
use Mockery\MockInterface;
|
use Mockery\MockInterface;
|
||||||
@ -14,10 +15,27 @@
|
|||||||
uses(RefreshDatabase::class);
|
uses(RefreshDatabase::class);
|
||||||
|
|
||||||
test('backup creation captures snapshots and audit log', function () {
|
test('backup creation captures snapshots and audit log', function () {
|
||||||
|
// Mock PolicySnapshotService
|
||||||
|
$this->mock(PolicySnapshotService::class, function (MockInterface $mock) {
|
||||||
|
$mock->shouldReceive('fetch')
|
||||||
|
->twice() // Called once for each policy
|
||||||
|
->andReturnUsing(function ($tenant, $policy) {
|
||||||
|
return [
|
||||||
|
'payload' => [
|
||||||
|
'id' => $policy->external_id,
|
||||||
|
'name' => $policy->display_name,
|
||||||
|
'roleScopeTagIds' => ['0'],
|
||||||
|
],
|
||||||
|
'metadata' => [],
|
||||||
|
'warnings' => [],
|
||||||
|
];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Mock ScopeTagResolver
|
// Mock ScopeTagResolver
|
||||||
$this->mock(ScopeTagResolver::class, function (MockInterface $mock) {
|
$this->mock(ScopeTagResolver::class, function (MockInterface $mock) {
|
||||||
$mock->shouldReceive('resolve')
|
$mock->shouldReceive('resolve')
|
||||||
->andReturn([]);
|
->andReturn([['id' => '0', 'displayName' => 'Default']]);
|
||||||
});
|
});
|
||||||
|
|
||||||
app()->bind(GraphClientInterface::class, fn () => new class implements GraphClientInterface
|
app()->bind(GraphClientInterface::class, fn () => new class implements GraphClientInterface
|
||||||
@ -67,6 +85,7 @@ public function request(string $method, string $path, array $options = []): Grap
|
|||||||
'policy_type' => 'deviceConfiguration',
|
'policy_type' => 'deviceConfiguration',
|
||||||
'display_name' => 'Policy A',
|
'display_name' => 'Policy A',
|
||||||
'platform' => 'windows',
|
'platform' => 'windows',
|
||||||
|
'last_synced_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$policyB = Policy::create([
|
$policyB = Policy::create([
|
||||||
@ -75,6 +94,7 @@ public function request(string $method, string $path, array $options = []): Grap
|
|||||||
'policy_type' => 'deviceCompliancePolicy',
|
'policy_type' => 'deviceCompliancePolicy',
|
||||||
'display_name' => 'Policy B',
|
'display_name' => 'Policy B',
|
||||||
'platform' => 'windows',
|
'platform' => 'windows',
|
||||||
|
'last_synced_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
@ -95,7 +115,7 @@ public function request(string $method, string $path, array $options = []): Grap
|
|||||||
|
|
||||||
expect($backupSet->item_count)->toBe(2);
|
expect($backupSet->item_count)->toBe(2);
|
||||||
expect($backupSet->items)->toHaveCount(2);
|
expect($backupSet->items)->toHaveCount(2);
|
||||||
expect($backupSet->items->first()->payload['policyId'])->toBe('policy-1');
|
expect($backupSet->items->first()->payload['id'])->toBe('policy-1');
|
||||||
|
|
||||||
$this->assertDatabaseHas('audit_logs', [
|
$this->assertDatabaseHas('audit_logs', [
|
||||||
'action' => 'backup.created',
|
'action' => 'backup.created',
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
'policy_type' => 'deviceConfiguration',
|
'policy_type' => 'deviceConfiguration',
|
||||||
'display_name' => 'Policy A',
|
'display_name' => 'Policy A',
|
||||||
'platform' => 'windows',
|
'platform' => 'windows',
|
||||||
|
'last_synced_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$otherTenant = Tenant::create([
|
$otherTenant = Tenant::create([
|
||||||
@ -35,6 +36,7 @@
|
|||||||
'policy_type' => 'deviceConfiguration',
|
'policy_type' => 'deviceConfiguration',
|
||||||
'display_name' => 'Policy B',
|
'display_name' => 'Policy B',
|
||||||
'platform' => 'windows',
|
'platform' => 'windows',
|
||||||
|
'last_synced_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user