diff --git a/src/HPCloud/Bootstrap.php b/src/HPCloud/Bootstrap.php index 64ae56c..a47d771 100644 --- a/src/HPCloud/Bootstrap.php +++ b/src/HPCloud/Bootstrap.php @@ -356,14 +356,14 @@ class Bootstrap { // Check if we have a username/password if (!empty($user) && self::hasConfig('password')) { $is = new IdentityServices(self::config('endpoint')); - $is->authenticateAsUser($user, self::config('password'), self::config('tenantid', NULL)); + $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->authenticateAsAccount($account, self::config('secret'), self::config('tenantid', NULL)); + $is->authenticateAsAccount($account, self::config('secret'), self::config('tenantid', NULL), self::config('tenantname', NULL)); self::$identity = $is; } diff --git a/test/Tests/IdentityServicesTest.php b/test/Tests/IdentityServicesTest.php index 29e0761..ec0c783 100644 --- a/test/Tests/IdentityServicesTest.php +++ b/test/Tests/IdentityServicesTest.php @@ -453,6 +453,12 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase { */ 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 = array( 'username' => self::conf('hpcloud.identity.username'), @@ -465,10 +471,12 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase { $is = Bootstrap::identity(TRUE); $this->assertInstanceOf('\HPCloud\Services\IdentityServices', $is); + Bootstrap::$config = $reset; + // Test authenticating as an account. $settings = array( 'account' => self::conf('hpcloud.identity.account'), - 'key' => self::conf('hpcloud.identity.secret'), + 'secret' => self::conf('hpcloud.identity.secret'), 'endpoint' => self::conf('hpcloud.identity.url'), 'tenantid' => self::conf('hpcloud.identity.tenantId'), ); @@ -484,5 +492,30 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase { // Test that forcing a refresh does so. $is2 = Bootstrap::identity(TRUE); $this->assertNotEquals($is, $is2); + + Bootstrap::$config = $reset; + + // 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'), + ); + Bootstrap::setConfiguration($settings); + + $is = Bootstrap::identity(TRUE); + $this->assertInstanceOf('\HPCloud\Services\IdentityServices', $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'), + ); + Bootstrap::setConfiguration($settings); + + $is = Bootstrap::identity(TRUE); + $this->assertInstanceOf('\HPCloud\Services\IdentityServices', $is); } }