summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2015-06-23 14:30:21 +0200
committerBjörn Schießle <bjoern@schiessle.org>2015-06-23 14:30:21 +0200
commitcce841c665a64aa161b023af59ac2136aaf424bf (patch)
tree246b877431bc46e561a89176eed978e174dd8b99 /tests
parent4b5324341c152ba14b817c13979a35e15502e39b (diff)
parent95602d4069a1eb9a45e1d08edeecc0d5b90e01ca (diff)
downloadnextcloud-server-cce841c665a64aa161b023af59ac2136aaf424bf.tar.gz
nextcloud-server-cce841c665a64aa161b023af59ac2136aaf424bf.zip
Merge pull request #17045 from owncloud/enc_improvements
encryption improvements
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/storage/wrapper/encryption.php63
1 files changed, 60 insertions, 3 deletions
diff --git a/tests/lib/files/storage/wrapper/encryption.php b/tests/lib/files/storage/wrapper/encryption.php
index 520091df42d..175713de497 100644
--- a/tests/lib/files/storage/wrapper/encryption.php
+++ b/tests/lib/files/storage/wrapper/encryption.php
@@ -68,6 +68,17 @@ class Encryption extends \Test\Files\Storage\Storage {
*/
private $mountManager;
+ /**
+ * @var \OC\Group\Manager | \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $groupManager;
+
+ /**
+ * @var \OCP\IConfig | \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $config;
+
+
/** @var integer dummy unencrypted size */
private $dummySize = -1;
@@ -84,14 +95,16 @@ class Encryption extends \Test\Files\Storage\Storage {
->method('getEncryptionModule')
->willReturn($mockModule);
- $config = $this->getMockBuilder('\OCP\IConfig')
+ $this->config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()
->getMock();
- $groupManager = $this->getMockBuilder('\OC\Group\Manager')
+ $this->groupManager = $this->getMockBuilder('\OC\Group\Manager')
->disableOriginalConstructor()
->getMock();
- $this->util = $this->getMock('\OC\Encryption\Util', ['getUidAndFilename', 'isFile', 'isExcluded'], [new View(), new \OC\User\Manager(), $groupManager, $config]);
+ $this->util = $this->getMock('\OC\Encryption\Util',
+ ['getUidAndFilename', 'isFile', 'isExcluded'],
+ [new View(), new \OC\User\Manager(), $this->groupManager, $this->config]);
$this->util->expects($this->any())
->method('getUidAndFilename')
->willReturnCallback(function ($path) {
@@ -365,4 +378,48 @@ class Encryption extends \Test\Files\Storage\Storage {
array(false, true),
);
}
+
+ /**
+ * @dataProvider dataTestGetHeader
+ * @param $path
+ * @param $strippedPath
+ */
+ public function testGetHeader($path, $strippedPath) {
+
+ $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage')
+ ->disableOriginalConstructor()->getMock();
+
+ $util = $this->getMockBuilder('\OC\Encryption\Util')
+ ->setConstructorArgs([new View(), new \OC\User\Manager(), $this->groupManager, $this->config])
+ ->getMock();
+
+ $instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption')
+ ->setConstructorArgs(
+ [
+ [
+ 'storage' => $sourceStorage,
+ 'root' => 'foo',
+ 'mountPoint' => '/',
+ 'mount' => $this->mount
+ ],
+ $this->encryptionManager, $util, $this->logger, $this->file, null, $this->keyStore, $this->update, $this->mountManager
+ ]
+ )
+ ->getMock();
+
+ $util->expects($this->once())->method('stripPartialFileExtension')
+ ->with($path)->willReturn($strippedPath);
+ $sourceStorage->expects($this->once())->method('file_exists')
+ ->with($strippedPath)->willReturn(false);
+
+ $this->invokePrivate($instance, 'getHeader', [$path]);
+ }
+
+ public function dataTestGetHeader() {
+ return array(
+ array('/foo/bar.txt', '/foo/bar.txt'),
+ array('/foo/bar.txt.part', '/foo/bar.txt'),
+ array('/foo/bar.txt.ocTransferId7437493.part', '/foo/bar.txt'),
+ );
+ }
}