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 $consumerKey
  * @return \CultuurNet\SymfonySecurityOAuth\Model\ConsumerInterface
  */
 public function getConsumerByKey($consumerKey)
 {
     $consumer = new Consumer();
     $consumer->setConsumerKey('dpf43f3p2l4k3l03');
     $consumer->setConsumerSecret('kd94hf93k423kf44');
     $consumer->setName('testConsumer');
     return $consumer;
 }
 /**
  * @param $consumerKey
  * @return \CultuurNet\SymfonySecurityOAuth\Model\Consumer
  */
 public function getConsumerByKey($consumerKey)
 {
     $uitid_consumer = $this->fetcher->getConsumer($consumerKey);
     $this->consumer = new Consumer();
     $this->consumer->setConsumerKey($uitid_consumer->getKey());
     $this->consumer->setConsumerSecret($uitid_consumer->getSecret());
     $this->consumer->setName($uitid_consumer->getName());
     return $this->consumer;
 }
 public function testGetAccessTokenByToken()
 {
     $accessConsumer = $this->consumerProvider->getConsumerByKey('test');
     $consumerReference = new Consumer();
     $consumerReference->setConsumerKey('testConsumerKey');
     $consumerReference->setConsumerSecret('testConsumerSecret');
     $consumerReference->setName('consumerName');
     $this->assertEquals($consumerReference, $accessConsumer);
 }
 /**
  * @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;
 }
 /**
  * @test
  */
 public function it_only_keeps_the_last_ten_timestamps_per_consumer()
 {
     $key = "timestamps/key:{$this->consumer->getConsumerKey()}";
     $this->nonceProvider->registerNonceAndTimestamp('wNcUhAXuMe', 500, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('dTAmpjPUbk', 600, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('blnDetYfmx', 700, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('SiakXrdbZv', 800, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('cduemCfTOQ', 900, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('MMoVLLMHOn', 1000, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('BGRvLDLmdz', 1100, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('jRQiFtutXj', 1200, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('RwwgRAOYlG', 1300, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('WTjPgqtpFM', 1400, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('EhnRTUPMaZ', 1500, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('RZiDsxDded', 1600, $this->consumer);
     $this->nonceProvider->registerNonceAndTimestamp('FiWVeIpbBm', 1700, $this->consumer);
     $count = count($this->client->zrange($key, 0, -1));
     $this->assertEquals(1, $count);
 }
 public function testApproveSignatureWithFaultyReference()
 {
     $consumer = new Consumer();
     $consumer->setConsumerSecret('kd94hf93k423kf44');
     $token = new Token();
     $token->setSecret('pfkkdhi9sl3r4s00');
     $this->oauthServerService->addSignatureService($this->signatureService);
     $this->requestParameters['oauth_signature'] = 'testSignature';
     $signatureIsApproved = $this->oauthServerService->approveSignature($consumer, $this->requestParameters, $this->requestMethod, $this->requestUrl, $token);
     $this->assertFalse($signatureIsApproved, 'Signature has not been approved');
 }