/**
  * @group tenant
  */
 public function testTenants()
 {
     $service = new IdentityServices(self::conf('hpcloud.identity.url'));
     $service2 = new IdentityServices(self::conf('hpcloud.identity.url'));
     $user = self::conf('hpcloud.identity.username');
     $pass = self::conf('hpcloud.identity.password');
     $tenantId = self::conf('hpcloud.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']);
 }
Beispiel #2
0
$key = $argv[2 + $offset];
$uri = $argv[3 + $offset];
$tenantId = NULL;
if (!empty($argv[4 + $offset])) {
    $tenantId = $argv[4 + $offset];
}
/*
$store = ObjectStorage::newFromSwiftAuth($user, $key, $uri);

$token = $store->token();
*/
$cs = new IdentityServices($uri);
if ($asUser) {
    $token = $cs->authenticateAsUser($user, $key, $tenantId);
} else {
    $token = $cs->authenticateAsAccount($user, $key, $tenantId);
}
if (empty($token)) {
    print "Authentication seemed to succeed, but no token was returned." . PHP_EOL;
    exit(1);
}
$t = "You are logged in as %s with token %s (good until %s)." . PHP_EOL;
$tokenDetails = $cs->tokenDetails();
$user = $cs->user();
printf($t, $user['name'], $cs->token(), $tokenDetails['expires']);
print "The following services are available on this account:" . PHP_EOL;
$services = $cs->serviceCatalog();
foreach ($services as $service) {
    print "\t" . $service['name'] . PHP_EOL;
}
//print_r($services);