mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 17:55:42 +00:00
test: update test suite
This commit is contained in:
parent
6154759507
commit
39262814ce
@ -6,7 +6,7 @@ use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
|||||||
use ApiPlatform\Symfony\Bundle\Test\Client;
|
use ApiPlatform\Symfony\Bundle\Test\Client;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
|
||||||
abstract class AbstractTest extends ApiTestCase
|
class AbstractTest extends ApiTestCase
|
||||||
{
|
{
|
||||||
private ?string $token = null;
|
private ?string $token = null;
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Tests\Service;
|
namespace App\Tests\Service;
|
||||||
|
|
||||||
use App\Entity\RdapServer;
|
use App\Entity\RdapServer;
|
||||||
|
use App\Entity\Tld;
|
||||||
use App\Exception\DomainNotFoundException;
|
use App\Exception\DomainNotFoundException;
|
||||||
use App\Exception\TldNotSupportedException;
|
use App\Exception\TldNotSupportedException;
|
||||||
use App\Exception\UnknownRdapServerException;
|
use App\Exception\UnknownRdapServerException;
|
||||||
@ -34,24 +35,24 @@ class RDAPServiceTest extends KernelTestCase
|
|||||||
$updateRdapServersHandler = self::$container->get(UpdateRdapServersHandler::class);
|
$updateRdapServersHandler = self::$container->get(UpdateRdapServersHandler::class);
|
||||||
$message = new UpdateRdapServers();
|
$message = new UpdateRdapServers();
|
||||||
$updateRdapServersHandler($message);
|
$updateRdapServersHandler($message);
|
||||||
self::$entityManager->flush();
|
|
||||||
|
|
||||||
$rdapServerRepository = self::$entityManager->getRepository(RdapServer::class);
|
$rdapServerRepository = self::$entityManager->getRepository(RdapServer::class);
|
||||||
$this->assertNotEmpty($rdapServerRepository->findAll());
|
$this->assertNotEmpty($rdapServerRepository->findAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Depends('testUpdateRdapServers')]
|
#[Depends('testUpdateRdapServers')]
|
||||||
public function testRegisterDomain(): void
|
public function testRegisterDomainByTld(): void
|
||||||
{
|
{
|
||||||
$rdapServerRepository = self::$entityManager->getRepository(RdapServer::class);
|
self::$RDAPService->registerDomains(['arpa']);
|
||||||
|
|
||||||
$testedTldList = ['com', 'net', 'org', 'fr', 'de', 'ch', 'ca', 'leclerc', 'uz'];
|
$rdapServerRepository = static::$entityManager->getRepository(RdapServer::class);
|
||||||
|
$rdapServerList = $rdapServerRepository->findBy(['tld' => array_map(
|
||||||
|
fn (string $tld) => static::$entityManager->getReference(Tld::class, $tld),
|
||||||
|
['com', 'net', 'fr', 'de', 'ch', 'ca', 'uz', 'google', 'ovh']
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
/** @var RdapServer $rdapServer */
|
foreach ($rdapServerList as $rdapServer) {
|
||||||
foreach ($rdapServerRepository->findAll() as $rdapServer) {
|
|
||||||
if (!in_array($rdapServer->getTld()->getTld(), $testedTldList)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
self::$RDAPService->registerDomain('nic.'.$rdapServer->getTld()->getTld());
|
self::$RDAPService->registerDomain('nic.'.$rdapServer->getTld()->getTld());
|
||||||
} catch (DomainNotFoundException|ClientException|TransportException) {
|
} catch (DomainNotFoundException|ClientException|TransportException) {
|
||||||
@ -73,4 +74,11 @@ class RDAPServiceTest extends KernelTestCase
|
|||||||
$this->expectException(TldNotSupportedException::class);
|
$this->expectException(TldNotSupportedException::class);
|
||||||
self::$RDAPService->registerDomain('nic.noexist');
|
self::$RDAPService->registerDomain('nic.noexist');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Depends('testUpdateRdapServers')]
|
||||||
|
public function testDomainNotFound()
|
||||||
|
{
|
||||||
|
$this->expectException(DomainNotFoundException::class);
|
||||||
|
self::$RDAPService->registerDomain('dd5c3e77-c824-4792-95fc-ddde03a08881.com');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user