/** @test */ public function shouldNotGrantToUserWithoutConfiguredRoles() { $guard = new ControllerGuard([['controller' => 'TestController', 'actions' => ['foo', 'bar', 'get', 'update'], 'roles' => ['manager', 'super_duper_user']]]); $identityProvider = new IdentityProvider(); $identityProvider->setIdentityRoles(['lame_o_user']); $guard->setIdentityProvider($identityProvider); $this->assertFalse($guard->isGranted(new RouteMatch(['controller' => 'TestController', 'action' => 'bar'])), 'Should grant for actions'); }
/** @test */ public function shouldRejectRequestsFromUsersWithoutAppropriateRoles_restAction() { $this->identityProvider->setIdentityRoles(['regular_ol_user']); $this->dispatch('/admin/123', 'DELETE'); $this->assertResponseStatusCode(403); }