mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Ensured API keys cannot be generated with domain-only roles linked to default domain
This commit is contained in:
@@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\CLI\ApiKey\RoleResolver;
|
||||
use Shlinkio\Shlink\CLI\Exception\InvalidRoleConfigException;
|
||||
use Shlinkio\Shlink\Core\Domain\DomainServiceInterface;
|
||||
use Shlinkio\Shlink\Core\Entity\Domain;
|
||||
use Shlinkio\Shlink\Rest\ApiKey\Model\RoleDefinition;
|
||||
@@ -23,7 +24,7 @@ class RoleResolverTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->domainService = $this->prophesize(DomainServiceInterface::class);
|
||||
$this->resolver = new RoleResolver($this->domainService->reveal());
|
||||
$this->resolver = new RoleResolver($this->domainService->reveal(), 'default.com');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,4 +95,16 @@ class RoleResolverTest extends TestCase
|
||||
1,
|
||||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function exceptionIsThrownWhenTryingToAddDomainOnlyLinkedToDefaultDomain(): void
|
||||
{
|
||||
$input = $this->prophesize(InputInterface::class);
|
||||
$input->getOption(RoleResolver::DOMAIN_ONLY_PARAM)->willReturn('default.com');
|
||||
$input->getOption(RoleResolver::AUTHOR_ONLY_PARAM)->willReturn(null);
|
||||
|
||||
$this->expectException(InvalidRoleConfigException::class);
|
||||
|
||||
$this->resolver->determineRoles($input->reveal());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user