/** * Test the bootstrap identity factory. * @depends testAuthenticateAsUser */ public 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 = ['username' => self::conf('openstack.identity.username'), 'password' => self::conf('openstack.identity.password'), 'endpoint' => self::conf('openstack.identity.url'), 'tenantid' => self::conf('openstack.identity.tenantId'), 'transport' => self::conf('transport'), 'transport.debug' => self::conf('transport.debug', false), 'transport.ssl_verify' => self::conf('transport.ssl', true)]; if (self::conf('transport.timeout')) { $setting['transport.timeout'] = self::conf('transport.timeout'); } if (self::conf('transport.proxy')) { $setting['transport.proxy'] = self::conf('transport.proxy'); } Bootstrap::setConfiguration($settings); $is = Bootstrap::identity(true); $this->assertInstanceOf('\\OpenStack\\Identity\\v2\\IdentityService', $is); // Test getting a second instance from the cache. $is2 = Bootstrap::identity(); $this->assertEquals($is, $is2); // Test that forcing a refresh does so. $is2 = Bootstrap::identity(true); $this->assertNotEquals($is, $is2); Bootstrap::$config = $reset; // Test with tenant name $settings = ['username' => self::conf('openstack.identity.username'), 'password' => self::conf('openstack.identity.password'), 'endpoint' => self::conf('openstack.identity.url'), 'tenantname' => self::conf('openstack.identity.tenantName'), 'transport' => self::conf('transport'), 'transport.debug' => self::conf('transport.debug', false), 'transport.ssl_verify' => self::conf('transport.ssl', true)]; if (self::conf('transport.timeout')) { $setting['transport.timeout'] = self::conf('transport.timeout'); } if (self::conf('transport.proxy')) { $setting['transport.proxy'] = self::conf('transport.proxy'); } Bootstrap::setConfiguration($settings); $is = Bootstrap::identity(true); $this->assertInstanceOf('\\OpenStack\\Identity\\v2\\IdentityService', $is); }