Changed automatic token generation to throw an exception instead
This commit is contained in:
parent
8ab59cb1c2
commit
22b44e251f
@ -57,8 +57,7 @@ class GuardListener
|
|||||||
$token = $this->tokenStorage->getToken();
|
$token = $this->tokenStorage->getToken();
|
||||||
|
|
||||||
if (null === $token) {
|
if (null === $token) {
|
||||||
$token = new AnonymousToken('secret', 'anon', array());
|
throw new \Exception("No token is set");
|
||||||
$this->tokenStorage->setToken($token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->roleHierarchy) {
|
if (null !== $this->roleHierarchy) {
|
||||||
|
@ -74,13 +74,9 @@ class GuardListenerTest extends TestCase
|
|||||||
$event = $this->createEvent();
|
$event = $this->createEvent();
|
||||||
$this->tokenStorage = null;
|
$this->tokenStorage = null;
|
||||||
|
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
|
|
||||||
$this->listener->onTransition($event, 'event_name_a');
|
$this->listener->onTransition($event, 'event_name_a');
|
||||||
|
|
||||||
$this->assertFalse($event->isBlocked());
|
|
||||||
|
|
||||||
$this->listener->onTransition($event, 'event_name_b');
|
|
||||||
|
|
||||||
$this->assertTrue($event->isBlocked());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createEvent()
|
private function createEvent()
|
||||||
|
Reference in New Issue
Block a user