public function setUp()
 {
     Bootstrap::useStreamWrappers();
     $this->url = $this->createNewUrl();
     $this->context = $this->createStreamContext();
     $this->resource = $this->createNewResource($this->url);
 }
 protected static function setConfiguration()
 {
     if (file_exists('tests/settings.ini')) {
         self::$settings = parse_ini_file('tests/settings.ini');
     } else {
         throw new \Exception('Could not access test/settings.ini');
     }
     Bootstrap::setConfiguration(self::$settings);
 }
 public function __construct($details)
 {
     parent::__construct($details);
     $this->file_path = 'swift://' . $details['file_path'];
     if (!self::$init) {
         $config = PerchConfig::get('openstack_object_storage');
         Bootstrap::useStreamWrappers();
         Bootstrap::setConfiguration(['account' => isset($config['account']) ? $config['account'] : null, 'key' => isset($config['key']) ? $config['key'] : null, 'username' => isset($config['username']) ? $config['username'] : null, 'password' => isset($config['password']) ? $config['password'] : null, 'tenantname' => isset($config['tenantname']) ? $config['tenantname'] : null, 'tenantid' => isset($config['tenantid']) ? $config['tenantid'] : null, 'endpoint' => $config['endpoint'], 'openstack.swift.region' => $config['region']]);
         self::$init = true;
     }
 }
 public function initRepository()
 {
     if (is_array($this->pluginConf)) {
         $this->driverConf = $this->pluginConf;
     } else {
         $this->driverConf = array();
     }
     require_once $this->getBaseDir() . "/openstack-sdk-php/vendor/autoload.php";
     Bootstrap::useStreamWrappers();
     Bootstrap::setConfiguration(array('username' => $this->repository->getOption("USERNAME"), 'password' => $this->repository->getOption("PASSWORD"), 'tenantid' => $this->repository->getOption("TENANT_ID"), 'endpoint' => $this->repository->getOption("ENDPOINT"), 'openstack.swift.region' => $this->repository->getOption("REGION"), 'transport.ssl.verify' => false));
     $path = $this->repository->getOption("PATH");
     $recycle = $this->repository->getOption("RECYCLE_BIN");
     ConfService::setConf("PROBE_REAL_SIZE", false);
     $this->detectStreamWrapper(true);
     $this->urlBase = "pydio://" . $this->repository->getId();
     if ($recycle != "") {
         RecycleBinManager::init($this->urlBase, "/" . $recycle);
     }
 }
<?php

require_once $this->getBaseDir() . "/openstack-sdk-php/vendor/autoload.php";
use OpenStack\Bootstrap;
Bootstrap::useStreamWrappers();
Bootstrap::setConfiguration(array('username' => $this->repository->getOption("USERNAME"), 'password' => $this->repository->getOption("PASSWORD"), 'tenantid' => $this->repository->getOption("TENANT_ID"), 'endpoint' => $this->repository->getOption("ENDPOINT"), 'openstack.swift.region' => $this->repository->getOption("REGION"), 'transport.ssl.verify' => false));
 /**
  * Get an item out of the context.
  *
  * @todo Should there be an option to NOT query the Bootstrap::conf()?
  *
  * @param string $name    The name to look up. First look it up in the context,
  *                        then look it up in the Bootstrap config.
  * @param mixed  $default The default value to return if no config param was
  *                        found.
  *
  * @return mixed The discovered result, or $default if specified, or null if
  *               no $default is specified.
  */
 protected function cxt($name, $default = null)
 {
     // Lazilly populate the context array.
     if (is_resource($this->context) && empty($this->contextArray)) {
         $cxt = stream_context_get_options($this->context);
         // If a custom scheme name has been set, use that.
         if (!empty($cxt[$this->schemeName])) {
             $this->contextArray = $cxt[$this->schemeName];
         } elseif (!empty($cxt[self::DEFAULT_SCHEME])) {
             $this->contextArray = $cxt[self::DEFAULT_SCHEME];
         }
     }
     // Should this be array_key_exists()?
     if (isset($this->contextArray[$name])) {
         return $this->contextArray[$name];
     }
     // Check to see if the value can be gotten from
     // \OpenStack\Bootstrap.
     $val = \OpenStack\Bootstrap::config($name, null);
     if (isset($val)) {
         return $val;
     }
     return $default;
 }
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use OpenStack\Bootstrap;
Bootstrap::useStreamWrappers();
$ini = parse_ini_file(getenv('HOME') . '/.OpenStack.ini');
$settings = ['account' => $ini['account'], 'key' => $ini['secret'], 'tenantid' => $ini['tenantId'], 'endpoint' => $ini['url']];
Bootstrap::setConfiguration($settings);
// Create a new file and write it to the object store.
$newfile = fopen('swift://Example/my_file.txt', 'w');
fwrite($newfile, "Good Morning!");
fclose($newfile);
// Check for an object:
if (file_exists('swift://Example/my_file.txt')) {
    print "Found my_file.txt." . PHP_EOL;
}
// Get an entire object at once:
$file = file_get_contents('swift://Example/my_file.txt');
print 'File: ' . $file . PHP_EOL;
$cxt = stream_context_create(['swift' => ['account' => $ini['account'], 'key' => $ini['secret'], 'tenantid' => $ini['tenantId'], 'endpoint' => $ini['url']]]);
print file_get_contents('swift://Example/my_file.txt', FALSE, $cxt);
 /**
  * Test the bootstrap identity factory.
  * @depends testAuthenticateAsUser
  */
 public function testBootstrap()
 {
     // We need to save the config settings and reset the bootstrap to this.
     // It does not remove the old settings. The means the identity fall through
     // for different settings may not happen because of ordering. So, we cache
     // and reset back to the default for each test.
     $reset = Bootstrap::$config;
     // Test authenticating as a user.
     $settings = ['username' => self::conf('openstack.identity.username'), 'password' => self::conf('openstack.identity.password'), 'endpoint' => self::conf('openstack.identity.url'), 'tenantid' => self::conf('openstack.identity.tenantId'), 'transport' => self::conf('transport'), 'transport.debug' => self::conf('transport.debug', false), 'transport.ssl_verify' => self::conf('transport.ssl', true)];
     if (self::conf('transport.timeout')) {
         $setting['transport.timeout'] = self::conf('transport.timeout');
     }
     if (self::conf('transport.proxy')) {
         $setting['transport.proxy'] = self::conf('transport.proxy');
     }
     Bootstrap::setConfiguration($settings);
     $is = Bootstrap::identity(true);
     $this->assertInstanceOf('\\OpenStack\\Identity\\v2\\IdentityService', $is);
     // Test getting a second instance from the cache.
     $is2 = Bootstrap::identity();
     $this->assertEquals($is, $is2);
     // Test that forcing a refresh does so.
     $is2 = Bootstrap::identity(true);
     $this->assertNotEquals($is, $is2);
     Bootstrap::$config = $reset;
     // Test with tenant name
     $settings = ['username' => self::conf('openstack.identity.username'), 'password' => self::conf('openstack.identity.password'), 'endpoint' => self::conf('openstack.identity.url'), 'tenantname' => self::conf('openstack.identity.tenantName'), 'transport' => self::conf('transport'), 'transport.debug' => self::conf('transport.debug', false), 'transport.ssl_verify' => self::conf('transport.ssl', true)];
     if (self::conf('transport.timeout')) {
         $setting['transport.timeout'] = self::conf('transport.timeout');
     }
     if (self::conf('transport.proxy')) {
         $setting['transport.proxy'] = self::conf('transport.proxy');
     }
     Bootstrap::setConfiguration($settings);
     $is = Bootstrap::identity(true);
     $this->assertInstanceOf('\\OpenStack\\Identity\\v2\\IdentityService', $is);
 }