mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
test: add gandi provider test
This commit is contained in:
@@ -32,7 +32,7 @@ final class ConnectorControllerTest extends ApiTestCase
|
||||
'waiveRetractationPeriod' => true,
|
||||
'acceptConditions' => true,
|
||||
'ownerLegalAge' => true,
|
||||
'token' => '',
|
||||
'token' => 'test',
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
@@ -69,4 +69,23 @@ final class ConnectorControllerTest extends ApiTestCase
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(400);
|
||||
}
|
||||
|
||||
public function testCreateConnectorValidAuthData(): void
|
||||
{
|
||||
$gandiToken = static::getContainer()->getParameter('gandi_pat_token');
|
||||
if (!$gandiToken) {
|
||||
$this->markTestSkipped('Missing Gandi PAT token');
|
||||
}
|
||||
$client = ConnectorControllerTest::createClientWithCredentials(ConnectorControllerTest::getToken(UserFactory::createOne()));
|
||||
$client->request('POST', '/api/connectors', ['json' => [
|
||||
'authData' => [
|
||||
'waiveRetractationPeriod' => true,
|
||||
'acceptConditions' => true,
|
||||
'ownerLegalAge' => true,
|
||||
'token' => $gandiToken,
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
}
|
||||
}
|
||||
|
||||
55
tests/Service/Provider/GandiProviderTest.php
Normal file
55
tests/Service/Provider/GandiProviderTest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Service\Provider;
|
||||
|
||||
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
||||
use App\Factory\UserFactory;
|
||||
use App\Message\OrderDomain;
|
||||
use App\MessageHandler\OrderDomainHandler;
|
||||
use App\Repository\DomainRepository;
|
||||
use App\Tests\Controller\ConnectorControllerTest;
|
||||
use App\Tests\Service\RDAPServiceTest;
|
||||
use App\Tests\State\WatchListUpdateProcessorTest;
|
||||
use PHPUnit\Framework\Attributes\DependsExternal;
|
||||
|
||||
class GandiProviderTest extends ApiTestCase
|
||||
{
|
||||
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
||||
public function testOrderDomain()
|
||||
{
|
||||
$gandiToken = static::getContainer()->getParameter('gandi_pat_token');
|
||||
if (!$gandiToken) {
|
||||
$this->markTestSkipped('Missing Gandi PAT token');
|
||||
}
|
||||
|
||||
// Create a GANDI Connector
|
||||
$client = ConnectorControllerTest::createClientWithCredentials(ConnectorControllerTest::getToken(UserFactory::createOne()));
|
||||
$response = $client->request('POST', '/api/connectors', ['json' => [
|
||||
'authData' => [
|
||||
'waiveRetractationPeriod' => true,
|
||||
'acceptConditions' => true,
|
||||
'ownerLegalAge' => true,
|
||||
'token' => $gandiToken,
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
|
||||
// Create a Watchlist with a single domain name
|
||||
WatchListUpdateProcessorTest::createUserAndWatchlist($client, ['/api/domains/example.com'], '/api/connectors/'.$response->toArray()['id']);
|
||||
|
||||
$response = $client->request('GET', '/api/watchlists');
|
||||
$watchlistId = $response->toArray()['hydra:member'][0]['token'];
|
||||
|
||||
// Set the domain as deleted
|
||||
$domain = self::getContainer()->get(DomainRepository::class)->findOneBy(['ldhName' => 'example.com']);
|
||||
$domain->setDeleted(true);
|
||||
|
||||
// Trigger the Order Domain message
|
||||
$orderDomainHandler = self::getContainer()->get(OrderDomainHandler::class);
|
||||
$message = new OrderDomain($watchlistId, 'example.com');
|
||||
$orderDomainHandler($message);
|
||||
|
||||
$this->assertResponseStatusCodeSame(200);
|
||||
}
|
||||
}
|
||||
@@ -53,13 +53,15 @@ final class WatchListUpdateProcessorTest extends ApiTestCase
|
||||
$this->assertCount(1, $data['trackedEvents']);
|
||||
}
|
||||
|
||||
public static function createUserAndWatchlist(?Client $client = null, array $domains = ['/api/domains/example.com']): Client
|
||||
public static function createUserAndWatchlist(?Client $client = null, array $domains = ['/api/domains/example.com'], ?string $connectorId = null): Client
|
||||
{
|
||||
$client = $client ?? self::createClientWithCredentials(self::getToken(UserFactory::createOne()));
|
||||
|
||||
$client->request('POST', '/api/watchlists', ['json' => [
|
||||
'domains' => $domains,
|
||||
'name' => 'My Watchlist',
|
||||
'trackedEvents' => ['last changed', 'transfer', 'expiration', 'deletion'],
|
||||
'connector' => $connectorId,
|
||||
]]);
|
||||
|
||||
return $client;
|
||||
|
||||
Reference in New Issue
Block a user