/** * @group tenant * @depends testTenants */ function testRescopeByTenantName() { $service = new IdentityServices(self::conf('hpcloud.identity.url')); $user = self::conf('hpcloud.identity.username'); $pass = self::conf('hpcloud.identity.password'); $tenantName = self::conf('hpcloud.identity.tenantName'); // Authenticate without a tenant ID. $token = $service->authenticateAsUser($user, $pass); $this->assertNotEmpty($token); $details = $service->tokenDetails(); $this->assertFalse(isset($details['tenant'])); $service->rescopeUsingTenantName($tenantName); $details = $service->tokenDetails(); $this->assertEquals($tenantName, $details['tenant']['name']); $catalog = $service->serviceCatalog(); $this->assertGreaterThan(1, count($catalog)); // Test unscoping $service->rescope(''); $details = $service->tokenDetails(); $this->assertFalse(isset($details['tenant'])); $catalog = $service->serviceCatalog(); }
$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);