Example #1
0
 public function setUp()
 {
     $this->entryText = file_get_contents('Zend/GData/App/_files/EntrySample1.xml', true);
     $this->httpEntrySample = file_get_contents('Zend/GData/App/_files/EntrySampleHttp1.txt', true);
     $this->entry = new App\Entry();
     $this->adapter = new \ZendTest\GData\TestAsset\MockHttpClient();
     $this->client = new GData\HttpClient();
     $this->client->setAdapter($this->adapter);
     $this->service = new App($this->client);
 }
Example #2
0
 public function setUp()
 {
     $this->fileName = 'Zend/GData/App/_files/FeedSample1.xml';
     $this->expectedEtagValue = 'W/"CkcHQH8_fCp7ImA9WxRTGEw."';
     $this->expectedMajorProtocolVersion = 1;
     $this->expectedMinorProtocolVersion = 2;
     $this->httpEntrySample = file_get_contents('Zend/GData/_files/AppSample1.txt', true);
     $this->httpEntrySampleWithoutVersion = file_get_contents('Zend/GData/_files/AppSample2.txt', true);
     $this->httpFeedSample = file_get_contents('Zend/GData/_files/AppSample3.txt', true);
     $this->httpFeedSampleWithoutVersion = file_get_contents('Zend/GData/_files/AppSample4.txt', true);
     $this->adapter = new TestAsset\MockHttpClient();
     $this->client = new GData\HttpClient();
     $this->client->setAdapter($this->adapter);
     $this->service = new App($this->client);
 }
Example #3
0
 /**
  * Performs a HTTP request using the specified method.
  *
  * Overrides the definition in the parent (Zend_Gdata_App)
  * and uses the Zend_Gdata_HttpClient functionality
  * to filter the HTTP requests and responses.
  *
  * @param string $method The HTTP method for the request -
  *                       'GET', 'POST', 'PUT', 'DELETE'
  * @param string $url The URL to which this request is being performed,
  *                    or null if found in $data
  * @param array $headers An associative array of HTTP headers
  *                       for this request
  * @param string $body The body of the HTTP request
  * @param string $contentType The value for the content type of the
  *                            request body
  * @param int $remainingRedirects Number of redirects to follow
  *                                if requests results in one
  * @return \Zend\Http\Response The response object
  */
 public function performHttpRequest($method, $url, $headers = array(), $body = null, $contentType = null, $remainingRedirects = null)
 {
     if ($this->_httpClient instanceof HttpClient) {
         $filterResult = $this->_httpClient->filterHttpRequest($method, $url, $headers, $body, $contentType);
         $method = $filterResult['method'];
         $url = $filterResult['url'];
         $body = $filterResult['body'];
         $headers = $filterResult['headers'];
         $contentType = $filterResult['contentType'];
         return $this->_httpClient->filterHttpResponse(parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects));
     } else {
         return parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects);
     }
 }
Example #4
0
 /**
  * Retrieve a HTTP client object with AuthSub credentials attached
  * as the Authorization header
  *
  * @param string $token The token to retrieve information about
  * @param \Zend\GData\HttpClient $client (optional) HTTP client to use to make the request
  */
 public static function getHttpClient($token, $client = null)
 {
     if ($client == null) {
         $client = new HttpClient();
     }
     if (!$client instanceof Client) {
         throw new App\HttpException('Client is not an instance of Zend_Http_Client.');
     }
     $useragent = 'Zend_Framework_Gdata/' . \Zend\Version::VERSION;
     $client->setConfig(array('strictredirects' => true, 'useragent' => $useragent));
     $client->setAuthSubToken($token);
     return $client;
 }
Example #5
0
 /**
  * @expectedException Zend\Gdata\App\HttpException
  */
 public function testGetAuthSubTokenInfoCatchesHttpClientException()
 {
     $adapter = new AdapterTest();
     $adapter->setNextRequestWillFail(true);
     $client = new GData\HttpClient();
     $client->setUri('http://example.com/AuthSub');
     $client->setAdapter($adapter);
     $revoked = GData\AuthSub::getAuthSubTokenInfo($this->token, $client);
 }
Example #6
0
 /**
  * Retrieve a HTTP client object with AuthSub credentials attached
  * as the Authorization header
  *
  * @param string $token The token to retrieve information about
  * @param HttpClient $client (optional) HTTP client to use to make the request
  * @return HttpClient
  */
 public static function getHttpClient($token, HttpClient $client = null)
 {
     if ($client == null) {
         $client = new HttpClient();
     }
     $useragent = 'Zend_Framework_Gdata/' . \Zend\Version::VERSION;
     $client->setOptions(array('strictredirects' => true, 'useragent' => $useragent));
     $client->setAuthSubToken($token);
     return $client;
 }
Example #7
0
    public function testPrivateKeyNotFound()
    {
        $this->setExpectedException('Zend\GData\App\InvalidArgumentException');

        if (!extension_loaded('openssl')) {
            $this->markTestSkipped('The openssl extension is not available');
        } else {
            $c = new GData\HttpClient();
            $c->setAuthSubPrivateKeyFile("zendauthsubfilenotfound",  null, true);
        }
    }