public function testAuthenticate()
 {
     $requestParameters = array('oauth_consumer_key' => 'dpf43f3p2l4k3l03', 'oauth_token' => 'nnch734d00sl2jdk', 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_timestamp' => 1433160000, 'oauth_nonce' => 'kllo9940pd9333jh', 'oauth_version' => '1.0', 'file' => 'vacation.jpg', 'size' => 'original');
     $consumerSecret = 'kd94hf93k423kf44';
     $tokenSecret = 'pfkkdhi9sl3r4s00';
     $signature = 'dwEfwtMrnGvGbxqXtv0q4BRRmLg=';
     $requestParameters['oauth_signature'] = $signature;
     $token = $this->token;
     $token->setRequestParameters($requestParameters);
     $returnedToken = $this->oauthAuthenticationProvider->authenticate($token);
     $expectedToken = new OAuthToken();
     $expectedToken->setRequestMethod($this->requestMethod);
     $expectedToken->setRequestUrl($this->requestUrl);
     $expectedToken->setRequestParameters($requestParameters);
     $user = new UserMock('123456789', 'testUser', '*****@*****.**');
     $token = new Token();
     $token->setToken($requestParameters['oauth_token']);
     $token->setSecret('pfkkdhi9sl3r4s00');
     $consumer = new Consumer();
     $consumer->setConsumerKey($requestParameters['oauth_consumer_key']);
     $consumer->setConsumerSecret('kd94hf93k423kf44');
     $consumer->setName('testConsumer');
     $token->setConsumer($consumer);
     $token->setUser($user);
     $expectedToken = $expectedToken->authenticated($token);
     $this->assertEquals($expectedToken, $returnedToken);
 }
 /**
  * @param string $oauth_token
  * @return \CultuurNet\SymfonySecurityOAuth\Model\TokenInterface
  */
 public function getAccessTokenByToken($oauth_token)
 {
     $token = new Token();
     $token->setToken('nnch734d00sl2jdk');
     $token->setSecret('pfkkdhi9sl3r4s00');
     $consumer = new Consumer();
     $consumer->setConsumerKey('dpf43f3p2l4k3l03');
     $consumer->setConsumerSecret('kd94hf93k423kf44');
     $consumer->setName('testConsumer');
     $token->setConsumer($consumer);
     $user = new UserMock('123456789', 'testUser', '*****@*****.**');
     $token->setUser($user);
     return $token;
 }
 public function testGetAccessTokenByToken()
 {
     $accessToken = $this->tokenProvider->getAccessTokenByToken('test');
     $consumerReference = new Consumer();
     $consumerReference->setConsumerKey('testConsumerKey');
     $consumerReference->setConsumerSecret('testConsumerSecret');
     $consumerReference->setName('consumerName');
     $userReference = new User('uid', 'nick', '*****@*****.**');
     $accessTokenReference = new Token();
     $accessTokenReference->setToken('testToken');
     $accessTokenReference->setSecret('testTokenSecret');
     $accessTokenReference->setConsumer($consumerReference);
     $accessTokenReference->setUser($userReference);
     $this->assertEquals($accessTokenReference, $accessToken);
 }
 public function testTokenProperties()
 {
     $token = new Token();
     $token->setToken('nnch734d00sl2jdk');
     $token->setSecret('pfkkdhi9sl3r4s00');
     $consumer = new Consumer();
     $consumer->setConsumerKey('dpf43f3p2l4k3l03');
     $consumer->setConsumerSecret('kd94hf93k423kf44');
     $consumer->setName('testConsumer');
     $token->setConsumer($consumer);
     $user = new UserMock('123456789', 'testUser', '*****@*****.**');
     $token->setUser($user);
     $expiresAt = time();
     $token->setExpiresAt($expiresAt);
     $this->assertEquals('nnch734d00sl2jdk', $token->getToken(), 'The Token property is properly set');
     $this->assertEquals('pfkkdhi9sl3r4s00', $token->getSecret(), 'The Token Secret property is properly set');
     $this->assertEquals($consumer, $token->getConsumer(), 'The consumer property is properly set');
     $this->assertEquals($user, $token->getUser(), 'The user property is properly set');
     $this->assertEquals($expiresAt, $token->getExpiresAt(), 'The user property is properly set');
 }
 /**
  * @param $oauth_token
  * @return mixed
  */
 public function getAccessTokenByToken($oauth_token)
 {
     /** @var \CultuurNet\UitidCredentials\Entities\Token $uitid_token */
     $uitid_token = $this->fetcher->getAccessToken($oauth_token);
     /** @var \CultuurNet\UitidCredentials\Entities\Consumer $uitid_consumer */
     $uitid_consumer = $uitid_token->getConsumer();
     /** @var \CultuurNet\UitidCredentials\Entities\User $uitid_user */
     $uitid_user = $uitid_token->getUser();
     /** @var string $uitid_token_secret */
     $uitid_token_secret = $uitid_token->getTokenSecret();
     $consumer = new Consumer();
     $consumer->setName($uitid_consumer->getName());
     $consumer->setConsumerKey($uitid_consumer->getKey());
     $consumer->setConsumerSecret($uitid_consumer->getSecret());
     $user = new User($uitid_user->getUid(), $uitid_user->getNick(), $uitid_user->getEmail());
     $accessToken = new Token();
     $accessToken->setConsumer($consumer);
     $accessToken->setToken($uitid_token->getToken());
     $accessToken->setUser($user);
     $accessToken->setSecret($uitid_token_secret);
     return $accessToken;
 }