Added explicit testing and support for IdenityService serialization.
This commit is contained in:
parent
026a6e58bf
commit
5914dd1984
@ -122,9 +122,14 @@ namespace HPCloud\Services;
|
||||
* - tenants()
|
||||
* - rescope()
|
||||
*
|
||||
* <b>Serializing</b>
|
||||
*
|
||||
* IdentityServices has been intentionally built to serialize well.
|
||||
* This allows implementors to cache IdentityServices objects rather
|
||||
* than make repeated requests for identity information.
|
||||
*
|
||||
*/
|
||||
class IdentityServices {
|
||||
class IdentityServices /*implements Serializable*/ {
|
||||
/**
|
||||
* The version of the API currently supported.
|
||||
*/
|
||||
@ -171,6 +176,8 @@ class IdentityServices {
|
||||
*/
|
||||
protected $catalog = array();
|
||||
|
||||
protected $userDetails;
|
||||
|
||||
/**
|
||||
* Build a new IdentityServices object.
|
||||
*
|
||||
@ -687,6 +694,7 @@ class IdentityServices {
|
||||
|
||||
/**
|
||||
* @see HPCloud::Services::IdentityServices::rescopeUsingTenantId()
|
||||
* @deprecated
|
||||
*/
|
||||
public function rescope($tenantId) {
|
||||
return $this->rescopeUsingTenantId($tenantId);
|
||||
@ -824,4 +832,24 @@ class IdentityServices {
|
||||
$this->serviceCatalog = $json['access']['serviceCatalog'];
|
||||
}
|
||||
|
||||
/* Not necessary.
|
||||
public function serialize() {
|
||||
$data = array(
|
||||
'tokenDetails' => $this->tokenDetails,
|
||||
'userDetails' => $this->userDetails,
|
||||
'serviceCatalog' => $this->serviceCatalog,
|
||||
'endpoint' => $this->endpoint,
|
||||
);
|
||||
return serialize($data);
|
||||
}
|
||||
|
||||
public function unserialize($data) {
|
||||
$vals = unserialize($data);
|
||||
$this->tokenDetails = $vals['tokenDetails'];
|
||||
$this->userDetails = $vals['userDetails'];
|
||||
$this->serviceCatalog = $vals['serviceCatalog'];
|
||||
$this->endpoint = $vals['endpoint'];
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -314,6 +314,33 @@ class IdentityServicesTest extends \HPCloud\Tests\TestCase {
|
||||
$this->assertNotEmpty($user['roles']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAuthenticateAsAccount
|
||||
* @group serialize
|
||||
*/
|
||||
public function testSerialization($service) {
|
||||
|
||||
$ser = serialize($service);
|
||||
|
||||
$this->assertNotEmpty($ser);
|
||||
|
||||
$again = unserialize($ser);
|
||||
|
||||
$this->assertInstanceOf('\HPCloud\Services\IdentityServices', $again);
|
||||
|
||||
$this->assertEquals($service->tenantId(), $again->tenantId());
|
||||
$this->assertEquals($service->serviceCatalog(), $again->serviceCatalog());
|
||||
$this->assertEquals($service->tokenDetails(), $again->tokenDetails());
|
||||
$this->assertEquals($service->user(), $again->user());
|
||||
$this->assertFalse($again->isExpired());
|
||||
|
||||
$tenantId = $again->tenantId();
|
||||
|
||||
$newTok = $again->rescopeUsingTenantId($tenantId);
|
||||
|
||||
$this->assertNotEmpty($newTok);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group tenant
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user