コード例 #1
0
 public function testGetUserInformation()
 {
     $this->markTestSkipped('Test will work from PHPUnit 3.7 onwards. See: https://github.com/sebastianbergmann/phpunit-mock-objects/issues/47.');
     $this->mockBuzz($this->userResponse);
     $userResponse = $this->resourceOwner->getUserInformation('access_token');
     $this->assertEquals('bar', $userResponse->getUsername());
     $this->assertEquals('access_token', $userResponse->getAccessToken());
 }
コード例 #2
0
 public function testGetUserInformationFailure()
 {
     $exception = new RequestException();
     $this->buzzClient->expects($this->once())->method('send')->will($this->throwException($exception));
     try {
         $this->resourceOwner->getUserInformation(array('access_token' => 'token'));
         $this->fail('An exception should have been raised');
     } catch (HttpTransportException $e) {
         $this->assertSame($exception, $e->getPrevious());
     }
 }
コード例 #3
0
 public function testGetUserInformation()
 {
     $this->mockBuzz($this->userResponse, 'application/json; charset=utf-8');
     /**
      * @var $userResponse \HWI\Bundle\OAuthBundle\OAuth\Response\AbstractUserResponse
      */
     $userResponse = $this->resourceOwner->getUserInformation(array('access_token' => 'token'));
     $this->assertEquals('1', $userResponse->getUsername());
     $this->assertEquals('bar', $userResponse->getNickname());
     $this->assertEquals('token', $userResponse->getAccessToken());
     $this->assertNull($userResponse->getRefreshToken());
     $this->assertNull($userResponse->getExpiresIn());
 }
コード例 #4
0
 /**
  * {@inheritDoc}
  */
 public function getUserInformation(array $accessToken, array $extraParameters = array())
 {
     if ($this->options['appsecret_proof']) {
         $extraParameters['appsecret_proof'] = hash_hmac('sha256', $accessToken['access_token'], $this->options['client_secret']);
     }
     return parent::getUserInformation($accessToken, $extraParameters);
 }
コード例 #5
0
 /**
  * Override for Orcid
  *
  * {@inheritDoc}
  */
 public function getUserInformation(array $accessToken, array $extraParameters = array())
 {
     if (!array_key_exists('orcid', $accessToken)) {
         return parent::getUserInformation($accessToken, $extraParameters);
     }
     $orcidService = new OrcidService();
     $bio = $orcidService->getBio($accessToken["orcid"]);
     $response = $this->getUserResponse();
     $response->setResponse($bio);
     $response->setResourceOwner($this);
     $response->setOAuthToken(new OAuthToken($accessToken));
     return $response;
 }
コード例 #6
0
 /**
  * {@inheritDoc}
  */
 public function getUserInformation(array $accessToken, array $extraParameters = array())
 {
     $response = parent::getUserInformation($accessToken, $extraParameters);
     $responseData = $response->getResponse();
     // fetch the email addresses linked to the account
     if (empty($responseData['email'])) {
         $content = $this->httpRequest($this->normalizeUrl($this->options['emails_url']), null, array('Authorization: Bearer ' . $accessToken['access_token']));
         foreach ($this->getResponseContent($content)['values'] as $email) {
             // we only need the primary email address
             if (true === $email['is_primary']) {
                 $responseData['email'] = $email['email'];
             }
         }
         $response->setResponse($responseData);
     }
     return $response;
 }
コード例 #7
0
 /**
  * {@inheritDoc}
  */
 public function getUserInformation(array $accessToken, array $extraParameters = array())
 {
     // SalesForce returns the infos_url in the OAuth Response Token
     $this->options['infos_url'] = $accessToken['id'];
     return parent::getUserInformation($accessToken, $extraParameters);
 }