Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push test metadata upon entity deletion #594

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
}
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
);
}
Expand All @@ -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)
Expand Down