Changed automatic token generation to throw an exception instead

This commit is contained in:
GDIBass 2017-08-17 23:37:10 -07:00
parent 8ab59cb1c2
commit 22b44e251f
2 changed files with 3 additions and 8 deletions

View File

@ -57,8 +57,7 @@ class GuardListener
$token = $this->tokenStorage->getToken();
if (null === $token) {
$token = new AnonymousToken('secret', 'anon', array());
$this->tokenStorage->setToken($token);
throw new \Exception("No token is set");
}
if (null !== $this->roleHierarchy) {

View File

@ -74,13 +74,9 @@ class GuardListenerTest extends TestCase
$event = $this->createEvent();
$this->tokenStorage = null;
$this->expectException(\Exception::class);
$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()