function testDeleteBackup() { $util = new \OCA\Files_Encryption\Util($this->view, self::TEST_ENCRYPTION_UTIL_USER1); $this->createDummyKeysForBackupTest(); $util->backupAllKeys('testDeleteBackup', false, false); $this->assertTrue($this->view->is_dir($this->encryptionDir . '/backup.testDeleteBackup')); $util->deleteBackup('testDeleteBackup'); $this->assertFalse($this->view->is_dir($this->encryptionDir . '/backup.testDeleteBackup')); }
/** * test if all keys get moved to the backup folder correctly */ function testBackupAllKeys() { self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER1); // create some dummy key files $encPath = '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '/files_encryption'; $this->view->mkdir($encPath . '/keys/foo'); $this->view->file_put_contents($encPath . '/keys/foo/fileKey', 'key'); $this->view->file_put_contents($encPath . '/keys/foo/user1.shareKey', 'share key'); $util = new \OCA\Files_Encryption\Util($this->view, self::TEST_ENCRYPTION_UTIL_USER1); $util->backupAllKeys('testBackupAllKeys'); $backupPath = $this->getBackupPath('testBackupAllKeys'); // check backupDir Content $this->assertTrue($this->view->is_dir($backupPath . '/keys')); $this->assertTrue($this->view->is_dir($backupPath . '/keys/foo')); $this->assertTrue($this->view->file_exists($backupPath . '/keys/foo/fileKey')); $this->assertTrue($this->view->file_exists($backupPath . '/keys/foo/user1.shareKey')); $this->assertTrue($this->view->file_exists($backupPath . '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '.privateKey')); $this->assertTrue($this->view->file_exists($backupPath . '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '.publicKey')); //cleanup $this->view->deleteAll($backupPath); $this->view->unlink($encPath . '/keys/foo/fileKey'); $this->view->unlink($encPath . '/keys/foo/user1.shareKey'); }