Handled IDN domains also on internal redirections when validating a URL

This commit is contained in:
Alejandro Celaya
2019-11-16 12:38:45 +01:00
parent 8cf1a95df5
commit 6b8fc3228e
4 changed files with 78 additions and 15 deletions

View File

@@ -182,16 +182,24 @@ class CreateShortUrlActionTest extends ApiTestCase
$this->assertNotEquals($firstShortCode, $secondShortCode);
}
/** @test */
public function createsNewShortUrlWithInternationalizedDomainName(): void
/**
* @test
* @dataProvider provideIdn
*/
public function createsNewShortUrlWithInternationalizedDomainName(string $longUrl): void
{
$longUrl = 'https://cédric.laubacher.io/';
[$statusCode, ['longUrl' => $expectedLongUrl]] = $this->createShortUrl(['longUrl' => $longUrl]);
$this->assertEquals(self::STATUS_OK, $statusCode);
$this->assertEquals($expectedLongUrl, $longUrl);
}
public function provideIdn(): iterable
{
// TODO Create some shlink IDN domains to test this instead of using public ones
return [['https://cédric.laubacher.io/'], ['https://laubacher.io/']]; // Second one redirects to first
}
/**
* @return array {
* @var int $statusCode