예제 #1
0
 public function tearDown()
 {
     // restore commandline key
     AppKey::current()->type = AppKey::TYPE_CLI;
     Context::setTrusted(false);
     // reset active auth token
     AuthToken::setCurrent(null);
 }
예제 #2
0
파일: RoleTest.php 프로젝트: CFLOVEYR/hook
 public function testOwnerReadSuccess()
 {
     $this->setConfig(App::collection('restricted_content')->getTable(), 'read', 'owner');
     $auth_id = 1;
     App::collection('restricted_content')->create(array('name' => "Read success", 'auth_id' => $auth_id));
     App::collection('restricted_content')->create(array('name' => "Read fail", 'auth_id' => 2));
     // mock authorized user
     $auth_token = new AuthToken(array('auth_id' => $auth_id));
     AuthToken::setCurrent($auth_token);
     $this->assertTrue(is_array(App::collection('restricted_content')->where('auth_id', 1)->first()->toArray()));
     // wrong auth_id, throw exception
     $this->setExpectedException('Hook\\Exceptions\\NotAllowedException');
     App::collection('restricted_content')->where('auth_id', 2)->first()->toArray();
 }
예제 #3
0
파일: Auth.php 프로젝트: CFLOVEYR/hook
 /**
  * dataWithToken
  * @return array
  */
 public function dataWithToken()
 {
     $auth_token = $this->generateToken();
     AuthToken::setCurrent($auth_token);
     $current_auth_token = AuthToken::current();
     $data = $this->toArray();
     $data['token'] = $auth_token->toArray();
     return $data;
 }