Exemplo n.º 1
0
 /**
  * Given an IdentityService instance, create an ObjectStorage instance.
  *
  * This constructs a new ObjectStorage from an authenticated instance
  * of an \OpenStack\Identity\v2\IdentityService object.
  *
  * @param \OpenStack\Identity\v2\IdentityService $identity An identity services object that already
  *                                                         has a valid token and a service catalog.
  * @param string $region The Object Storage region
  * @param \OpenStack\Common\Transport\ClientInterface $client The HTTP client
  *
  * @return \OpenStack\ObjectStore\v1\ObjectStorage A new ObjectStorage instance.
  */
 public static function newFromIdentity($identity, $region, \OpenStack\Common\Transport\ClientInterface $client = null)
 {
     $cat = $identity->serviceCatalog();
     $tok = $identity->token();
     return self::newFromServiceCatalog($cat, $tok, $region, $client);
 }
 /**
  * @group tenant
  */
 public function testTenants()
 {
     $service = new IdentityService(self::conf('openstack.identity.url'), $this->getTransportClient());
     $service2 = new IdentityService(self::conf('openstack.identity.url'), $this->getTransportClient());
     $user = self::conf('openstack.identity.username');
     $pass = self::conf('openstack.identity.password');
     $tenantId = self::conf('openstack.identity.tenantId');
     $service->authenticateAsUser($user, $pass, $tenantId);
     $tenants = $service2->tenants($service->token());
     $this->assertGreaterThan(0, count($tenants));
     $this->assertNotEmpty($tenants[0]['name']);
     $this->assertNotEmpty($tenants[0]['id']);
     $tenants = $service->tenants();
     $this->assertGreaterThan(0, count($tenants));
     $this->assertNotEmpty($tenants[0]['name']);
     $this->assertNotEmpty($tenants[0]['id']);
 }