mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 09:45:29 +00:00
test: add test for Namecheap
This commit is contained in:
parent
7d0642eb6a
commit
213617c3c1
@ -15,3 +15,11 @@ GANDI_PAT_TOKEN=
|
||||
|
||||
NAMECOM_USERNAME=
|
||||
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=
|
||||
|
||||
@ -52,3 +52,5 @@ when@test:
|
||||
gandi_pat_token: '%env(string:GANDI_PAT_TOKEN)%'
|
||||
namecom_username: '%env(string:NAMECOM_USERNAME)%'
|
||||
namecom_password: '%env(string:NAMECOM_PASSWORD)%'
|
||||
namecheap_username: '%env(string:NAMECHEAP_USERNAME)%'
|
||||
namecheap_token: '%env(string:NAMECHEAP_TOKEN)%'
|
||||
|
||||
@ -11,6 +11,7 @@ use Psr\Cache\CacheItemInterface;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
@ -37,6 +38,7 @@ class NamecheapProvider extends AbstractProvider
|
||||
private readonly string $outgoingIp,
|
||||
DenormalizerInterface&NormalizerInterface $serializer,
|
||||
ValidatorInterface $validator,
|
||||
private readonly KernelInterface $kernel,
|
||||
) {
|
||||
parent::__construct($cacheItemPool, $serializer, $validator);
|
||||
}
|
||||
@ -99,7 +101,7 @@ class NamecheapProvider extends AbstractProvider
|
||||
'ClientIp' => $this->outgoingIp,
|
||||
], $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,
|
||||
]);
|
||||
|
||||
|
||||
@ -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
|
||||
{
|
||||
// Create a Connector
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user