Updated Identity Service to OpenStack
This commit is contained in:
parent
969e39833a
commit
a995a9c0a6
@ -29,7 +29,7 @@ SOFTWARE.
|
||||
|
||||
namespace OpenStack;
|
||||
|
||||
use HPCloud\Services\IdentityServices;
|
||||
use OpenStack\Services\IdentityService;
|
||||
use OpenStack\Exception;
|
||||
|
||||
/**
|
||||
@ -133,7 +133,7 @@ class Bootstrap {
|
||||
|
||||
/**
|
||||
* An identity services object created from the global settings.
|
||||
* @var object OpenStack::Services::IdentityServices
|
||||
* @var object OpenStack::Services::IdentityService
|
||||
*/
|
||||
public static $identity = NULL;
|
||||
|
||||
@ -371,14 +371,14 @@ class Bootstrap {
|
||||
|
||||
// Check if we have a username/password
|
||||
if (!empty($user) && self::hasConfig('password')) {
|
||||
$is = new IdentityServices(self::config('endpoint'));
|
||||
$is = new IdentityService(self::config('endpoint'));
|
||||
$is->authenticateAsUser($user, self::config('password'), self::config('tenantid', NULL), self::config('tenantname', NULL));
|
||||
self::$identity = $is;
|
||||
}
|
||||
|
||||
// Otherwise we go with access/secret keys
|
||||
elseif (!empty($account) && self::hasConfig('secret')) {
|
||||
$is = new IdentityServices(self::config('endpoint'));
|
||||
$is = new IdentityService(self::config('endpoint'));
|
||||
$is->authenticateAsAccount($account, self::config('secret'), self::config('tenantid', NULL), self::config('tenantname', NULL));
|
||||
self::$identity = $is;
|
||||
}
|
||||
|
@ -22,15 +22,15 @@ SOFTWARE.
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This file contains the main IdentityServices class.
|
||||
* This file contains the main IdentityService class.
|
||||
*/
|
||||
|
||||
namespace HPCloud\Services;
|
||||
namespace OpenStack\Services;
|
||||
|
||||
/**
|
||||
* IdentityServices provides authentication and authorization.
|
||||
* IdentityService provides authentication and authorization.
|
||||
*
|
||||
* IdentityServices (a.k.a. Keystone) provides a central service for managing
|
||||
* IdentityService (a.k.a. Keystone) provides a central service for managing
|
||||
* other services. Through it, you can do the following:
|
||||
*
|
||||
* - Authenticate
|
||||
@ -75,7 +75,7 @@ namespace HPCloud\Services;
|
||||
* A list of tenants associated with this account can be obtain programatically
|
||||
* using the tenants() method on this object.
|
||||
*
|
||||
* HPCloud customers can find their tenant ID in the console along with their
|
||||
* OpenStack users can find their tenant ID in the console along with their
|
||||
* account ID and secret key.
|
||||
*
|
||||
* @b EXAMPLE
|
||||
@ -84,15 +84,15 @@ namespace HPCloud\Services;
|
||||
*
|
||||
* @code
|
||||
* <?php
|
||||
* // You may need to use \HPCloud\Bootstrap to set things up first.
|
||||
* // You may need to use \OpenStack\Bootstrap to set things up first.
|
||||
*
|
||||
* use \HPCloud\Services\IdentityServices;
|
||||
* use \OpenStack\Services\IdentityService;
|
||||
*
|
||||
* // Create a new object with the endpoint URL (no version number)
|
||||
* $ident = new IdentityServices('https://example.com:35357');
|
||||
* $ident = new IdentityService('https://example.com:35357');
|
||||
*
|
||||
* // Authenticate and set the tenant ID simultaneously.
|
||||
* $ident->authenticateAsUser('butcher@hp.com', 'password', '1234567');
|
||||
* $ident->authenticateAsUser('me@example.com', 'password', '1234567');
|
||||
*
|
||||
* // The token to use when connecting to other services:
|
||||
* $token = $ident->token();
|
||||
@ -124,12 +124,12 @@ namespace HPCloud\Services;
|
||||
*
|
||||
* <b>Serializing</b>
|
||||
*
|
||||
* IdentityServices has been intentionally built to serialize well.
|
||||
* This allows implementors to cache IdentityServices objects rather
|
||||
* IdentityService has been intentionally built to serialize well.
|
||||
* This allows implementors to cache IdentityService objects rather
|
||||
* than make repeated requests for identity information.
|
||||
*
|
||||
*/
|
||||
class IdentityServices /*implements Serializable*/ {
|
||||
class IdentityService /*implements Serializable*/ {
|
||||
/**
|
||||
* The version of the API currently supported.
|
||||
*/
|
||||
@ -179,7 +179,7 @@ class IdentityServices /*implements Serializable*/ {
|
||||
protected $userDetails;
|
||||
|
||||
/**
|
||||
* Build a new IdentityServices object.
|
||||
* Build a new IdentityService object.
|
||||
*
|
||||
* Each object is bound to a particular identity services endpoint.
|
||||
*
|
||||
@ -194,7 +194,7 @@ class IdentityServices /*implements Serializable*/ {
|
||||
*
|
||||
* @code
|
||||
* <?php
|
||||
* $cs = new \HPCloud\Services\IdentityServices('http://example.com');
|
||||
* $cs = new \OpenStack\Services\IdentityService('http://example.com');
|
||||
* $token = $cs->authenticateAsAccount($accountId, $accessKey);
|
||||
* ?>
|
||||
* @endcode
|
||||
@ -241,7 +241,7 @@ class IdentityServices /*implements Serializable*/ {
|
||||
* the authenticate() method:
|
||||
* @code
|
||||
* <?php
|
||||
* $cs = new \HPCloud\Services\IdentityServices($url);
|
||||
* $cs = new \OpenStack\Services\IdentityService($url);
|
||||
* $ops = array(
|
||||
* 'passwordCredentials' => array(
|
||||
* 'username' => $username,
|
||||
@ -263,9 +263,9 @@ class IdentityServices /*implements Serializable*/ {
|
||||
* The token. This is returned for simplicity. The full response is used
|
||||
* to populate this object's service catalog, etc. The token is also
|
||||
* retrievable with token().
|
||||
* @throws HPCloud::Transport::AuthorizationException
|
||||
* @throws OpenStack::Transport::AuthorizationException
|
||||
* If authentication failed.
|
||||
* @throws HPCloud::Exception
|
||||
* @throws OpenStack::Exception
|
||||
* For abnormal network conditions. The message will give an indication as
|
||||
* to the underlying problem.
|
||||
*/
|
||||
@ -285,7 +285,7 @@ class IdentityServices /*implements Serializable*/ {
|
||||
|
||||
//print $body . PHP_EOL;
|
||||
|
||||
$client = \HPCloud\Transport::instance();
|
||||
$client = \OpenStack\Transport::instance();
|
||||
|
||||
$response = $client->doRequest($url, 'POST', $headers, $body);
|
||||
|
||||
@ -299,9 +299,9 @@ class IdentityServices /*implements Serializable*/ {
|
||||
* Authenticate to Identity Services with username, password, and either
|
||||
* tenant ID or tenant Name.
|
||||
*
|
||||
* Given an HPCloud username and password, authenticate to Identity Services.
|
||||
* Given a OpenStack username and password, authenticate to Identity Services.
|
||||
* Identity Services will then issue a token that can be used to access other
|
||||
* HPCloud services.
|
||||
* OpenStack services.
|
||||
*
|
||||
* If a tenant ID is provided, this will also associate the user with the
|
||||
* given tenant ID. If a tenant Name is provided, this will associate the user
|
||||
@ -322,13 +322,13 @@ class IdentityServices /*implements Serializable*/ {
|
||||
* A password string.
|
||||
* @param string $tenantId
|
||||
* The tenant ID for this account. This can be obtained through the
|
||||
* HPCloud console.
|
||||
* OpenStack console.
|
||||
* @param string $tenantName
|
||||
* The tenant Name for this account. This can be obtained through the
|
||||
* HPCloud console.
|
||||
* @throws HPCloud::Transport::AuthorizationException
|
||||
* OpenStack console.
|
||||
* @throws OpenStack::Transport::AuthorizationException
|
||||
* If authentication failed.
|
||||
* @throws HPCloud::Exception
|
||||
* @throws OpenStack::Exception
|
||||
* For abnormal network conditions. The message will give an indication as
|
||||
* to the underlying problem.
|
||||
*/
|
||||
@ -352,11 +352,11 @@ class IdentityServices /*implements Serializable*/ {
|
||||
return $this->authenticate($ops);
|
||||
}
|
||||
/**
|
||||
* Authenticate to HPCloud using your account ID and access key.
|
||||
* Authenticate to OpenStack using your account ID and access key.
|
||||
*
|
||||
* Given an account ID and and access key (secret key), authenticate
|
||||
* to Identity Services. Identity Services will then issue a token that can be
|
||||
* used with other HPCloud services, such as Object Storage (aka Swift).
|
||||
* used with other OpenStack services, such as Object Storage (aka Swift).
|
||||
*
|
||||
* The account ID and access key information can be found in the account
|
||||
* section of the console.
|
||||
@ -383,13 +383,13 @@ class IdentityServices /*implements Serializable*/ {
|
||||
* with this token.
|
||||
* @param string $tenantName
|
||||
* The tenant Name for this account. This can be obtained through the
|
||||
* HPCloud console.
|
||||
* OpenStack console.
|
||||
* @retval string
|
||||
* @return string
|
||||
* The auth token.
|
||||
* @throws HPCloud::Transport::AuthorizationException
|
||||
* @throws OpenStack::Transport::AuthorizationException
|
||||
* If authentication failed.
|
||||
* @throws HPCloud::Exception
|
||||
* @throws OpenStack::Exception
|
||||
* For abnormal network conditions. The message will give an indication as
|
||||
* to the underlying problem.
|
||||
*/
|
||||
@ -673,9 +673,9 @@ class IdentityServices /*implements Serializable*/ {
|
||||
* @return array
|
||||
* An indexed array of tenant info. Each entry will be an associative
|
||||
* array containing tenant details.
|
||||
* @throws HPCloud::Transport::AuthorizationException
|
||||
* @throws OpenStack::Transport::AuthorizationException
|
||||
* If authentication failed.
|
||||
* @throws HPCloud::Exception
|
||||
* @throws OpenStack::Exception
|
||||
* For abnormal network conditions. The message will give an indication as
|
||||
* to the underlying problem.
|
||||
*/
|
||||
@ -692,7 +692,7 @@ class IdentityServices /*implements Serializable*/ {
|
||||
//'Content-Type' => 'application/json',
|
||||
);
|
||||
|
||||
$client = \HPCloud\Transport::instance();
|
||||
$client = \OpenStack\Transport::instance();
|
||||
$response = $client->doRequest($url, 'GET', $headers);
|
||||
|
||||
$raw = $response->content();
|
||||
@ -703,7 +703,7 @@ class IdentityServices /*implements Serializable*/ {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HPCloud::Services::IdentityServices::rescopeUsingTenantId()
|
||||
* @see OpenStack::Services::IdentityService::rescopeUsingTenantId()
|
||||
* @deprecated
|
||||
*/
|
||||
public function rescope($tenantId) {
|
||||
@ -735,9 +735,9 @@ class IdentityServices /*implements Serializable*/ {
|
||||
* @retval string
|
||||
* @return string
|
||||
* The authentication token.
|
||||
* @throws HPCloud::Transport::AuthorizationException
|
||||
* @throws OpenStack::Transport::AuthorizationException
|
||||
* If authentication failed.
|
||||
* @throws HPCloud::Exception
|
||||
* @throws OpenStack::Exception
|
||||
* For abnormal network conditions. The message will give an indication as
|
||||
* to the underlying problem.
|
||||
*/
|
||||
@ -761,7 +761,7 @@ class IdentityServices /*implements Serializable*/ {
|
||||
//'X-Auth-Token' => $token,
|
||||
);
|
||||
|
||||
$client = \HPCloud\Transport::instance();
|
||||
$client = \OpenStack\Transport::instance();
|
||||
$response = $client->doRequest($url, 'POST', $headers, $body);
|
||||
$this->handleResponse($response);
|
||||
|
||||
@ -793,9 +793,9 @@ class IdentityServices /*implements Serializable*/ {
|
||||
* @retval string
|
||||
* @return string
|
||||
* The authentication token.
|
||||
* @throws HPCloud::Transport::AuthorizationException
|
||||
* @throws OpenStack::Transport::AuthorizationException
|
||||
* If authentication failed.
|
||||
* @throws HPCloud::Exception
|
||||
* @throws OpenStack::Exception
|
||||
* For abnormal network conditions. The message will give an indication as
|
||||
* to the underlying problem.
|
||||
*/
|
||||
@ -819,7 +819,7 @@ class IdentityServices /*implements Serializable*/ {
|
||||
//'X-Auth-Token' => $token,
|
||||
);
|
||||
|
||||
$client = \HPCloud\Transport::instance();
|
||||
$client = \OpenStack\Transport::instance();
|
||||
$response = $client->doRequest($url, 'POST', $headers, $body);
|
||||
$this->handleResponse($response);
|
||||
|
||||
@ -832,11 +832,11 @@ class IdentityServices /*implements Serializable*/ {
|
||||
* This parses the JSON data and parcels out the data to the appropriate
|
||||
* fields.
|
||||
*
|
||||
* @param object $response HPCloud::Transport::Response
|
||||
* @param object $response OpenStack::Transport::Response
|
||||
* A response object.
|
||||
*
|
||||
* @retval HPCloud::Services::IdentityServices
|
||||
* @return \HPCloud\Services\IdentityServices
|
||||
* @retval OpenStack::Services::IdentityService
|
||||
* @return \OpenStack\Services\IdentityService
|
||||
* $this for the current object so it can be used in chaining.
|
||||
*/
|
||||
protected function handleResponse($response) {
|
@ -82,11 +82,11 @@ Your settings should look something like this:
|
||||
|
||||
hpcloud.swift.container = "I♡HPCloud"
|
||||
|
||||
hpcloud.identity.url = https://region-a.geo-1.idenity.hpcloudsvc.com
|
||||
hpcloud.identity.tenantId = 12345
|
||||
hpcloud.identity.username = butcher@hp.com
|
||||
hpcloud.identity.password = secret
|
||||
hpcloud.identity.account = 54321
|
||||
openstack.identity.url = https://region-a.geo-1.idenity.hpcloudsvc.com
|
||||
openstack.identity.tenantId = 12345
|
||||
openstack.identity.username = butcher@hp.com
|
||||
openstack.identity.password = secret
|
||||
openstack.identity.access = 54321
|
||||
hpcloud.identity.key = 9878787
|
||||
```
|
||||
|
||||
|
@ -100,7 +100,7 @@ class TestCase extends \PHPUnit_Framework_TestCase {
|
||||
$user = self::$settings['hpcloud.swift.account'];
|
||||
$key = self::$settings['hpcloud.swift.key'];
|
||||
$url = self::$settings['hpcloud.swift.url'];
|
||||
//$url = self::$settings['hpcloud.identity.url'];
|
||||
//$url = self::$settings['openstack.identity.url'];
|
||||
|
||||
return \HPCloud\Storage\ObjectStorage::newFromSwiftAuth($user, $key, $url);
|
||||
|
||||
@ -122,10 +122,10 @@ class TestCase extends \PHPUnit_Framework_TestCase {
|
||||
protected function identity($reset = FALSE) {
|
||||
|
||||
if ($reset || empty(self::$ident)) {
|
||||
$user = self::conf('hpcloud.identity.username');
|
||||
$pass = self::conf('hpcloud.identity.password');
|
||||
$tenantId = self::conf('hpcloud.identity.tenantId');
|
||||
$url = self::conf('hpcloud.identity.url');
|
||||
$user = self::conf('openstack.identity.username');
|
||||
$pass = self::conf('openstack.identity.password');
|
||||
$tenantId = self::conf('openstack.identity.tenantId');
|
||||
$url = self::conf('openstack.identity.url');
|
||||
|
||||
$is = new \HPCloud\Services\IdentityServices($url);
|
||||
|
||||
|
@ -22,26 +22,26 @@ SOFTWARE.
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Unit tests for IdentityServices.
|
||||
* Unit tests for IdentityService.
|
||||
*/
|
||||
namespace HPCloud\Tests\Services;
|
||||
namespace OpenStack\Tests\Services;
|
||||
|
||||
require_once 'src/HPCloud/Bootstrap.php';
|
||||
require_once 'src/OpenStack/Bootstrap.php';
|
||||
require_once 'test/TestCase.php';
|
||||
|
||||
use \HPCloud\Services\IdentityServices;
|
||||
use \HPCloud\Bootstrap;
|
||||
use \OpenStack\Services\IdentityService;
|
||||
use \OpenStack\Bootstrap;
|
||||
|
||||
|
||||
class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
class IdentityServiceTest extends \OpenStack\Tests\TestCase {
|
||||
|
||||
public function testConstructor(){
|
||||
$endpoint = self::conf('hpcloud.identity.url');
|
||||
$endpoint = self::conf('openstack.identity.url');
|
||||
$this->assertNotEmpty($endpoint);
|
||||
|
||||
$service = new IdentityServices($endpoint);
|
||||
$service = new IdentityService($endpoint);
|
||||
|
||||
$this->assertInstanceOf('\HPCloud\Services\IdentityServices', $service);
|
||||
$this->assertInstanceOf('\OpenStack\Services\IdentityService', $service);
|
||||
|
||||
return $service;
|
||||
}
|
||||
@ -50,8 +50,8 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
* @depends testConstructor
|
||||
*/
|
||||
public function testUrl() {
|
||||
$endpoint = self::conf('hpcloud.identity.url');
|
||||
$service = new IdentityServices($endpoint);
|
||||
$endpoint = self::conf('openstack.identity.url');
|
||||
$service = new IdentityService($endpoint);
|
||||
|
||||
// If there is a trailing / we remove that from the endpoint. Our calls add
|
||||
// the / back where appropriate.
|
||||
@ -67,11 +67,11 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
|
||||
// Canary: Make sure all the required params are declared.
|
||||
$settings = array(
|
||||
'hpcloud.identity.username',
|
||||
'hpcloud.identity.password',
|
||||
'hpcloud.identity.tenantId',
|
||||
'hpcloud.identity.account',
|
||||
'hpcloud.identity.secret',
|
||||
'openstack.identity.username',
|
||||
'openstack.identity.password',
|
||||
'openstack.identity.tenantId',
|
||||
'openstack.identity.access',
|
||||
'openstack.identity.secret',
|
||||
);
|
||||
foreach ($settings as $setting) {
|
||||
$this->assertNotEmpty(self::conf($setting), "Required param: " . $setting);
|
||||
@ -80,26 +80,26 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
// Test username/password auth.
|
||||
$auth = array(
|
||||
'passwordCredentials' => array(
|
||||
'username' => self::conf('hpcloud.identity.username'),
|
||||
'password' => self::conf('hpcloud.identity.password'),
|
||||
'username' => self::conf('openstack.identity.username'),
|
||||
'password' => self::conf('openstack.identity.password'),
|
||||
),
|
||||
'tenantId' => self::conf('hpcloud.identity.tenantId'),
|
||||
'tenantId' => self::conf('openstack.identity.tenantId'),
|
||||
);
|
||||
$tok = $service->authenticate($auth);
|
||||
$this->assertNotEmpty($tok);
|
||||
|
||||
// We should get the same token if we request again.
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$tok2 = $service->authenticate($auth);
|
||||
$this->assertEquals($tok, $tok2);
|
||||
|
||||
// Again with no tenant ID.
|
||||
$auth = array(
|
||||
'passwordCredentials' => array(
|
||||
'username' => self::conf('hpcloud.identity.username'),
|
||||
'password' => self::conf('hpcloud.identity.password'),
|
||||
'username' => self::conf('openstack.identity.username'),
|
||||
'password' => self::conf('openstack.identity.password'),
|
||||
),
|
||||
//'tenantId' => self::conf('hpcloud.identity.tenantId'),
|
||||
//'tenantId' => self::conf('openstack.identity.tenantId'),
|
||||
);
|
||||
$tok = $service->authenticate($auth);
|
||||
$this->assertNotEmpty($tok);
|
||||
@ -108,11 +108,11 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
// Test account ID/secret key auth.
|
||||
$auth = array(
|
||||
'apiAccessKeyCredentials' => array(
|
||||
'accessKey' => self::conf('hpcloud.identity.account'),
|
||||
'secretKey' => self::conf('hpcloud.identity.secret'),
|
||||
'accessKey' => self::conf('openstack.identity.access'),
|
||||
'secretKey' => self::conf('openstack.identity.secret'),
|
||||
),
|
||||
);
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$tok3 = $service->authenticate($auth);
|
||||
|
||||
$this->assertNotEmpty($tok3);
|
||||
@ -123,11 +123,11 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
* @depends testAuthenticate
|
||||
*/
|
||||
public function testAuthenticateAsUser() {
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
|
||||
$user = self::conf('hpcloud.identity.username');
|
||||
$pass = self::conf('hpcloud.identity.password');
|
||||
$tenantId = self::conf('hpcloud.identity.tenantId');
|
||||
$user = self::conf('openstack.identity.username');
|
||||
$pass = self::conf('openstack.identity.password');
|
||||
$tenantId = self::conf('openstack.identity.tenantId');
|
||||
|
||||
$tok = $service->authenticateAsUser($user, $pass, $tenantId);
|
||||
|
||||
@ -145,11 +145,11 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
* @depends testAuthenticate
|
||||
*/
|
||||
public function testAuthenticateAsAccount() {
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
|
||||
$account = self::conf('hpcloud.identity.account');
|
||||
$secret = self::conf('hpcloud.identity.secret');
|
||||
$tenantId = self::conf('hpcloud.identity.tenantId');
|
||||
$account = self::conf('openstack.identity.access');
|
||||
$secret = self::conf('openstack.identity.secret');
|
||||
$tenantId = self::conf('openstack.identity.tenantId');
|
||||
|
||||
// No tenant ID.
|
||||
$tok = $service->authenticateAsAccount($account, $secret);
|
||||
@ -157,7 +157,7 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
$this->assertEmpty($service->tenantId());
|
||||
|
||||
// No tenant ID.
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$tok = $service->authenticateAsAccount($account, $secret, $tenantId);
|
||||
$this->assertNotEmpty($tok);
|
||||
$this->assertEquals($tenantId, $service->tenantId());
|
||||
@ -178,7 +178,7 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
public function testIsExpired($service) {
|
||||
$this->assertFalse($service->isExpired());
|
||||
|
||||
$service2 = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service2 = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$this->assertTrue($service2->isExpired());
|
||||
}
|
||||
|
||||
@ -186,29 +186,29 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
* @depends testAuthenticateAsAccount
|
||||
*/
|
||||
public function testTenantName() {
|
||||
$account = self::conf('hpcloud.identity.account');
|
||||
$secret = self::conf('hpcloud.identity.secret');
|
||||
$user = self::conf('hpcloud.identity.username');
|
||||
$pass = self::conf('hpcloud.identity.password');
|
||||
$tenantName = self::conf('hpcloud.identity.tenantName');
|
||||
$account = self::conf('openstack.identity.access');
|
||||
$secret = self::conf('openstack.identity.secret');
|
||||
$user = self::conf('openstack.identity.username');
|
||||
$pass = self::conf('openstack.identity.password');
|
||||
$tenantName = self::conf('openstack.identity.tenantName');
|
||||
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$this->assertNull($service->tenantName());
|
||||
|
||||
$service->authenticateAsUser($user, $pass);
|
||||
$this->assertEmpty($service->tenantName());
|
||||
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$ret = $service->authenticateAsUser($user, $pass, NULL, $tenantName);
|
||||
$this->assertNotEmpty($service->tenantName());
|
||||
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$this->assertNull($service->tenantName());
|
||||
|
||||
$service->authenticateAsAccount($account, $secret);
|
||||
$this->assertEmpty($service->tenantName());
|
||||
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$ret = $service->authenticateAsAccount($account, $secret, NULL, $tenantName);
|
||||
$this->assertNotEmpty($service->tenantName());
|
||||
$this->assertEquals($tenantName, $service->tenantName());
|
||||
@ -218,17 +218,17 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
* @depends testAuthenticateAsAccount
|
||||
*/
|
||||
public function testTenantId() {
|
||||
$user = self::conf('hpcloud.identity.username');
|
||||
$pass = self::conf('hpcloud.identity.password');
|
||||
$tenantId = self::conf('hpcloud.identity.tenantId');
|
||||
$user = self::conf('openstack.identity.username');
|
||||
$pass = self::conf('openstack.identity.password');
|
||||
$tenantId = self::conf('openstack.identity.tenantId');
|
||||
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$this->assertNull($service->tenantId());
|
||||
|
||||
$service->authenticateAsUser($user, $pass);
|
||||
$this->assertEmpty($service->tenantId());
|
||||
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$service->authenticateAsUser($user, $pass, $tenantId);
|
||||
$this->assertNotEmpty($service->tenantId());
|
||||
}
|
||||
@ -238,11 +238,11 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
*/
|
||||
public function testTokenDetails() {
|
||||
$now = time();
|
||||
$user = self::conf('hpcloud.identity.username');
|
||||
$pass = self::conf('hpcloud.identity.password');
|
||||
$tenantId = self::conf('hpcloud.identity.tenantId');
|
||||
$user = self::conf('openstack.identity.username');
|
||||
$pass = self::conf('openstack.identity.password');
|
||||
$tenantId = self::conf('openstack.identity.tenantId');
|
||||
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$service->authenticateAsUser($user, $pass);
|
||||
|
||||
// Details for account auth.
|
||||
@ -255,12 +255,12 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
|
||||
|
||||
// Test details for username auth.
|
||||
$service = new IdentityServices(self::conf('hpcloud.identity.url'));
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$service->authenticateAsUser($user, $pass, $tenantId);
|
||||
|
||||
$details = $service->tokenDetails();
|
||||
|
||||
$expectUser = self::conf('hpcloud.identity.username');
|
||||
$expectUser = self::conf('openstack.identity.username');
|
||||
|
||||
$this->assertStringStartsWith($expectUser, $details['tenant']['name']);
|
||||
$this->assertNotEmpty($details['id']);
|
||||
@ -312,7 +312,7 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
public function testUser($service) {
|
||||
$user = $service->user();
|
||||
|
||||
$this->assertEquals(self::conf('hpcloud.identity.username'), $user['name']);
|
||||
$this->assertEquals(self::conf('openstack.identity.username'), $user['name']);
|
||||
$this->assertNotEmpty($user['roles']);
|
||||
}
|
||||
|
||||
@ -328,7 +328,7 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
|
||||
$again = unserialize($ser);
|
||||
|
||||
$this->assertInstanceOf('\HPCloud\Services\IdentityServices', $again);
|
||||
$this->assertInstanceOf('\OpenStack\Services\IdentityService', $again);
|
||||
|
||||
$this->assertEquals($service->tenantId(), $again->tenantId());
|
||||
$this->assertEquals($service->serviceCatalog(), $again->serviceCatalog());
|
||||
@ -347,11 +347,11 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
* @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 = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$service2 = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$user = self::conf('openstack.identity.username');
|
||||
$pass = self::conf('openstack.identity.password');
|
||||
$tenantId = self::conf('openstack.identity.tenantId');
|
||||
$service->authenticateAsUser($user, $pass, $tenantId);
|
||||
|
||||
|
||||
@ -373,10 +373,10 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
* @depends testTenants
|
||||
*/
|
||||
function testRescope() {
|
||||
$service = 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 = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$user = self::conf('openstack.identity.username');
|
||||
$pass = self::conf('openstack.identity.password');
|
||||
$tenantId = self::conf('openstack.identity.tenantId');
|
||||
|
||||
// Authenticate without a tenant ID.
|
||||
$token = $service->authenticateAsUser($user, $pass);
|
||||
@ -413,10 +413,10 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
* @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');
|
||||
$service = new IdentityService(self::conf('openstack.identity.url'));
|
||||
$user = self::conf('openstack.identity.username');
|
||||
$pass = self::conf('openstack.identity.password');
|
||||
$tenantName = self::conf('openstack.identity.tenantName');
|
||||
|
||||
// Authenticate without a tenant ID.
|
||||
$token = $service->authenticateAsUser($user, $pass);
|
||||
@ -463,29 +463,29 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
|
||||
// Test authenticating as a user.
|
||||
$settings = array(
|
||||
'username' => self::conf('hpcloud.identity.username'),
|
||||
'password' => self::conf('hpcloud.identity.password'),
|
||||
'endpoint' => self::conf('hpcloud.identity.url'),
|
||||
'tenantid' => self::conf('hpcloud.identity.tenantId'),
|
||||
'username' => self::conf('openstack.identity.username'),
|
||||
'password' => self::conf('openstack.identity.password'),
|
||||
'endpoint' => self::conf('openstack.identity.url'),
|
||||
'tenantid' => self::conf('openstack.identity.tenantId'),
|
||||
);
|
||||
Bootstrap::setConfiguration($settings);
|
||||
|
||||
$is = Bootstrap::identity(TRUE);
|
||||
$this->assertInstanceOf('\HPCloud\Services\IdentityServices', $is);
|
||||
$this->assertInstanceOf('\OpenStack\Services\IdentityService', $is);
|
||||
|
||||
Bootstrap::$config = $reset;
|
||||
|
||||
// Test authenticating as an account.
|
||||
$settings = array(
|
||||
'account' => self::conf('hpcloud.identity.account'),
|
||||
'secret' => self::conf('hpcloud.identity.secret'),
|
||||
'endpoint' => self::conf('hpcloud.identity.url'),
|
||||
'tenantid' => self::conf('hpcloud.identity.tenantId'),
|
||||
'account' => self::conf('openstack.identity.access'),
|
||||
'secret' => self::conf('openstack.identity.secret'),
|
||||
'endpoint' => self::conf('openstack.identity.url'),
|
||||
'tenantid' => self::conf('openstack.identity.tenantId'),
|
||||
);
|
||||
Bootstrap::setConfiguration($settings);
|
||||
|
||||
$is = Bootstrap::identity(TRUE);
|
||||
$this->assertInstanceOf('\HPCloud\Services\IdentityServices', $is);
|
||||
$this->assertInstanceOf('\OpenStack\Services\IdentityService', $is);
|
||||
|
||||
// Test getting a second instance from the cache.
|
||||
$is2 = Bootstrap::identity();
|
||||
@ -499,25 +499,25 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
|
||||
// Test with tenant name
|
||||
$settings = array(
|
||||
'account' => self::conf('hpcloud.identity.account'),
|
||||
'secret' => self::conf('hpcloud.identity.secret'),
|
||||
'endpoint' => self::conf('hpcloud.identity.url'),
|
||||
'tenantname' => self::conf('hpcloud.identity.tenantName'),
|
||||
'account' => self::conf('openstack.identity.access'),
|
||||
'secret' => self::conf('openstack.identity.secret'),
|
||||
'endpoint' => self::conf('openstack.identity.url'),
|
||||
'tenantname' => self::conf('openstack.identity.tenantName'),
|
||||
);
|
||||
Bootstrap::setConfiguration($settings);
|
||||
|
||||
$is = Bootstrap::identity(TRUE);
|
||||
$this->assertInstanceOf('\HPCloud\Services\IdentityServices', $is);
|
||||
$this->assertInstanceOf('\OpenStack\Services\IdentityService', $is);
|
||||
|
||||
$settings = array(
|
||||
'username' => self::conf('hpcloud.identity.username'),
|
||||
'password' => self::conf('hpcloud.identity.password'),
|
||||
'endpoint' => self::conf('hpcloud.identity.url'),
|
||||
'tenantname' => self::conf('hpcloud.identity.tenantName'),
|
||||
'username' => self::conf('openstack.identity.username'),
|
||||
'password' => self::conf('openstack.identity.password'),
|
||||
'endpoint' => self::conf('openstack.identity.url'),
|
||||
'tenantname' => self::conf('openstack.identity.tenantName'),
|
||||
);
|
||||
Bootstrap::setConfiguration($settings);
|
||||
|
||||
$is = Bootstrap::identity(TRUE);
|
||||
$this->assertInstanceOf('\HPCloud\Services\IdentityServices', $is);
|
||||
$this->assertInstanceOf('\OpenStack\Services\IdentityService', $is);
|
||||
}
|
||||
}
|
||||
|
@ -51,10 +51,10 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
|
||||
public static function tearDownAfterClass() {
|
||||
|
||||
// First we get an identity
|
||||
$user = self::conf('hpcloud.identity.username');
|
||||
$pass = self::conf('hpcloud.identity.password');
|
||||
$tenantId = self::conf('hpcloud.identity.tenantId');
|
||||
$url = self::conf('hpcloud.identity.url');
|
||||
$user = self::conf('openstack.identity.username');
|
||||
$pass = self::conf('openstack.identity.password');
|
||||
$tenantId = self::conf('openstack.identity.tenantId');
|
||||
$url = self::conf('openstack.identity.url');
|
||||
|
||||
$ident = new \HPCloud\Services\IdentityServices($url);
|
||||
|
||||
@ -133,10 +133,10 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
|
||||
*/
|
||||
protected function authSwiftContext($add = array(), $scheme = NULL) {
|
||||
$cname = self::$settings['hpcloud.swift.container'];
|
||||
$account = self::$settings['hpcloud.identity.account'];
|
||||
$key = self::$settings['hpcloud.identity.secret'];
|
||||
$tenant = self::$settings['hpcloud.identity.tenantId'];
|
||||
$baseURL = self::$settings['hpcloud.identity.url'];
|
||||
$account = self::$settings['openstack.identity.access'];
|
||||
$key = self::$settings['openstack.identity.secret'];
|
||||
$tenant = self::$settings['openstack.identity.tenantId'];
|
||||
$baseURL = self::$settings['openstack.identity.url'];
|
||||
|
||||
if (empty($scheme)) {
|
||||
$scheme = StreamWrapperFS::DEFAULT_SCHEME;
|
||||
@ -166,10 +166,10 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
|
||||
*/
|
||||
protected function addBootstrapConfig() {
|
||||
$opts = array(
|
||||
'account' => self::$settings['hpcloud.identity.account'],
|
||||
'key' => self::$settings['hpcloud.identity.secret'],
|
||||
'endpoint' => self::$settings['hpcloud.identity.url'],
|
||||
'tenantid' => self::$settings['hpcloud.identity.tenantId'],
|
||||
'account' => self::$settings['openstack.identity.access'],
|
||||
'key' => self::$settings['openstack.identity.secret'],
|
||||
'endpoint' => self::$settings['openstack.identity.url'],
|
||||
'tenantid' => self::$settings['openstack.identity.tenantId'],
|
||||
'token' => $this->objectStore()->token(),
|
||||
'swift_endpoint' => $this->objectStore()->url(),
|
||||
);
|
||||
@ -188,7 +188,7 @@ class StreamWrapperFSTest extends \HPCloud\Tests\TestCase {
|
||||
$array = stream_context_get_options($cxt);
|
||||
|
||||
$opts = $array['swiftfs'];
|
||||
$endpoint = self::conf('hpcloud.identity.url');
|
||||
$endpoint = self::conf('openstack.identity.url');
|
||||
|
||||
$this->assertEquals($endpoint, $opts['endpoint'], 'A UTF-8 encoding issue.');
|
||||
}
|
||||
|
@ -48,10 +48,10 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
|
||||
public static function tearDownAfterClass() {
|
||||
|
||||
// First we get an identity
|
||||
$user = self::conf('hpcloud.identity.username');
|
||||
$pass = self::conf('hpcloud.identity.password');
|
||||
$tenantId = self::conf('hpcloud.identity.tenantId');
|
||||
$url = self::conf('hpcloud.identity.url');
|
||||
$user = self::conf('openstack.identity.username');
|
||||
$pass = self::conf('openstack.identity.password');
|
||||
$tenantId = self::conf('openstack.identity.tenantId');
|
||||
$url = self::conf('openstack.identity.url');
|
||||
|
||||
$ident = new \HPCloud\Services\IdentityServices($url);
|
||||
|
||||
@ -130,10 +130,10 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
|
||||
*/
|
||||
protected function authSwiftContext($add = array(), $scheme = NULL) {
|
||||
$cname = self::$settings['hpcloud.swift.container'];
|
||||
$account = self::$settings['hpcloud.identity.account'];
|
||||
$key = self::$settings['hpcloud.identity.secret'];
|
||||
$tenant = self::$settings['hpcloud.identity.tenantId'];
|
||||
$baseURL = self::$settings['hpcloud.identity.url'];
|
||||
$account = self::$settings['openstack.identity.access'];
|
||||
$key = self::$settings['openstack.identity.secret'];
|
||||
$tenant = self::$settings['openstack.identity.tenantId'];
|
||||
$baseURL = self::$settings['openstack.identity.url'];
|
||||
|
||||
if (empty($scheme)) {
|
||||
$scheme = StreamWrapper::DEFAULT_SCHEME;
|
||||
@ -163,10 +163,10 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
|
||||
*/
|
||||
protected function addBootstrapConfig() {
|
||||
$opts = array(
|
||||
'account' => self::$settings['hpcloud.identity.account'],
|
||||
'key' => self::$settings['hpcloud.identity.secret'],
|
||||
'endpoint' => self::$settings['hpcloud.identity.url'],
|
||||
'tenantid' => self::$settings['hpcloud.identity.tenantId'],
|
||||
'account' => self::$settings['openstack.identity.access'],
|
||||
'key' => self::$settings['openstack.identity.secret'],
|
||||
'endpoint' => self::$settings['openstack.identity.url'],
|
||||
'tenantid' => self::$settings['openstack.identity.tenantId'],
|
||||
'token' => $this->objectStore()->token(),
|
||||
'swift_endpoint' => $this->objectStore()->url(),
|
||||
);
|
||||
@ -185,7 +185,7 @@ class StreamWrapperTest extends \HPCloud\Tests\TestCase {
|
||||
$array = stream_context_get_options($cxt);
|
||||
|
||||
$opts = $array['swift'];
|
||||
$endpoint = self::conf('hpcloud.identity.url');
|
||||
$endpoint = self::conf('openstack.identity.url');
|
||||
|
||||
$this->assertEquals($endpoint, $opts['endpoint'], 'A UTF-8 encoding issue.');
|
||||
}
|
||||
|
@ -1,3 +1,21 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
; Identity Services ;
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; This is the default Identity Service URL.
|
||||
openstack.identity.url = https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0
|
||||
|
||||
; Set the tenant ID
|
||||
openstack.identity.tenantId =
|
||||
openstack.identity.tenantName =
|
||||
|
||||
; For authentication by username.
|
||||
openstack.identity.username =
|
||||
openstack.identity.password =
|
||||
|
||||
; For authentication by account ID.
|
||||
openstack.identity.access =
|
||||
openstack.identity.secret =
|
||||
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
; Object Storage ;
|
||||
@ -18,24 +36,6 @@ hpcloud.swift.container = "I♡HPCloud"
|
||||
; Specified region name to test against.
|
||||
hpcloud.swift.region = "region-a.geo-1"
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
; Identity Services ;
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; This is the default Identity Service URL.
|
||||
hpcloud.identity.url = https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0
|
||||
|
||||
; Set the tenant ID
|
||||
hpcloud.identity.tenantId =
|
||||
|
||||
; For authentication by username.
|
||||
hpcloud.identity.username =
|
||||
hpcloud.identity.password =
|
||||
|
||||
; For authentication by account ID.
|
||||
hpcloud.identity.account =
|
||||
hpcloud.identity.secret =
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Configuration Parameters ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
Loading…
x
Reference in New Issue
Block a user