chore: merge master

This commit is contained in:
Maël Gangloff
2025-03-03 12:58:38 +01:00
10 changed files with 112 additions and 42 deletions

View File

@@ -13,7 +13,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Validator\ConstraintViolationInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
@@ -58,8 +57,8 @@ abstract class AbstractProvider
$data = $this->serializer->denormalize($this->verifyLegalAuthData($authData), $this->dtoClass);
$violations = $this->validator->validate($data);
if ($violations->count()) {
throw new BadRequestHttpException(implode('\n', array_map(fn (ConstraintViolationInterface $v) => $v->getPropertyPath().': '.$v->getMessage(), iterator_to_array($violations))));
if ($violations->count() > 0) {
throw new BadRequestHttpException((string) $violations);
}
return [

View File

@@ -2,6 +2,7 @@
namespace App\Service\Connector;
use App\Dto\Connector\NameComProviderDto;
use App\Entity\Domain;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
@@ -21,9 +22,10 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
#[Autoconfigure(public: true)]
class NameComProvider extends AbstractProvider
{
protected string $dtoClass = NameComProvider::class;
protected string $dtoClass = NameComProviderDto::class;
public function __construct(CacheItemPoolInterface $cacheItemPool,
public function __construct(
CacheItemPoolInterface $cacheItemPool,
private readonly HttpClientInterface $client,
private readonly KernelInterface $kernel,
DenormalizerInterface&NormalizerInterface $serializer,

View File

@@ -150,7 +150,7 @@ readonly class RDAPService
$this->updateDomainStatus($domain, $rdapData);
if (in_array('free', $domain->getStatus())) {
throw new NotFoundHttpException('The domain name is not present in the WHOIS database.');
throw new NotFoundHttpException("The domain name $idnDomain is not present in the WHOIS database.");
}
$domain->setRdapServer($rdapServer)->setDelegationSigned(isset($rdapData['secureDNS']['delegationSigned']) && true === $rdapData['secureDNS']['delegationSigned']);
@@ -170,13 +170,13 @@ readonly class RDAPService
return $domain;
}
private function getTld($domain): Tld
private function getTld(string $domain): Tld
{
if (!str_contains($domain, '.')) {
$tldEntity = $this->tldRepository->findOneBy(['tld' => '']);
if (null == $tldEntity) {
throw new NotFoundHttpException('The requested TLD is not yet supported, please try again with another one');
throw new NotFoundHttpException("The requested TLD $domain is not yet supported, please try again with another one");
}
return $tldEntity;
@@ -192,7 +192,7 @@ readonly class RDAPService
$tldEntity = $this->tldRepository->findOneBy(['tld' => $tld]);
if (null === $tldEntity) {
throw new NotFoundHttpException('The requested TLD is not yet supported, please try again with another one');
throw new NotFoundHttpException("The requested TLD $tld is not yet supported, please try again with another one");
}
return $tldEntity;
@@ -205,10 +205,11 @@ readonly class RDAPService
private function fetchRdapServer(Tld $tld): RdapServer
{
$rdapServer = $this->rdapServerRepository->findOneBy(['tld' => $tld], ['updatedAt' => 'DESC']);
$tldString = $tld->getTld();
$rdapServer = $this->rdapServerRepository->findOneBy(['tld' => $tldString], ['updatedAt' => 'DESC']);
if (null === $rdapServer) {
throw new NotFoundHttpException('Unable to determine which RDAP server to contact');
throw new NotFoundHttpException("TLD $tldString : Unable to determine which RDAP server to contact");
}
return $rdapServer;
@@ -262,7 +263,7 @@ readonly class RDAPService
$this->em->flush();
}
throw new NotFoundHttpException('The domain name is not present in the WHOIS database.');
throw new NotFoundHttpException("The domain name $idnDomain is not present in the WHOIS database.");
}
return $e;