mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-21 19:55:35 +00:00
test: exclude provider test if there is a server exception
This commit is contained in:
parent
1ed2275ac1
commit
6d6119a490
@ -15,6 +15,7 @@ use App\Tests\Service\RDAPServiceTest;
|
|||||||
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;
|
||||||
|
use Symfony\Component\HttpClient\Exception\ServerException;
|
||||||
use Symfony\Component\Uid\UuidV4;
|
use Symfony\Component\Uid\UuidV4;
|
||||||
|
|
||||||
class AbstractProviderTest extends ApiTestCase
|
class AbstractProviderTest extends ApiTestCase
|
||||||
@ -75,41 +76,45 @@ class AbstractProviderTest extends ApiTestCase
|
|||||||
|
|
||||||
private function testGenericProvider(ConnectorProvider $connectorProvider, array $authData): void
|
private function testGenericProvider(ConnectorProvider $connectorProvider, array $authData): void
|
||||||
{
|
{
|
||||||
// Create a Connector
|
try {
|
||||||
$client = ConnectorControllerTest::createClientWithCredentials(ConnectorControllerTest::getToken(UserFactory::createOne()));
|
// Create a Connector
|
||||||
$response = $client->request('POST', '/api/connectors', ['json' => [
|
$client = ConnectorControllerTest::createClientWithCredentials(ConnectorControllerTest::getToken(UserFactory::createOne()));
|
||||||
'authData' => $authData,
|
$response = $client->request('POST', '/api/connectors', ['json' => [
|
||||||
'provider' => $connectorProvider->value,
|
'authData' => $authData,
|
||||||
]]);
|
'provider' => $connectorProvider->value,
|
||||||
$this->assertResponseStatusCodeSame(201);
|
]]);
|
||||||
|
$this->assertResponseStatusCodeSame(201);
|
||||||
|
|
||||||
/** @var EntityManagerInterface $entityManager */
|
/** @var EntityManagerInterface $entityManager */
|
||||||
$entityManager = self::getContainer()->get(EntityManagerInterface::class);
|
$entityManager = self::getContainer()->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
// Create a Watchlist with the domain name
|
// Create a Watchlist with the domain name
|
||||||
WatchListUpdateProcessorTest::createUserAndWatchlist($client,
|
WatchListUpdateProcessorTest::createUserAndWatchlist($client,
|
||||||
['/api/domains/example.com'],
|
['/api/domains/example.com'],
|
||||||
'/api/connectors/'.$response->toArray()['id']);
|
'/api/connectors/'.$response->toArray()['id']);
|
||||||
|
|
||||||
$response = $client->request('GET', '/api/watchlists');
|
$response = $client->request('GET', '/api/watchlists');
|
||||||
$watchlist = $entityManager->getRepository(WatchList::class)->findOneBy(['token' => $response->toArray()['hydra:member'][0]['token']]);
|
$watchlist = $entityManager->getRepository(WatchList::class)->findOneBy(['token' => $response->toArray()['hydra:member'][0]['token']]);
|
||||||
|
|
||||||
$domain = (new Domain())
|
$domain = (new Domain())
|
||||||
->setLdhName((new UuidV4()).'.com')
|
->setLdhName((new UuidV4()).'.com')
|
||||||
->setDeleted(true)
|
->setDeleted(true)
|
||||||
->setTld($entityManager->getReference(Tld::class, 'fr'))
|
->setTld($entityManager->getReference(Tld::class, 'fr'))
|
||||||
->setDelegationSigned(false);
|
->setDelegationSigned(false);
|
||||||
|
|
||||||
$entityManager->persist($domain);
|
$entityManager->persist($domain);
|
||||||
$watchlist->addDomain($domain);
|
$watchlist->addDomain($domain);
|
||||||
|
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
|
|
||||||
// Trigger the Order Domain message
|
// Trigger the Order Domain message
|
||||||
$orderDomainHandler = self::getContainer()->get(OrderDomainHandler::class);
|
$orderDomainHandler = self::getContainer()->get(OrderDomainHandler::class);
|
||||||
$message = new OrderDomain($watchlist->getToken(), $domain->getLdhName());
|
$message = new OrderDomain($watchlist->getToken(), $domain->getLdhName());
|
||||||
$orderDomainHandler($message);
|
$orderDomainHandler($message);
|
||||||
|
|
||||||
$this->assertResponseStatusCodeSame(200);
|
$this->assertResponseStatusCodeSame(200);
|
||||||
|
} catch (ServerException $e) {
|
||||||
|
$this->markTestSkipped('Provider '.$connectorProvider->value.' is not ready. Response HTTP '.$e->getResponse()->getStatusCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user