/** * should the file be encrypted or not * * @param string $path * @return boolean */ public function shouldEncrypt($path) { if ($this->util->shouldEncryptHomeStorage() === false) { $storage = $this->util->getStorage($path); if ($storage->instanceOfStorage('\\OCP\\Files\\IHomeStorage')) { return false; } } $parts = explode('/', $path); if (count($parts) < 4) { return false; } if ($parts[2] == 'files') { return true; } if ($parts[2] == 'files_versions') { return true; } if ($parts[2] == 'files_trashbin') { return true; } return false; }
/** * @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()); }