set('portal-monitor.config_api_key', 'service-key'); $this->getJson('/api/v1/internal/portal-monitor/vcenter') ->assertUnauthorized() ->assertJsonMissingPath('data'); } public function test_returns_active_vcenter_credentials_from_module_vcenter(): void { config()->set('portal-monitor.config_api_key', 'service-key'); vCenter::query()->create([ 'host' => '10.0.0.20', 'user' => 'monitor@example.local', 'password' => SignRSA::EncryptFunc('secret-value'), 'status' => 1, ]); $this->withHeader('X-Portal-Monitor-Key', 'service-key') ->getJson('/api/v1/internal/portal-monitor/vcenter') ->assertOk() ->assertHeader('Cache-Control', 'no-store, private') ->assertJsonPath('data.host', '10.0.0.20') ->assertJsonPath('data.port', 443) ->assertJsonPath('data.username', 'monitor@example.local') ->assertJsonPath('data.password', 'secret-value'); } public function test_returns_sanitized_error_when_no_active_vcenter_exists(): void { config()->set('portal-monitor.config_api_key', 'service-key'); $this->withHeader('X-Portal-Monitor-Key', 'service-key') ->getJson('/api/v1/internal/portal-monitor/vcenter') ->assertStatus(503) ->assertJson([ 'error' => true, 'message' => 'Active vCenter configuration is unavailable', ]); } }