[Pkg-owncloud-commits] [owncloud] 06/134: add test for the stream wrapper to read encrypted files from the system folder /tmp
David Prévot
taffit at moszumanska.debian.org
Fri Apr 18 21:43:55 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 9cff832282fd8e852db21d37b52e4f628de9d885
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date: Wed Dec 18 17:07:35 2013 +0100
add test for the stream wrapper to read encrypted files from the system folder /tmp
---
apps/files_encryption/tests/stream.php | 39 ++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php
index 5097f40..d26cd75 100644
--- a/apps/files_encryption/tests/stream.php
+++ b/apps/files_encryption/tests/stream.php
@@ -180,4 +180,43 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
// tear down
$view->unlink($filename);
}
+
+ /**
+ * @medium
+ * @brief test if stream wrapper can read files outside from the data folder
+ */
+ function testStreamFromLocalFile() {
+
+ $filename = '/' . $this->userId . '/files/' . 'tmp-' . time().'.txt';
+
+ $tmpFilename = "/tmp/" . time() . ".txt";
+
+ // write an encrypted file
+ $cryptedFile = $this->view->file_put_contents($filename, $this->dataShort);
+
+ // Test that data was successfully written
+ $this->assertTrue(is_int($cryptedFile));
+
+ // create a copy outside of the data folder in /tmp
+ $proxyStatus = \OC_FileProxy::$enabled;
+ \OC_FileProxy::$enabled = false;
+ $encryptedContent = $this->view->file_get_contents($filename);
+ \OC_FileProxy::$enabled = $proxyStatus;
+
+ file_put_contents($tmpFilename, $encryptedContent);
+
+ \OCA\Encryption\Helper::addTmpFileToMapper($tmpFilename, $filename);
+
+ // try to read the file from /tmp
+ $handle = fopen("crypt://".$tmpFilename, "r");
+ $contentFromTmpFile = stream_get_contents($handle);
+
+ // check if it was successful
+ $this->assertEquals($this->dataShort, $contentFromTmpFile);
+
+ // clean up
+ unlink($tmpFilename);
+ $this->view->unlink($filename);
+
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list