diff options
author | Florin Peter <github@florin-peter.de> | 2013-05-18 22:00:35 +0200 |
---|---|---|
committer | Florin Peter <github@florin-peter.de> | 2013-05-18 22:00:35 +0200 |
commit | e0e89602a24c151cd27095f355812a200acbbb83 (patch) | |
tree | 9d54aa938e54c67a62660481b6dfa109526e5800 /apps/files_encryption/tests/keymanager.php | |
parent | 80f9c5bb6d7d453a4a5b81abf346e8e20d10a5af (diff) | |
download | nextcloud-server-e0e89602a24c151cd27095f355812a200acbbb83.tar.gz nextcloud-server-e0e89602a24c151cd27095f355812a200acbbb83.zip |
fixed key-manager tests
Diffstat (limited to 'apps/files_encryption/tests/keymanager.php')
-rw-r--r-- | apps/files_encryption/tests/keymanager.php | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/apps/files_encryption/tests/keymanager.php b/apps/files_encryption/tests/keymanager.php index 415f3320945..151f6813e0f 100644 --- a/apps/files_encryption/tests/keymanager.php +++ b/apps/files_encryption/tests/keymanager.php @@ -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 ); - - $this->assertGreaterThan( 26, strlen( $key ) ); - - $this->assertEquals( '-----BEGIN PUBLIC KEY-----', substr( $key, 0, 26 ) ); + $publiceKey = Encryption\Keymanager::getPublicKey( $this->view, $this->userId ); + + $res = openssl_pkey_get_public($publiceKey); + + $this->assertTrue(is_resource($res)); + + $sslInfo = openssl_pkey_get_details($res); + + $this->assertArrayHasKey('key', $sslInfo); } function testSetFileKey() { |