fixed key-manager tests

This commit is contained in:
Florin Peter 2013-05-18 22:00:35 +02:00
parent 80f9c5bb6d
commit e0e89602a2
1 changed files with 15 additions and 8 deletions

View File

@ -88,20 +88,27 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
$privateKey = Encryption\Crypt::symmetricDecryptFileContent( $key, $this->pass);
// Will this length vary? Perhaps we should use a range instead
$this->assertGreaterThan( 27, strlen( $privateKey ) );
$res = openssl_pkey_get_private($privateKey);
$this->assertEquals( '-----BEGIN PRIVATE KEY-----', substr( $privateKey, 0, 27 ) );
$this->assertTrue(is_resource($res));
$sslInfo = openssl_pkey_get_details($res);
$this->assertArrayHasKey('key', $sslInfo);
}
function testGetPublicKey() {
$key = Encryption\Keymanager::getPublicKey( $this->view, $this->userId );
$publiceKey = Encryption\Keymanager::getPublicKey( $this->view, $this->userId );
$this->assertGreaterThan( 26, strlen( $key ) );
$res = openssl_pkey_get_public($publiceKey);
$this->assertEquals( '-----BEGIN PUBLIC KEY-----', substr( $key, 0, 26 ) );
$this->assertTrue(is_resource($res));
$sslInfo = openssl_pkey_get_details($res);
$this->assertArrayHasKey('key', $sslInfo);
}
function testSetFileKey() {