summaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests/lib/UtilTest.php
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-10-13 17:54:06 +0200
committerBjörn Schießle <bjoern@schiessle.org>2015-10-27 14:24:20 +0100
commit5fad45b2309426c5b91af1d87beaa9950eadc5ba (patch)
tree0c45e969b3a5b457c47169ff540df82f46ae14b3 /apps/encryption/tests/lib/UtilTest.php
parentd7d5a3bab51d952e05965e84b784d7eff0efc9c9 (diff)
downloadnextcloud-server-5fad45b2309426c5b91af1d87beaa9950eadc5ba.tar.gz
nextcloud-server-5fad45b2309426c5b91af1d87beaa9950eadc5ba.zip
make encryption configurable for home storage
Diffstat (limited to 'apps/encryption/tests/lib/UtilTest.php')
-rw-r--r--apps/encryption/tests/lib/UtilTest.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/apps/encryption/tests/lib/UtilTest.php b/apps/encryption/tests/lib/UtilTest.php
index 723cc9fb910..d55b6b50b3e 100644
--- a/apps/encryption/tests/lib/UtilTest.php
+++ b/apps/encryption/tests/lib/UtilTest.php
@@ -39,6 +39,9 @@ class UtilTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject */
private $userManagerMock;
+ /** @var \PHPUnit_Framework_MockObject_MockObject */
+ private $mountMock;
+
/** @var Util */
private $instance;
@@ -65,6 +68,7 @@ class UtilTest extends TestCase {
protected function setUp() {
parent::setUp();
+ $this->mountMock = $this->getMock('\OCP\Files\Mount\IMountPoint');
$this->filesMock = $this->getMock('OC\Files\View');
$this->userManagerMock = $this->getMock('\OCP\IUserManager');
@@ -151,4 +155,52 @@ class UtilTest extends TestCase {
];
}
+ /**
+ * @dataProvider dataTestShouldEncryptHomeStorage
+ * @param $returnValue return value from getAppValue()
+ * @param $expected
+ */
+ public function testShouldEncryptHomeStorage($returnValue, $expected) {
+ $this->configMock->expects($this->once())->method('getAppValue')
+ ->with('encryption', 'encryptHomeStorage', '1')
+ ->willReturn($returnValue);
+
+ $this->assertSame($expected,
+ $this->instance->shouldEncryptHomeStorage());
+ }
+
+ public function dataTestShouldEncryptHomeStorage() {
+ return [
+ ['1', true],
+ ['0', false]
+ ];
+ }
+
+ /**
+ * @dataProvider dataTestSetEncryptHomeStorage
+ * @param $value
+ * @param $expected
+ */
+ public function testSetEncryptHomeStorage($value, $expected) {
+ $this->configMock->expects($this->once())->method('setAppValue')
+ ->with('encryption', 'encryptHomeStorage', $expected);
+ $this->instance->setEncryptHomeStorage($value);
+ }
+
+ public function dataTestSetEncryptHomeStorage() {
+ return [
+ [true, '1'],
+ [false, '0']
+ ];
+ }
+
+ public function testGetStorage() {
+ $path = '/foo/bar.txt';
+ $this->filesMock->expects($this->once())->method('getMount')->with($path)
+ ->willReturn($this->mountMock);
+ $this->mountMock->expects($this->once())->method('getStorage')->willReturn(true);
+
+ $this->assertTrue($this->instance->getStorage($path));
+ }
+
}