Skip to content

Commit 7065264

Browse files
committed
Fix remaining configuration tests
1 parent adf7350 commit 7065264

File tree

3 files changed

+11
-38
lines changed

3 files changed

+11
-38
lines changed

src/Surfnet/StepupMiddleware/ManagementBundle/Controller/ConfigurationController.php

+10
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,34 @@
2020

2121
use DateTime;
2222
use Ramsey\Uuid\Uuid;
23+
use Surfnet\Stepup\Helper\JsonHelper;
24+
use Surfnet\StepupMiddleware\ApiBundle\Exception\BadCommandRequestException;
2325
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
2426
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\UpdateConfigurationCommand;
2527
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline;
28+
use Surfnet\StepupMiddleware\ManagementBundle\Validator\Constraints\HasValidConfigurationStructure;
2629
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2730
use Symfony\Component\HttpFoundation\JsonResponse;
2831
use Symfony\Component\HttpFoundation\Request;
32+
use Symfony\Component\Validator\Validator\ValidatorInterface;
2933

3034
class ConfigurationController extends AbstractController
3135
{
3236
public function __construct(
3337
private readonly TransactionAwarePipeline $pipeline,
38+
private readonly ValidatorInterface $validator,
3439
) {
3540
}
3641

3742
public function update(Request $request): JsonResponse
3843
{
3944
$this->denyAccessUnlessGranted('ROLE_MANAGEMENT');
4045

46+
$violations = $this->validator->validate($request->getContent(), new HasValidConfigurationStructure());
47+
if ($violations->count() > 0) {
48+
throw BadCommandRequestException::withViolations('Invalid configure institutions request', $violations);
49+
}
50+
4151
$command = new UpdateConfigurationCommand();
4252
$command->configuration = $request->getContent();
4353
$command->UUID = (string)Uuid::uuid4();

src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sps.php

-37
This file was deleted.

src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_whitelisted_institution_use_raa.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
return [
2020
'expectedPropertyPath' => 'Institution(surfnet.nl)',
21-
'expectErrorMessageToContain' => 'All values of option "use_raa" should be known institutions.',
21+
'expectErrorMessageToContain' => 'All values of option "use_raa" for "surfnet.nl" should be known institutions.',
2222
'reconfigureInstitutionRequest' => [
2323
'surfnet.nl' => [
2424
"use_ra_locations" => true,

0 commit comments

Comments
 (0)