summaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests/hooks/UserHooksTest.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-04-28 12:57:30 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-04-28 13:00:09 +0200
commit7d05f387fb01c1b72ab6a21951f6d86d2bb99003 (patch)
tree8b0eb9839340dfb95d7233717f99a5518e23478b /apps/encryption/tests/hooks/UserHooksTest.php
parent557b4a2cb0ae0367e5facb1e4be136de07ab8cff (diff)
downloadnextcloud-server-7d05f387fb01c1b72ab6a21951f6d86d2bb99003.tar.gz
nextcloud-server-7d05f387fb01c1b72ab6a21951f6d86d2bb99003.zip
make sure that we create a header for the encrypted private key
Diffstat (limited to 'apps/encryption/tests/hooks/UserHooksTest.php')
-rw-r--r--apps/encryption/tests/hooks/UserHooksTest.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/apps/encryption/tests/hooks/UserHooksTest.php b/apps/encryption/tests/hooks/UserHooksTest.php
index bcfb33e86cb..b0cc9cc924a 100644
--- a/apps/encryption/tests/hooks/UserHooksTest.php
+++ b/apps/encryption/tests/hooks/UserHooksTest.php
@@ -11,6 +11,7 @@
namespace OCA\Encryption\Tests\Hooks;
+use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Hooks\UserHooks;
use Test\TestCase;
@@ -101,8 +102,18 @@ class UserHooksTest extends TestCase {
->method('symmetricEncryptFileContent')
->willReturn(true);
+ $this->cryptMock->expects($this->any())
+ ->method('generateHeader')
+ ->willReturn(Crypt::HEADER_START . ':Cipher:test:' . Crypt::HEADER_END);
+
$this->keyManagerMock->expects($this->exactly(4))
- ->method('setPrivateKey');
+ ->method('setPrivateKey')
+ ->willReturnCallback(function ($user, $key) {
+ $header = substr($key, 0, strlen(Crypt::HEADER_START));
+ $this->assertSame(
+ Crypt::HEADER_START,
+ $header, 'every encrypted file should start with a header');
+ });
$this->assertNull($this->instance->setPassphrase($this->params));
$this->params['recoveryPassword'] = 'password';