예제 #1
0
 /**
  * Tears down this test case
  *
  * @return void
  */
 public function tearDown()
 {
     if (!$this->_config) {
         return;
     }
     // Delete the container here
     $rackspace = new RackspaceService($this->_config->get(\Zend\Cloud\StorageService\Adapter\Rackspace::USER), $this->_config->get(\Zend\Cloud\StorageService\Adapter\Rackspace::API_KEY));
     $files = $rackspace->getObjects($this->_config->get(\Zend\Cloud\StorageService\Adapter\Rackspace::REMOTE_CONTAINER));
     if ($files == !false) {
         foreach ($files as $file) {
             $rackspace->deleteObject($this->_config->get(\Zend\Cloud\StorageService\Adapter\Rackspace::REMOTE_CONTAINER), $file->getName());
         }
     }
     $rackspace->deleteContainer($this->_config->get(\Zend\Cloud\StorageService\Adapter\Rackspace::REMOTE_CONTAINER));
     parent::tearDown();
 }
예제 #2
0
 /**
  * Test the authentication error (401 Unauthorized - Bad username or password)
  *
  * @return void
  */
 public function testAuthenticateError()
 {
     $this->_files->getHttpClient()->setAdapter($this->_httpClientAdapterTest);
     $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__));
     $this->assertFalse($this->_files->authenticate());
     $this->assertFalse($this->_files->isSuccessful());
     $this->assertEquals($this->_files->getErrorCode(), '401');
     $this->assertEquals($this->_files->getErrorMsg(), 'Bad username or password');
 }
예제 #3
0
 /**
  * Get the CDN SSL URL of the object
  *
  * @return string
  */
 public function getCdnUrlSsl()
 {
     $result = $this->service->getInfoCdnContainer($this->container);
     if ($result !== false) {
         if ($result['cdn_enabled']) {
             return $result['cdn_uri_ssl'] . '/' . $this->name;
         }
     }
     return false;
 }
예제 #4
0
 /**
  * Update the CDN information
  *
  * @return boolean
  */
 public function updateCdnInfo()
 {
     $result = $this->service->getInfoCdnContainer($this->getName());
     if ($result !== false) {
         $this->cdn = strtolower($result['cdn_enabled']) !== 'false';
         $this->ttl = $result['ttl'];
         $this->logRetention = strtolower($result['log_retention']) !== 'false';
         $this->cdnUri = $result['cdn_uri'];
         $this->cdnUriSsl = $result['cdn_uri_ssl'];
         return true;
     }
     return false;
 }
예제 #5
0
 /**
  * Return an array of the items contained in the given path.  The items
  * returned are the files or objects that in the specified path.
  *
  * @param  string $path
  * @param  array  $options
  * @return array
  */
 public function listItems($path, $options = null)
 {
     if (!empty($path)) {
         $options = array('prefix' => $path);
     }
     $files = $this->rackspace->getObjects($this->container, $options);
     if (!$this->rackspace->isSuccessful()) {
         throw new Exception\RuntimeException('Error on list items: ' . $this->rackspace->getErrorMsg());
     }
     $resultArray = array();
     if (!empty($files)) {
         foreach ($files as $file) {
             $resultArray[] = $file->getName();
         }
     }
     return $resultArray;
 }
예제 #6
0
    /**
     * Test the get of a container
     *
     * @return void
     */
    public function testGetContainer()
    {
        $this->_files->getHttpClient()
                    ->setAdapter($this->_httpClientAdapterTest);

        $this->_httpClientAdapterTest->setResponse($this->_loadResponse('../../_files/testAuthenticate'));
        $this->assertTrue($this->_files->authenticate(),'Authentication failed');

        $this->_httpClientAdapterTest->setResponse($this->_loadResponse(__FUNCTION__));

        $container= $this->_files->getContainer('foo');
        $this->assertTrue($this->_files->isSuccessful(),'Get container failed');
        $this->assertEquals($container->getName(),'foo','The name of container is wrong');
        $this->assertEquals($container->getSize(),9756,'The size in bytes is wrong');
        $this->assertEquals($container->getObjectCount(),2,'The objects count is wrong');
        $metadata= array(
            'foo' => 'bar',
            'foo2' => 'bar2'
        );
        $this->assertEquals($container->getMetadata(),$metadata,'The metadata is wrong');
    }
예제 #7
0
 public function testDeleteContainer()
 {
     $this->assertTrue($this->rackspace->deleteContainer(TESTS_ZEND_SERVICE_RACKSPACE_CONTAINER_NAME));
 }