TenantAtlas/apps/platform/tests/Unit/Support/TenantConfiguration/Spec431ExchangePowerShellOperationRegistrationTest.php
2026-07-07 15:54:34 +02:00

52 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
use App\Services\Providers\ProviderOperationRegistry;
use App\Services\TenantConfiguration\ExchangePowerShellInvocationGate;
use App\Support\Auth\Capabilities;
use App\Support\OperationCatalog;
use App\Support\OperationRunType;
use App\Support\Operations\OperationRunCapabilityResolver;
use App\Support\Providers\Capabilities\ProviderCapabilityRegistry;
it('Spec431 registers one internal Exchange PowerShell invocation operation boundary', function (): void {
$providerOperations = app(ProviderOperationRegistry::class);
$providerCapabilities = app(ProviderCapabilityRegistry::class);
expect(OperationRunType::TenantConfigurationExchangePowerShellInvocation->value)
->toBe('tenant_configuration.exchange_powershell_invocation')
->and(OperationRunType::values())->toContain('tenant_configuration.exchange_powershell_invocation')
->and(OperationCatalog::canonicalCode('tenant_configuration.exchange_powershell_invocation'))
->toBe('tenant_configuration.exchange_powershell_invocation')
->and(OperationCatalog::label('tenant_configuration.exchange_powershell_invocation'))
->toBe('Exchange PowerShell invocation')
->and(app(OperationRunCapabilityResolver::class)->requiredExecutionCapabilityForType('tenant_configuration.exchange_powershell_invocation'))
->toBe(Capabilities::PROVIDER_RUN);
expect($providerOperations->get('tenant_configuration.exchange_powershell_invocation'))
->toMatchArray([
'operation_type' => 'tenant_configuration.exchange_powershell_invocation',
'module' => 'exchange_powershell',
'required_capability' => Capabilities::PROVIDER_RUN,
'provider_capability_keys' => ['exchange_powershell_invoke'],
])
->and($providerOperations->bindingFor('tenant_configuration.exchange_powershell_invocation', 'microsoft')['binding_status'])
->toBe(ProviderOperationRegistry::BINDING_ACTIVE)
->and($providerCapabilities->get('exchange_powershell_invoke')->operationTypes)
->toBe(['tenant_configuration.exchange_powershell_invocation'])
->and($providerCapabilities->get('exchange_powershell_invoke')->providerRequirementKeys)
->toBe(['provider.exchange_powershell_invocation', 'permissions.admin_consent']);
});
it('Spec431 defaults the invocation feature gate off', function (): void {
putenv('TENANTPILOT_EXCHANGE_POWERSHELL_INVOCATION_ENABLED');
unset($_ENV['TENANTPILOT_EXCHANGE_POWERSHELL_INVOCATION_ENABLED'], $_SERVER['TENANTPILOT_EXCHANGE_POWERSHELL_INVOCATION_ENABLED']);
$config = require config_path('tenantpilot.php');
expect($config['features']['exchange_powershell_invocation'])->toBeFalse()
->and(ExchangePowerShellInvocationGate::FEATURE_CONFIG_PATH)
->toBe('tenantpilot.features.exchange_powershell_invocation');
});