diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2013-11-14 15:11:21 +0400 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2013-11-14 15:11:21 +0400 |
commit | 2df376367582edfbbfb98f8fe9837c5b57e5ad0c (patch) | |
tree | 6a6b120bc680e3c349e9d86d8092fa02a532cda2 /apps | |
parent | 222fa88eec086a8332566bf6e9bce2eb20e9dd55 (diff) |
test encryptAll() and decryptAll() to make sure that mtime and etag stay the same
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/files_encryption/tests/util.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php index 1b93bc36c8e..0f21ed96e45 100755 --- a/apps/files_encryption/tests/util.php +++ b/apps/files_encryption/tests/util.php @@ -281,6 +281,70 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { $this->assertFalse($this->util->isSharedPath($path)); } + function testEncryptAll() { + + $filename = "/encryptAll" . time() . ".txt"; + $util = new Encryption\Util($this->view, $this->userId); + + // disable encryption to upload a unencrypted file + \OC_App::disable('files_encryption'); + + $this->view->file_put_contents($this->userId . '/files/' . $filename, $this->dataShort); + + $fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename); + + $this->assertTrue(is_array($fileInfoUnencrypted)); + + // enable file encryption again + \OC_App::enable('files_encryption'); + + // encrypt all unencrypted files + $util->encryptAll('/' . $this->userId . '/' . 'files'); + + $fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename); + + $this->assertTrue(is_array($fileInfoEncrypted)); + + // check if mtime and etags unchanged + $this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']); + $this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']); + + $this->view->unlink($this->userId . '/files/' . $filename); + } + + + function testDecryptAll() { + + $filename = "/decryptAll" . time() . ".txt"; + $util = new Encryption\Util($this->view, $this->userId); + + $this->view->file_put_contents($this->userId . '/files/' . $filename, $this->dataShort); + + $fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename); + + print("\n File Info Encrypted\n"); + print_r($fileInfoEncrypted); + + $this->assertTrue(is_array($fileInfoEncrypted)); + + // encrypt all unencrypted files + $util->decryptAll('/' . $this->userId . '/' . 'files'); + + $fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename); + + print("\n File Info Unencrypted\n"); + print_r($fileInfoUnencrypted); + + $this->assertTrue(is_array($fileInfoUnencrypted)); + + // check if mtime and etags unchanged + $this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']); + $this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']); + + $this->view->unlink($this->userId . '/files/' . $filename); + + } + /** * @large */ |