/**
  * 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');
 }
Beispiel #2
0
 /**
  * Create a new container if it doesn't exists.
  *
  * @return string
  */
 public function getCurrentClientContainer()
 {
     if (empty($this->_clientId)) {
         return false;
     }
     $container = strtolower(APPLICATION_ENV) . '-client-' . $this->_clientId;
     if (!$this->_service->getContainer($container)) {
         $this->_service->createContainer($container);
         $this->_service->enableCdnContainer($container);
         if (!$this->_service->isSuccessful()) {
             throw new Exception($this->_service->getErrorMsg());
         }
     }
     return $container;
 }
Beispiel #3
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 Zend_Cloud_StorageService_Exception('Error on list items: ' . $this->_rackspace->getErrorMsg());
     }
     $resultArray = array();
     if (!empty($files)) {
         foreach ($files as $file) {
             $resultArray[] = $file->getName();
         }
     }
     return $resultArray;
 }