Ensured default domain redirects cannot be edited through regular approach

This commit is contained in:
Alejandro Celaya
2021-08-03 18:28:04 +02:00
parent 9abf611d63
commit 7c06633a67
6 changed files with 77 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ use Shlinkio\Shlink\Core\Domain\Model\DomainItem;
use Shlinkio\Shlink\Core\Domain\Repository\DomainRepositoryInterface;
use Shlinkio\Shlink\Core\Entity\Domain;
use Shlinkio\Shlink\Core\Exception\DomainNotFoundException;
use Shlinkio\Shlink\Core\Exception\InvalidDomainException;
use Shlinkio\Shlink\Core\Options\NotFoundRedirectOptions;
use Shlinkio\Shlink\Rest\ApiKey\Model\ApiKeyMeta;
use Shlinkio\Shlink\Rest\ApiKey\Model\RoleDefinition;
@@ -213,4 +214,15 @@ class DomainServiceTest extends TestCase
yield 'domain not found and author API key' => [null, $authorApiKey];
yield 'domain found and author API key' => [$domain, $authorApiKey];
}
/** @test */
public function anExceptionIsThrowsWhenTryingToEditRedirectsForDefaultDomain(): void
{
$this->expectException(InvalidDomainException::class);
$this->expectExceptionMessage(
'You cannot configure default domain\'s redirects this way. Use the configuration or env vars.',
);
$this->domainService->configureNotFoundRedirects('default.com', NotFoundRedirects::withoutRedirects());
}
}