test: add test for Namecheap

This commit is contained in:
Maël Gangloff 2025-10-19 13:27:33 +02:00
parent 7d0642eb6a
commit 213617c3c1
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
4 changed files with 32 additions and 1 deletions

View File

@ -15,3 +15,11 @@ GANDI_PAT_TOKEN=
NAMECOM_USERNAME= NAMECOM_USERNAME=
NAMECOM_PASSWORD= NAMECOM_PASSWORD=
NAMECHEAP_USERNAME=
NAMECHEAP_TOKEN=
# Typically your IP address, this envvar is required for
# some connectors that need to be provided with your host's
# outgoing IP address.
OUTGOING_IP=

View File

@ -52,3 +52,5 @@ when@test:
gandi_pat_token: '%env(string:GANDI_PAT_TOKEN)%' gandi_pat_token: '%env(string:GANDI_PAT_TOKEN)%'
namecom_username: '%env(string:NAMECOM_USERNAME)%' namecom_username: '%env(string:NAMECOM_USERNAME)%'
namecom_password: '%env(string:NAMECOM_PASSWORD)%' namecom_password: '%env(string:NAMECOM_PASSWORD)%'
namecheap_username: '%env(string:NAMECHEAP_USERNAME)%'
namecheap_token: '%env(string:NAMECHEAP_TOKEN)%'

View File

@ -11,6 +11,7 @@ use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\CacheItemPoolInterface;
use Psr\Cache\InvalidArgumentException; use Psr\Cache\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Validator\Validator\ValidatorInterface;
@ -37,6 +38,7 @@ class NamecheapProvider extends AbstractProvider
private readonly string $outgoingIp, private readonly string $outgoingIp,
DenormalizerInterface&NormalizerInterface $serializer, DenormalizerInterface&NormalizerInterface $serializer,
ValidatorInterface $validator, ValidatorInterface $validator,
private readonly KernelInterface $kernel,
) { ) {
parent::__construct($cacheItemPool, $serializer, $validator); parent::__construct($cacheItemPool, $serializer, $validator);
} }
@ -99,7 +101,7 @@ class NamecheapProvider extends AbstractProvider
'ClientIp' => $this->outgoingIp, 'ClientIp' => $this->outgoingIp,
], $parameters); ], $parameters);
$response = $this->client->request('POST', $dryRun ? self::SANDBOX_BASE_URL : self::BASE_URL, [ $response = $this->client->request('POST', ($this->kernel->isDebug() || $dryRun) ? self::SANDBOX_BASE_URL : self::BASE_URL, [
'query' => $actualParams, 'query' => $actualParams,
]); ]);

View File

@ -54,6 +54,25 @@ class AbstractProviderTest extends ApiTestCase
]); ]);
} }
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
public function testNamecheap()
{
$namecheapUsername = static::getContainer()->getParameter('namecheap_username');
$namecheapToken = static::getContainer()->getParameter('namecheap_token');
if (!$namecheapUsername || !$namecheapToken) {
$this->markTestSkipped('Missing Namecheap username or token');
}
$this->testGenericProvider(ConnectorProvider::NAMECHEAP, [
'waiveRetractationPeriod' => true,
'acceptConditions' => true,
'ownerLegalAge' => true,
'ApiUser' => $namecheapUsername,
'ApiKey' => $namecheapToken,
]);
}
private function testGenericProvider(ConnectorProvider $connectorProvider, array $authData): void private function testGenericProvider(ConnectorProvider $connectorProvider, array $authData): void
{ {
// Create a Connector // Create a Connector