/** * Test Auth Identity clear * * @covers \Bluz\Auth\Auth::clearIdentity */ public function testAuthClearIdentity() { $adminIdentity = new UserAdmin(); Auth::setIdentity($adminIdentity); Auth::clearIdentity(); $this->assertNull(Auth::getIdentity()); }
protected function setUp() { parent::setUp(); Db::insert('users')->setArray(['id' => 1, 'login' => 'Donatello', 'email' => '*****@*****.**', 'status' => 'pending'])->execute(); Db::insert('users')->setArray(['id' => 2, 'login' => 'Bill', 'email' => '*****@*****.**', 'status' => 'active'])->execute(); Auth::setIdentity(new \Application\Users\Row()); }
/** * {@inheritdoc} * * @param string $module * @param string $controller * @param array $params * @return void */ protected function preDispatch($module, $controller, $params = array()) { // auth as CLI user $cliUser = Table::findRowWhere(['login' => 'system']); Auth::setIdentity($cliUser); parent::preDispatch($module, $controller, $params); }
protected function setUp() { parent::setUp(); $this->hybridAuthMock = $this->getMockBuilder('\\Hybrid_Auth')->setMethods(['authenticate'])->disableOriginalConstructor()->getMock(); $this->authAdapterMock = $this->getMockBuilder('\\Hybrid_Provider_Adapter')->setMethods(['getUserProfile'])->disableOriginalConstructor()->getMock(); Db::insert('users')->setArray(['id' => 2, 'login' => 'Bill', 'email' => '*****@*****.**', 'status' => 'active'])->execute(); Db::insert('auth')->setArray(['provider' => 'facebook', 'userId' => 2, 'foreignKey' => 112233])->execute(); Auth::setIdentity(new \Application\Users\Row()); }
/** * setUp * * @return void */ public function setUp() { parent::setUp(); $this->getApp()->useLayout(false); Auth::setIdentity(new UserHasPermission(UserFixtureContainer::$fixture)); }
/** * Setup user with all privileges * * @return void */ protected function setupSuperUserIdentity() { Auth::setIdentity(new UserHasPermission()); }
/** * Can entity login * * @return void */ public function login() { Auth::setIdentity($this); }
/** * setUp * * @return void */ protected function setUp() { parent::setUp(); Auth::setIdentity(new Row()); }
/** * Can entity login * * @throws Exception * @throws AuthException * @return void */ public function tryLogin() { switch ($this->status) { case Table::STATUS_PENDING: throw new AuthException("Your account is pending activation", 403); case Table::STATUS_DISABLED: throw new AuthException("Your account is disabled by administrator", 403); case Table::STATUS_ACTIVE: // all ok // regenerate session if (PHP_SAPI !== 'cli') { Session::regenerateId(); } // save user to new session Auth::setIdentity($this); break; default: throw new Exception("User status is undefined in system"); } }
/** * Try with permissions */ public function testAllow() { Auth::setIdentity(new UserHasPermission()); $this->getApp()->widget('test', 'acl-denied'); }
/** * Test deny access */ public function testDeny() { Proxy\Auth::setIdentity(new UserGuest()); $this->assertFalse(Proxy\Acl::isAllowed('any', 'any')); }