Merge branch 'feat/retry-rdap' into develop

This commit is contained in:
Maël Gangloff 2025-10-28 13:13:07 +01:00
commit b77dca9f62
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
17 changed files with 197 additions and 97 deletions

View File

@ -9,6 +9,13 @@ framework:
retry_strategy: retry_strategy:
max_retries: 3 max_retries: 3
multiplier: 2 multiplier: 2
rdap_async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
retry_strategy:
delay: 1000
multiplier: 2
max_delay: 86400000
failed: 'doctrine://default?queue_name=failed' failed: 'doctrine://default?queue_name=failed'
# sync: 'sync://' # sync: 'sync://'
@ -23,11 +30,9 @@ framework:
Symfony\Component\Notifier\Message\SmsMessage: async Symfony\Component\Notifier\Message\SmsMessage: async
App\Message\OrderDomain: async App\Message\OrderDomain: async
App\Message\ProcessWatchlistTrigger: async App\Message\DetectDomainChange: async
App\Message\SendDomainEventNotif: async App\Message\ProcessAllWatchlist: async
App\Message\UpdateDomainsFromWatchlist: async App\Message\ProcessWatchlist: async
App\Message\UpdateRdapServers: async App\Message\UpdateRdapServers: async
App\Message\ValidateConnectorCredentials: async App\Message\ValidateConnectorCredentials: async
App\Message\UpdateDomain: rdap_async
# Route your messages to the transports
# 'App\Message\YourMessage': async

View File

@ -20,7 +20,7 @@ framework:
limit: 5 limit: 5
rate: { interval: '5 minutes' } rate: { interval: '5 minutes' }
rdap_requests: user_rdap_requests:
policy: sliding_window policy: sliding_window
limit: 10 limit: 10
interval: '1 hour' interval: '1 hour'

View File

@ -2,7 +2,7 @@
namespace App\Command; namespace App\Command;
use App\Message\ProcessWatchlistTrigger; use App\Message\ProcessAllWatchlist;
use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -33,7 +33,7 @@ class ProcessWatchlistCommand extends Command
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$this->bus->dispatch(new ProcessWatchlistTrigger()); $this->bus->dispatch(new ProcessAllWatchlist());
$io->success('Watchlist processing triggered!'); $io->success('Watchlist processing triggered!');

View File

@ -3,7 +3,7 @@
namespace App\Command; namespace App\Command;
use App\Entity\Watchlist; use App\Entity\Watchlist;
use App\Message\SendDomainEventNotif; use App\Message\DetectDomainChange;
use App\Repository\DomainRepository; use App\Repository\DomainRepository;
use App\Service\RDAPService; use App\Service\RDAPService;
use Random\Randomizer; use Random\Randomizer;
@ -64,7 +64,7 @@ class RegisterDomainCommand extends Command
/** @var Watchlist $watchlist */ /** @var Watchlist $watchlist */
foreach ($watchlists as $watchlist) { foreach ($watchlists as $watchlist) {
$this->bus->dispatch(new SendDomainEventNotif($watchlist->getToken(), $domain->getLdhName(), $updatedAt)); $this->bus->dispatch(new DetectDomainChange($watchlist->getToken(), $domain->getLdhName(), $updatedAt));
} }
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -12,14 +12,14 @@ class MeController extends AbstractController
{ {
public function __construct( public function __construct(
private readonly SerializerInterface $serializer, private readonly SerializerInterface $serializer,
private readonly RateLimiterFactory $rdapRequestsLimiter, private readonly RateLimiterFactory $userRdapRequestsLimiter,
) { ) {
} }
public function __invoke(): Response public function __invoke(): Response
{ {
$user = $this->getUser(); $user = $this->getUser();
$limiter = $this->rdapRequestsLimiter->create($user->getUserIdentifier()); $limiter = $this->userRdapRequestsLimiter->create($user->getUserIdentifier());
$limit = $limiter->consume(0); $limit = $limiter->consume(0);
$data = $this->serializer->serialize($user, 'json', ['groups' => 'user:list']); $data = $this->serializer->serialize($user, 'json', ['groups' => 'user:list']);

View File

@ -2,7 +2,7 @@
namespace App\Message; namespace App\Message;
final class SendDomainEventNotif final class DetectDomainChange
{ {
public function __construct( public function __construct(
public string $watchlistToken, public string $watchlistToken,

View File

@ -2,7 +2,7 @@
namespace App\Message; namespace App\Message;
final class ProcessWatchlistTrigger final class ProcessAllWatchlist
{ {
/* /*
* Add whatever properties and methods you need * Add whatever properties and methods you need

View File

@ -2,7 +2,7 @@
namespace App\Message; namespace App\Message;
final readonly class UpdateDomainsFromWatchlist final readonly class ProcessWatchlist
{ {
public function __construct( public function __construct(
public string $watchlistToken, public string $watchlistToken,

View File

@ -0,0 +1,15 @@
<?php
namespace App\Message;
use Symfony\Component\Messenger\Attribute\AsMessage;
#[AsMessage('rdap_async')]
final class UpdateDomain
{
public function __construct(
public string $ldhName,
public string $watchlistToken,
) {
}
}

View File

@ -6,7 +6,7 @@ use App\Entity\Domain;
use App\Entity\DomainEvent; use App\Entity\DomainEvent;
use App\Entity\DomainStatus; use App\Entity\DomainStatus;
use App\Entity\Watchlist; use App\Entity\Watchlist;
use App\Message\SendDomainEventNotif; use App\Message\DetectDomainChange;
use App\Notifier\DomainStatusUpdateNotification; use App\Notifier\DomainStatusUpdateNotification;
use App\Notifier\DomainUpdateNotification; use App\Notifier\DomainUpdateNotification;
use App\Repository\DomainEventRepository; use App\Repository\DomainEventRepository;
@ -25,7 +25,7 @@ use Symfony\Component\Mime\Address;
use Symfony\Component\Notifier\Recipient\Recipient; use Symfony\Component\Notifier\Recipient\Recipient;
#[AsMessageHandler] #[AsMessageHandler]
final readonly class SendDomainEventNotifHandler final readonly class DetectDomainChangeHandler
{ {
private Address $sender; private Address $sender;
@ -51,7 +51,7 @@ final readonly class SendDomainEventNotifHandler
* @throws TransportExceptionInterface * @throws TransportExceptionInterface
* @throws \Exception * @throws \Exception
*/ */
public function __invoke(SendDomainEventNotif $message): void public function __invoke(DetectDomainChange $message): void
{ {
/** @var Watchlist $watchlist */ /** @var Watchlist $watchlist */
$watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]); $watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]);

View File

@ -3,8 +3,8 @@
namespace App\MessageHandler; namespace App\MessageHandler;
use App\Entity\Watchlist; use App\Entity\Watchlist;
use App\Message\ProcessWatchlistTrigger; use App\Message\ProcessAllWatchlist;
use App\Message\UpdateDomainsFromWatchlist; use App\Message\ProcessWatchlist;
use App\Repository\WatchlistRepository; use App\Repository\WatchlistRepository;
use Random\Randomizer; use Random\Randomizer;
use Symfony\Component\Messenger\Attribute\AsMessageHandler; use Symfony\Component\Messenger\Attribute\AsMessageHandler;
@ -12,7 +12,7 @@ use Symfony\Component\Messenger\Exception\ExceptionInterface;
use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\MessageBusInterface;
#[AsMessageHandler] #[AsMessageHandler]
final readonly class ProcessWatchlistTriggerHandler final readonly class ProcessAllWatchlistHandler
{ {
public function __construct( public function __construct(
private WatchlistRepository $watchlistRepository, private WatchlistRepository $watchlistRepository,
@ -23,11 +23,13 @@ final readonly class ProcessWatchlistTriggerHandler
/** /**
* @throws ExceptionInterface * @throws ExceptionInterface
*/ */
public function __invoke(ProcessWatchlistTrigger $message): void public function __invoke(ProcessAllWatchlist $message): void
{ {
/* /*
* We shuffle the watch lists to process them in an order that we consider random. * We shuffle the watch lists to process them in an order that we consider random.
* The shuffling is provided by a high-level API of a CSPRNG number generator. * The shuffling is provided by a high-level API of a CSPRNG number generator.
*
* ProcessAllWatchlist -> ProcessWatchlist -> UpdateDomain -> (DetectDomainChange & OrderDomain)
*/ */
$randomizer = new Randomizer(); $randomizer = new Randomizer();
@ -35,7 +37,7 @@ final readonly class ProcessWatchlistTriggerHandler
/** @var Watchlist $watchlist */ /** @var Watchlist $watchlist */
foreach ($watchlists as $watchlist) { foreach ($watchlists as $watchlist) {
$this->bus->dispatch(new UpdateDomainsFromWatchlist($watchlist->getToken())); $this->bus->dispatch(new ProcessWatchlist($watchlist->getToken()));
} }
} }
} }

View File

@ -4,53 +4,36 @@ namespace App\MessageHandler;
use App\Entity\Domain; use App\Entity\Domain;
use App\Entity\Watchlist; use App\Entity\Watchlist;
use App\Exception\DomainNotFoundException;
use App\Exception\TldNotSupportedException;
use App\Exception\UnknownRdapServerException;
use App\Message\OrderDomain; use App\Message\OrderDomain;
use App\Message\SendDomainEventNotif; use App\Message\ProcessWatchlist;
use App\Message\UpdateDomainsFromWatchlist; use App\Message\UpdateDomain;
use App\Notifier\DomainDeletedNotification;
use App\Repository\DomainRepository;
use App\Repository\WatchlistRepository; use App\Repository\WatchlistRepository;
use App\Service\ChatNotificationService;
use App\Service\Provider\AbstractProvider; use App\Service\Provider\AbstractProvider;
use App\Service\Provider\CheckDomainProviderInterface; use App\Service\Provider\CheckDomainProviderInterface;
use App\Service\RDAPService; use App\Service\RDAPService;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler; use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Notifier\Recipient\Recipient;
#[AsMessageHandler] #[AsMessageHandler]
final readonly class UpdateDomainsFromWatchlistHandler final readonly class ProcessWatchlistHandler
{ {
private Address $sender;
public function __construct( public function __construct(
private RDAPService $RDAPService, private RDAPService $RDAPService,
private ChatNotificationService $chatNotificationService,
private MailerInterface $mailer,
string $mailerSenderEmail,
string $mailerSenderName,
private MessageBusInterface $bus, private MessageBusInterface $bus,
private WatchlistRepository $watchlistRepository, private WatchlistRepository $watchlistRepository,
private LoggerInterface $logger, private LoggerInterface $logger,
#[Autowire(service: 'service_container')] #[Autowire(service: 'service_container')]
private ContainerInterface $locator, private ContainerInterface $locator,
private DomainRepository $domainRepository,
) { ) {
$this->sender = new Address($mailerSenderEmail, $mailerSenderName);
} }
/** /**
* @throws \Throwable * @throws \Throwable
*/ */
public function __invoke(UpdateDomainsFromWatchlist $message): void public function __invoke(ProcessWatchlist $message): void
{ {
/** @var Watchlist $watchlist */ /** @var Watchlist $watchlist */
$watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]); $watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]);
@ -96,39 +79,8 @@ final readonly class UpdateDomainsFromWatchlistHandler
*/ */
/** @var Domain $domain */ /** @var Domain $domain */
foreach ($watchlist->getDomains()->filter(fn ($domain) => $this->RDAPService->isToBeUpdated($domain, false, null !== $watchlist->getConnector())) as $domain foreach ($watchlist->getDomains()->filter(fn ($domain) => $this->RDAPService->isToBeUpdated($domain, false, null !== $watchlist->getConnector())) as $domain) {
) { $this->bus->dispatch(new UpdateDomain($domain->getLdhName(), $watchlist->getToken()));
$updatedAt = $domain->getUpdatedAt();
$deleted = $domain->getDeleted();
try {
/*
* Domain name update
* We send messages that correspond to the sending of notifications that will not be processed here.
*/
$this->RDAPService->registerDomain($domain->getLdhName());
$this->bus->dispatch(new SendDomainEventNotif($watchlist->getToken(), $domain->getLdhName(), $updatedAt));
} catch (DomainNotFoundException) {
$newDomain = $this->domainRepository->findOneBy(['ldhName' => $domain->getLdhName()]);
if (!$deleted && null !== $newDomain && $newDomain->getDeleted()) {
$notification = new DomainDeletedNotification($this->sender, $domain);
$this->mailer->send($notification->asEmailMessage(new Recipient($watchlist->getUser()->getEmail()))->getMessage());
$this->chatNotificationService->sendChatNotification($watchlist, $notification);
}
if ($watchlist->getConnector()) {
/*
* If the domain name no longer appears in the WHOIS AND a connector is associated with this Watchlist,
* this connector is used to purchase the domain name.
*/
$this->bus->dispatch(new OrderDomain($watchlist->getToken(), $domain->getLdhName()));
}
} catch (TldNotSupportedException|UnknownRdapServerException) {
/*
* In this case, the domain name can no longer be updated. Unfortunately, there is nothing more that can be done.
*/
}
} }
} }

View File

@ -0,0 +1,126 @@
<?php
namespace App\MessageHandler;
use App\Entity\RdapServer;
use App\Entity\Watchlist;
use App\Exception\DomainNotFoundException;
use App\Exception\MalformedDomainException;
use App\Exception\TldNotSupportedException;
use App\Exception\UnknownRdapServerException;
use App\Exception\UnsupportedDsnSchemeException;
use App\Message\DetectDomainChange;
use App\Message\OrderDomain;
use App\Message\UpdateDomain;
use App\Notifier\DomainDeletedNotification;
use App\Repository\DomainRepository;
use App\Repository\WatchlistRepository;
use App\Service\ChatNotificationService;
use App\Service\RDAPService;
use Doctrine\ORM\OptimisticLockException;
use Psr\Log\LoggerInterface;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Messenger\Exception\ExceptionInterface;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Notifier\Recipient\Recipient;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
#[AsMessageHandler]
final readonly class UpdateDomainHandler
{
private Address $sender;
public function __construct(
private RDAPService $RDAPService,
private ChatNotificationService $chatNotificationService,
private MailerInterface $mailer,
string $mailerSenderEmail,
string $mailerSenderName,
private MessageBusInterface $bus,
private WatchlistRepository $watchlistRepository,
private DomainRepository $domainRepository,
private LoggerInterface $logger,
) {
$this->sender = new Address($mailerSenderEmail, $mailerSenderName);
}
/**
* @throws TransportExceptionInterface
* @throws \Symfony\Component\Notifier\Exception\TransportExceptionInterface
* @throws RedirectionExceptionInterface
* @throws DecodingExceptionInterface
* @throws ClientExceptionInterface
* @throws OptimisticLockException
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
* @throws UnsupportedDsnSchemeException
* @throws ServerExceptionInterface
* @throws MalformedDomainException
* @throws ExceptionInterface
* @throws \Exception
*/
public function __invoke(UpdateDomain $message): void
{
$domain = $this->domainRepository->findOneBy(['ldhName' => $message->ldhName]);
/** @var ?RdapServer $rdapServer */
$rdapServer = $domain->getTld()->getRdapServers()->first();
if (null === $rdapServer) {
$this->logger->warning('No RDAP server for this domain name', [
'ldhName' => $domain->getLdhName(),
]);
return;
}
$watchlist = $this->watchlistRepository->findOneBy(['token' => $message->watchlistToken]);
if (!$this->RDAPService->isToBeUpdated($domain, false, null !== $watchlist->getConnector())) {
$this->logger->debug('The domain name is already present in the database and does not need to be updated at this time', [
'ldhName' => $domain->getLdhName(),
]);
return;
}
$updatedAt = $domain->getUpdatedAt();
$deleted = $domain->getDeleted();
try {
/*
* Domain name update
* We send messages that correspond to the sending of notifications that will not be processed here.
*/
$this->RDAPService->registerDomain($domain->getLdhName());
} catch (DomainNotFoundException) {
$newDomain = $this->domainRepository->findOneBy(['ldhName' => $domain->getLdhName()]);
if (!$deleted && null !== $newDomain && $newDomain->getDeleted()) {
$notification = new DomainDeletedNotification($this->sender, $domain);
$this->mailer->send($notification->asEmailMessage(new Recipient($watchlist->getUser()->getEmail()))->getMessage());
$this->chatNotificationService->sendChatNotification($watchlist, $notification);
}
if ($watchlist->getConnector()) {
/*
* If the domain name no longer appears in the WHOIS AND a connector is associated with this Watchlist,
* this connector is used to purchase the domain name.
*/
$this->bus->dispatch(new OrderDomain($watchlist->getToken(), $domain->getLdhName()));
}
} catch (TldNotSupportedException|UnknownRdapServerException) {
/*
* In this case, the domain name can no longer be updated. Unfortunately, there is nothing more that can be done.
*/
}
/** @var Watchlist $wl */
foreach ($domain->getWatchlists()->getIterator() as $wl) {
$this->bus->dispatch(new DetectDomainChange($wl->getToken(), $domain->getLdhName(), $updatedAt));
}
}
}

View File

@ -2,15 +2,15 @@
namespace App\Scheduler; namespace App\Scheduler;
use App\Message\ProcessWatchlistTrigger; use App\Message\ProcessAllWatchlist;
use Symfony\Component\Scheduler\Attribute\AsSchedule; use Symfony\Component\Scheduler\Attribute\AsSchedule;
use Symfony\Component\Scheduler\RecurringMessage; use Symfony\Component\Scheduler\RecurringMessage;
use Symfony\Component\Scheduler\Schedule; use Symfony\Component\Scheduler\Schedule;
use Symfony\Component\Scheduler\ScheduleProviderInterface; use Symfony\Component\Scheduler\ScheduleProviderInterface;
use Symfony\Contracts\Cache\CacheInterface; use Symfony\Contracts\Cache\CacheInterface;
#[AsSchedule('notif_watchlist')] #[AsSchedule('process_watchlist')]
final readonly class SendNotifWatchlistTriggerSchedule implements ScheduleProviderInterface final readonly class ProcessWatchlistSchedule implements ScheduleProviderInterface
{ {
public function __construct( public function __construct(
private CacheInterface $cache, private CacheInterface $cache,
@ -21,7 +21,7 @@ final readonly class SendNotifWatchlistTriggerSchedule implements ScheduleProvid
{ {
return (new Schedule()) return (new Schedule())
->add( ->add(
RecurringMessage::every('5 minutes', new ProcessWatchlistTrigger()), RecurringMessage::every('5 minutes', new ProcessAllWatchlist()),
) )
->stateful($this->cache); ->stateful($this->cache);
} }

View File

@ -10,7 +10,7 @@ use App\Exception\DomainNotFoundException;
use App\Exception\MalformedDomainException; use App\Exception\MalformedDomainException;
use App\Exception\TldNotSupportedException; use App\Exception\TldNotSupportedException;
use App\Exception\UnknownRdapServerException; use App\Exception\UnknownRdapServerException;
use App\Message\SendDomainEventNotif; use App\Message\DetectDomainChange;
use App\Repository\DomainRepository; use App\Repository\DomainRepository;
use App\Service\RDAPService; use App\Service\RDAPService;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -37,7 +37,7 @@ readonly class AutoRegisterDomainProvider implements ProviderInterface
private RDAPService $RDAPService, private RDAPService $RDAPService,
private KernelInterface $kernel, private KernelInterface $kernel,
private ParameterBagInterface $parameterBag, private ParameterBagInterface $parameterBag,
private RateLimiterFactory $rdapRequestsLimiter, private RateLimiterFactory $userRdapRequestsLimiter,
private Security $security, private Security $security,
private LoggerInterface $logger, private LoggerInterface $logger,
private DomainRepository $domainRepository, private DomainRepository $domainRepository,
@ -92,7 +92,7 @@ readonly class AutoRegisterDomainProvider implements ProviderInterface
} }
if (false === $this->kernel->isDebug() && true === $this->parameterBag->get('limited_features')) { if (false === $this->kernel->isDebug() && true === $this->parameterBag->get('limited_features')) {
$limiter = $this->rdapRequestsLimiter->create($userId); $limiter = $this->userRdapRequestsLimiter->create($userId);
$limit = $limiter->consume(); $limit = $limiter->consume();
if (!$limit->isAccepted()) { if (!$limit->isAccepted()) {
@ -131,7 +131,7 @@ readonly class AutoRegisterDomainProvider implements ProviderInterface
/** @var Watchlist $watchlist */ /** @var Watchlist $watchlist */
foreach ($watchlists as $watchlist) { foreach ($watchlists as $watchlist) {
$this->bus->dispatch(new SendDomainEventNotif($watchlist->getToken(), $domain->getLdhName(), $updatedAt)); $this->bus->dispatch(new DetectDomainChange($watchlist->getToken(), $domain->getLdhName(), $updatedAt));
} }
return $domain; return $domain;

View File

@ -2,9 +2,9 @@
namespace App\Tests\MessageHandler; namespace App\Tests\MessageHandler;
use App\Message\ProcessWatchlistTrigger; use App\Message\ProcessAllWatchlist;
use App\Message\UpdateDomainsFromWatchlist; use App\Message\ProcessWatchlist;
use App\MessageHandler\ProcessWatchlistTriggerHandler; use App\MessageHandler\ProcessAllWatchlistHandler;
use App\Tests\State\WatchlistUpdateProcessorTest; use App\Tests\State\WatchlistUpdateProcessorTest;
use PHPUnit\Framework\Attributes\DependsExternal; use PHPUnit\Framework\Attributes\DependsExternal;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@ -16,16 +16,16 @@ final class ProcessWatchlistTriggerHandlerTest extends KernelTestCase
public function testSendMessage() public function testSendMessage()
{ {
$container = self::getContainer(); $container = self::getContainer();
$handler = $container->get(ProcessWatchlistTriggerHandler::class); $handler = $container->get(ProcessAllWatchlistHandler::class);
/** @var TraceableMessageBus $bus */ /** @var TraceableMessageBus $bus */
$bus = $container->get('messenger.bus.default'); $bus = $container->get('messenger.bus.default');
$bus->reset(); $bus->reset();
$handler(new ProcessWatchlistTrigger()); $handler(new ProcessAllWatchlist());
$dispatched = $bus->getDispatchedMessages(); $dispatched = $bus->getDispatchedMessages();
$this->assertNotEmpty($dispatched); $this->assertNotEmpty($dispatched);
$this->assertInstanceOf(UpdateDomainsFromWatchlist::class, $dispatched[0]['message']); $this->assertInstanceOf(ProcessWatchlist::class, $dispatched[0]['message']);
} }
} }

View File

@ -4,8 +4,8 @@ namespace App\Tests\MessageHandler;
use App\Entity\Domain; use App\Entity\Domain;
use App\Entity\Watchlist; use App\Entity\Watchlist;
use App\Message\UpdateDomainsFromWatchlist; use App\Message\ProcessWatchlist;
use App\MessageHandler\UpdateDomainsFromWatchlistHandler; use App\MessageHandler\ProcessWatchlistHandler;
use App\Tests\State\WatchlistUpdateProcessorTest; use App\Tests\State\WatchlistUpdateProcessorTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\Attributes\DependsExternal; use PHPUnit\Framework\Attributes\DependsExternal;
@ -20,7 +20,7 @@ final class UpdateDomainsFromWatchlistHandlerTest extends KernelTestCase
{ {
$container = self::getContainer(); $container = self::getContainer();
$entityManager = $container->get(EntityManagerInterface::class); $entityManager = $container->get(EntityManagerInterface::class);
$handler = $container->get(UpdateDomainsFromWatchlistHandler::class); $handler = $container->get(ProcessWatchlistHandler::class);
$bus = $container->get('messenger.bus.default'); $bus = $container->get('messenger.bus.default');
$deletedDomainLdhName = new UuidV4().'.com'; $deletedDomainLdhName = new UuidV4().'.com';
@ -40,7 +40,7 @@ final class UpdateDomainsFromWatchlistHandlerTest extends KernelTestCase
/* @var TraceableMessageBus $bus */ /* @var TraceableMessageBus $bus */
$bus->reset(); $bus->reset();
$handler(new UpdateDomainsFromWatchlist($watchlist->getToken())); $handler(new ProcessWatchlist($watchlist->getToken()));
$this->expectNotToPerformAssertions(); $this->expectNotToPerformAssertions();
} }