diff --git a/src/Surfnet/ServiceProviderDashboard/Application/CommandHandler/Entity/DeletePublishedTestEntityCommandHandler.php b/src/Surfnet/ServiceProviderDashboard/Application/CommandHandler/Entity/DeletePublishedTestEntityCommandHandler.php index 59f2c6ea8..05332c23a 100644 --- a/src/Surfnet/ServiceProviderDashboard/Application/CommandHandler/Entity/DeletePublishedTestEntityCommandHandler.php +++ b/src/Surfnet/ServiceProviderDashboard/Application/CommandHandler/Entity/DeletePublishedTestEntityCommandHandler.php @@ -24,11 +24,13 @@ use Surfnet\ServiceProviderDashboard\Application\Exception\EntityNotDeletedException; use Surfnet\ServiceProviderDashboard\Application\Exception\UnableToDeleteEntityException; use Surfnet\ServiceProviderDashboard\Domain\Repository\DeleteManageEntityRepository; +use Surfnet\ServiceProviderDashboard\Domain\Repository\PublishEntityRepository; class DeletePublishedTestEntityCommandHandler implements CommandHandler { public function __construct( private readonly DeleteManageEntityRepository $deleteEntityRepository, + private readonly PublishEntityRepository $publishClient, private readonly LoggerInterface $logger ) { } @@ -56,7 +58,10 @@ public function handle(DeletePublishedTestEntityCommand $command) } if ($response !== DeleteManageEntityRepository::RESULT_SUCCESS) { - throw new EntityNotDeletedException('Deleting the entity yielded an non success response'); + throw new EntityNotDeletedException('Deleting the entity yielded a non success response'); } + + // Push metadata to EngineBlock and other listeners nudging them to update their indexed entity metadata + $this->publishClient->pushMetadata(); } } diff --git a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml index c3cf7078b..4fad8743b 100644 --- a/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml +++ b/src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Resources/config/services.yml @@ -45,6 +45,7 @@ services: class: Surfnet\ServiceProviderDashboard\Application\CommandHandler\Entity\DeletePublishedTestEntityCommandHandler arguments: - '@surfnet.manage.client.delete_client.test_environment' + - '@Surfnet\ServiceProviderDashboard\Infrastructure\Manage\Client\PublishEntityClient' public: true tags: - { name: tactician.handler, command: Surfnet\ServiceProviderDashboard\Application\Command\Entity\DeletePublishedTestEntityCommand } diff --git a/tests/integration/Application/CommandHandler/Entity/DeletePublishedTestEntityCommandHandlerTest.php b/tests/integration/Application/CommandHandler/Entity/DeletePublishedTestEntityCommandHandlerTest.php index 90c6a6090..543c90aef 100644 --- a/tests/integration/Application/CommandHandler/Entity/DeletePublishedTestEntityCommandHandlerTest.php +++ b/tests/integration/Application/CommandHandler/Entity/DeletePublishedTestEntityCommandHandlerTest.php @@ -27,6 +27,7 @@ use Surfnet\ServiceProviderDashboard\Application\Exception\UnableToDeleteEntityException; use Surfnet\ServiceProviderDashboard\Domain\Entity\Constants; use Surfnet\ServiceProviderDashboard\Domain\Repository\DeleteManageEntityRepository; +use Surfnet\ServiceProviderDashboard\Domain\Repository\PublishEntityRepository; class DeletePublishedTestEntityCommandHandlerTest extends MockeryTestCase { @@ -42,18 +43,23 @@ class DeletePublishedTestEntityCommandHandlerTest extends MockeryTestCase private $repository; /** - * @var LoggerInterface|Mock + * @var LoggerInterface&Mock */ private $logger; + private PublishEntityRepository $publishClient; + public function setUp(): void { $this->repository = m::mock(DeleteManageEntityRepository::class); $this->logger = m::mock(LoggerInterface::class); + $this->publishClient = m::mock(PublishEntityRepository::class); + $this->commandHandler = new DeletePublishedTestEntityCommandHandler( $this->repository, + $this->publishClient, $this->logger ); } @@ -62,6 +68,10 @@ public function test_it_can_delete_an_entity_from_test() { $command = new DeletePublishedTestEntityCommand('d6f394b2-08b1-4882-8b32-81688c15c489', Constants::TYPE_SAML); + $this->publishClient + ->shouldReceive('pushMetadata') + ->once(); + $this->repository ->shouldReceive('delete') ->with('d6f394b2-08b1-4882-8b32-81688c15c489', Constants::TYPE_SAML)