[Pkg-owncloud-commits] [owncloud] 41/457: add a unit test to make sure that we don't try to read a file during a write operation

David Prévot taffit at moszumanska.debian.org
Sun Jun 28 20:05:21 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 1c500487ba33b5218929d08a6c95fd1096f7f9ce
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Mon May 18 16:40:58 2015 +0200

    add a unit test to make sure that we don't try to read a file during a write operation
---
 tests/lib/files/stream/encryption.php | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tests/lib/files/stream/encryption.php b/tests/lib/files/stream/encryption.php
index 30c6d24..c2388c7 100644
--- a/tests/lib/files/stream/encryption.php
+++ b/tests/lib/files/stream/encryption.php
@@ -7,6 +7,9 @@ use OCA\Encryption_Dummy\DummyModule;
 
 class Encryption extends \Test\TestCase {
 
+	/** @var  \OCP\Encryption\IEncryptionModule | \PHPUnit_Framework_MockObject_MockObject  */
+	private $encryptionModule;
+
 	/**
 	 * @param string $fileName
 	 * @param string $mode
@@ -21,7 +24,7 @@ class Encryption extends \Test\TestCase {
 		$fullPath = $fileName;
 		$header = [];
 		$uid = '';
-		$encryptionModule = $this->buildMockModule();
+		$this->encryptionModule = $this->buildMockModule();
 		$storage = $this->getMockBuilder('\OC\Files\Storage\Storage')
 			->disableOriginalConstructor()->getMock();
 		$encStorage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption')
@@ -43,7 +46,7 @@ class Encryption extends \Test\TestCase {
 			->willReturn(['user1', $internalPath]);
 
 		return \OC\Files\Stream\Encryption::wrap($source, $internalPath,
-			$fullPath, $header, $uid, $encryptionModule, $storage, $encStorage,
+			$fullPath, $header, $uid, $this->encryptionModule, $storage, $encStorage,
 			$util, $file, $mode, $size, $unencryptedSize, 8192);
 	}
 
@@ -221,10 +224,15 @@ class Encryption extends \Test\TestCase {
 	 * @dataProvider dataFilesProvider
 	 */
 	public function testWriteReadBigFile($testFile) {
+
 		$expectedData = file_get_contents(\OC::$SERVERROOT . '/tests/data/' . $testFile);
 		// write it
 		$fileName = tempnam("/tmp", "FOO");
 		$stream = $this->getStream($fileName, 'w+', 0);
+		// while writing the file from the beginning to the end we should never try
+		// to read parts of the file. This should only happen for write operations
+		// in the middle of a file
+		$this->encryptionModule->expects($this->never())->method('decrypt');
 		fwrite($stream, $expectedData);
 		fclose($stream);
 

-- 
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