mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
test: update test suite
This commit is contained in:
@@ -7,18 +7,15 @@ use App\Entity\Connector;
|
||||
use App\Factory\UserFactory;
|
||||
use App\Tests\AuthenticatedUserTrait;
|
||||
use Zenstruck\Foundry\Test\Factories;
|
||||
use Zenstruck\Foundry\Test\ResetDatabase;
|
||||
|
||||
final class ConnectorControllerTest extends ApiTestCase
|
||||
{
|
||||
use ResetDatabase;
|
||||
use Factories;
|
||||
use AuthenticatedUserTrait;
|
||||
|
||||
public function testGetConnectorCollection(): void
|
||||
{
|
||||
$testUser = UserFactory::createOne();
|
||||
$client = ConnectorControllerTest::createClientWithCredentials(ConnectorControllerTest::getToken($testUser));
|
||||
$client = ConnectorControllerTest::createClientWithCredentials(ConnectorControllerTest::getToken(UserFactory::createOne()));
|
||||
|
||||
$response = $client->request('GET', '/api/connectors');
|
||||
|
||||
@@ -26,4 +23,50 @@ final class ConnectorControllerTest extends ApiTestCase
|
||||
$this->assertMatchesResourceCollectionJsonSchema(Connector::class);
|
||||
$this->assertCount(0, $response->toArray()['hydra:member']);
|
||||
}
|
||||
|
||||
public function testCreateConnectorInvalidAuthData(): void
|
||||
{
|
||||
$client = ConnectorControllerTest::createClientWithCredentials(ConnectorControllerTest::getToken(UserFactory::createOne()));
|
||||
$client->request('POST', '/api/connectors', ['json' => [
|
||||
'authData' => [
|
||||
'waiveRetractationPeriod' => true,
|
||||
'acceptConditions' => true,
|
||||
'ownerLegalAge' => true,
|
||||
'token' => '',
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(400);
|
||||
}
|
||||
|
||||
public function testCreateConnectorInvalidConsent(): void
|
||||
{
|
||||
$client = ConnectorControllerTest::createClientWithCredentials(ConnectorControllerTest::getToken(UserFactory::createOne()));
|
||||
$client->request('POST', '/api/connectors', ['json' => [
|
||||
'authData' => [
|
||||
'waiveRetractationPeriod' => true,
|
||||
'acceptConditions' => true,
|
||||
'ownerLegalAge' => false,
|
||||
'token' => '',
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(451);
|
||||
}
|
||||
|
||||
public function testCreateConnectorInvalidAuthDataAdditionalKey(): void
|
||||
{
|
||||
$client = ConnectorControllerTest::createClientWithCredentials(ConnectorControllerTest::getToken(UserFactory::createOne()));
|
||||
$client->request('POST', '/api/connectors', ['json' => [
|
||||
'authData' => [
|
||||
'waiveRetractationPeriod' => true,
|
||||
'acceptConditions' => true,
|
||||
'ownerLegalAge' => true,
|
||||
'token' => '',
|
||||
'unknownKey' => 'hello',
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(400);
|
||||
}
|
||||
}
|
||||
|
||||
24
tests/Controller/HomeControllerTest.php
Normal file
24
tests/Controller/HomeControllerTest.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class HomeControllerTest extends WebTestCase
|
||||
{
|
||||
public function testIndex(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/');
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public function testConnectSsoReturnNotFound(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/login/oauth');
|
||||
|
||||
$this->assertResponseStatusCodeSame(404);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user