diff --git a/classes/Rest/Controllers/WarehouseControllerProvider.php b/classes/Rest/Controllers/WarehouseControllerProvider.php index c816ab5ec5..5b40aaac2b 100644 --- a/classes/Rest/Controllers/WarehouseControllerProvider.php +++ b/classes/Rest/Controllers/WarehouseControllerProvider.php @@ -2126,8 +2126,9 @@ private function getUserStore(\XDUser $user, $realm) * not included; if an invalid start date, * end date, realm, field alias, or filter * key is provided; if the end date is - * before the start date; or if the offset - * is negative. + * before the start date; if the offset is + * negative; or if the requested realm is + * not configured to provide raw data. */ public function getRawData(Request $request, Application $app) { @@ -2135,6 +2136,9 @@ public function getRawData(Request $request, Application $app) $params = $this->validateRawDataParams($request, $user); $realmManager = new RealmManager(); $queryClass = $realmManager->getRawDataQueryClass($params['realm']); + if (!class_exists($queryClass)) { + throw new BadRequestHttpException('The requested realm is not configured to provide raw data.'); + } $logger = $this->getRawDataLogger(); $streamCallback = function () use ( $user, diff --git a/tests/integration/lib/Rest/WarehouseControllerProviderTest.php b/tests/integration/lib/Rest/WarehouseControllerProviderTest.php index ea3107c0c9..f194f38b23 100644 --- a/tests/integration/lib/Rest/WarehouseControllerProviderTest.php +++ b/tests/integration/lib/Rest/WarehouseControllerProviderTest.php @@ -830,6 +830,11 @@ public function provideGetRawData() ['realm' => 'foo'], parent::validateBadRequestResponse('Invalid realm.') ], + [ + 'realm_not_configured', + ['realm' => 'Storage'], + parent::validateBadRequestResponse('The requested realm is not configured to provide raw data.') + ], [ 'invalid_fields', ['fields' => 'foo,bar;'],