Example #1
0
 /**
  * @dataProvider dataProviderForPrepareErrorResponseTest
  */
 public function testPrepareErrorResponse($exception, $response, $expected)
 {
     /* @var $response \Zend_Controller_Response_Http */
     $errorResponse = $this->_oauthHelper->prepareErrorResponse($exception, $response);
     $this->assertEquals(['oauth_problem' => $expected[0]], $errorResponse);
     $this->assertEquals($expected[1], $response->getHttpResponseCode());
 }
Example #2
0
 /**
  *  Initiate RequestToken request operation
  *
  * @return void
  */
 public function execute()
 {
     try {
         $requestUrl = $this->_helper->getRequestUrl($this->getRequest());
         $request = $this->_helper->prepareRequest($this->getRequest(), $requestUrl);
         // Request request token
         $response = $this->_oauthService->getRequestToken($request, $requestUrl, $this->getRequest()->getMethod());
     } catch (\Exception $exception) {
         $response = $this->_helper->prepareErrorResponse($exception, $this->getResponse());
     }
     $this->getResponse()->setBody(http_build_query($response));
 }
Example #3
0
 /**
  * Initiate AccessToken request operation
  *
  * @return void
  */
 public function execute()
 {
     try {
         $requestUrl = $this->_helper->getRequestUrl($this->getRequest());
         $request = $this->_helper->prepareRequest($this->getRequest(), $requestUrl);
         // Request access token in exchange of a pre-authorized token
         $response = $this->_oauthService->getAccessToken($request, $requestUrl, $this->getRequest()->getMethod());
         //After sending the access token, update the integration status to active;
         $consumer = $this->_intOauthService->loadConsumerByKey($request['oauth_consumer_key']);
         $this->_integrationService->findByConsumerId($consumer->getId())->setStatus(IntegrationModel::STATUS_ACTIVE)->save();
     } catch (\Exception $exception) {
         $response = $this->_helper->prepareErrorResponse($exception, $this->getResponse());
     }
     $this->getResponse()->setBody(http_build_query($response));
 }
 /**
  * @param \Exception $exception
  * @param array $expected
  * @return void
  * @dataProvider dataProviderForPrepareErrorResponseTest
  */
 public function testPrepareErrorResponse($exception, $expected)
 {
     $this->response->expects($this->once())->method('setHttpResponseCode')->with($expected[1]);
     $errorResponse = $this->oauthRequestHelper->prepareErrorResponse($exception, $this->response);
     $this->assertEquals(['oauth_problem' => $expected[0]], $errorResponse);
 }