diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-01-02 21:24:37 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-01-10 17:04:32 +0100 |
commit | fcda3a20f455795b898161ec4ada0aeb500b9218 (patch) | |
tree | d1819e6c04954377ede49bbf80ebc02335acf2a2 /tests/lib/Encryption | |
parent | 40239decb1b36f1daff53710e01d81e18c24f4fc (diff) | |
download | nextcloud-server-fcda3a20f455795b898161ec4ada0aeb500b9218.tar.gz nextcloud-server-fcda3a20f455795b898161ec4ada0aeb500b9218.zip |
create new encryption keys on password reset and backup the old one
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'tests/lib/Encryption')
-rw-r--r-- | tests/lib/Encryption/Keys/StorageTest.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php index b5b91f886a3..4e9719351f3 100644 --- a/tests/lib/Encryption/Keys/StorageTest.php +++ b/tests/lib/Encryption/Keys/StorageTest.php @@ -510,4 +510,47 @@ class StorageTest extends TestCase { ]; } + + /** + * @dataProvider dataTestBackupUserKeys + * @param bool $createBackupDir + */ + public function testBackupUserKeys($createBackupDir) { + + $storage = $this->getMockBuilder('OC\Encryption\Keys\Storage') + ->setConstructorArgs([$this->view, $this->util]) + ->setMethods(['getTimestamp']) + ->getMock(); + + $storage->expects($this->any())->method('getTimestamp')->willReturn('1234567'); + + $this->view->expects($this->once())->method('file_exists') + ->with('user1/files_encryption/backup')->willReturn(!$createBackupDir); + + if ($createBackupDir) { + $this->view->expects($this->at(1))->method('mkdir') + ->with('user1/files_encryption/backup'); + $this->view->expects($this->at(2))->method('mkdir') + ->with('user1/files_encryption/backup/test.encryptionModule.1234567'); + } else { + $this->view->expects($this->once())->method('mkdir') + ->with('user1/files_encryption/backup/test.encryptionModule.1234567'); + } + + $this->view->expects($this->once())->method('copy') + ->with( + 'user1/files_encryption/encryptionModule', + 'user1/files_encryption/backup/test.encryptionModule.1234567' + )->willReturn(true); + + $this->assertTrue($storage->backupUserKeys('encryptionModule', 'test', 'user1')); + + } + + public function dataTestBackupUserKeys() { + return [ + [true], [false] + ]; + } + } |