/**
  * 测试AuthLoggerListener::onTokenPost()
  */
 public function testOnTokenPost()
 {
     $e = new Event();
     $e->setParam('access_token', 'qihu_token');
     $e->setParam('account', "_qihu_m_test_id");
     $e->setParam('ip', '192.168.0.1');
     $e->setParam('nickname', iconv('utf-8', 'gbk', 'test_name'));
     $e->setResult(array('id' => 'test_id', 'name' => 'test_name', 'avator' => 'test_avator', 'nick' => 'test_nick'));
     $e->setZfirm(array('token' => 'zfirm_token'));
     $this->events->trigger(Event::EVENT_TOKEN_POST, $e);
     $this->assertStringMatchesFormat('%s INFO (6): 360, access_token: qihu_token, account: _qihu_m_test_id, ip: 192.168.0.1, token: zfirm_token%w', file_get_contents($this->destfile));
 }
Example #2
0
 /**
  * 执行91无线的数据验证
  * 
  * @param AuthEvent $e
  * @return mixed
  */
 public function onVerify(AuthEvent $e)
 {
     $request = $e->getQuery();
     if (isset($request['uin']) && isset($request['sessionid'])) {
         $user = $this->checkSessionId($request['Uin'], $request['sessionid']);
         if (!isset($userinfo['ErrorCode']) || 1 != intval($user['ErrorCode'])) {
             return new Failure('获取用户信息失败。', $user);
         }
         $e->setResult($user);
     } else {
         return new Failure('Uin参数或sessionId参数不存在。', $request);
     }
     return $e->getResult();
 }
Example #3
0
 /**
  * 执行奇虎(360)数据验证
  * 
  * @param AuthEvent $e
  * @return array|Failure
  */
 public function onVerify(AuthEvent $e)
 {
     $request = $e->getQuery();
     if (isset($request['code']) && !empty($request['code'])) {
         $token = $this->getAccessToken($request['code']);
         if (!isset($token['access_token']) || empty($token['access_token'])) {
             return new Failure('获取access token失败。', $token);
         }
         $e->setParam('access_token', $token['access_token']);
         $user = $this->getUserInfo($token['access_token']);
         if (!isset($user['id']) || empty($user['id'])) {
             return new Failure('获取用户信息失败。', $user);
         }
         $e->setResult($user);
     } else {
         return new Failure('code参数不存在。', $request);
     }
     return $e->getResult();
 }
 /**
  * 测试Zfirm用户平台的数据验证——成功
  */
 public function testOnTokenSuccess()
 {
     $token = rand();
     $this->user->expects($this->once())->method('setToken')->with($this->equalTo('_qihu_m_valid_id'), $this->equalTo((new RemoteAddress())->getIpAddress()), $this->equalTo('valid_name'))->will($this->returnValue(array('token' => $token)));
     $e = new Event();
     $e->setResult(array('id' => 'valid_id', 'name' => 'valid_name'));
     $result = $this->http->onToken($e);
     $this->assertArrayHasKey('token', $result);
     $this->assertEquals($token, $result['token']);
 }