remove more is_array from encryption

remotes/origin/ldap_group_count
Robin Appelman 12 years ago
parent 642d8e370e
commit 299bb4d99d
  1. 4
      apps/files_encryption/lib/proxy.php
  2. 14
      apps/files_encryption/tests/share.php
  3. 8
      apps/files_encryption/tests/util.php

@ -307,7 +307,7 @@ class Proxy extends \OC_FileProxy {
public function postGetFileInfo($path, $data) {
// if path is a folder do nothing
if (\OCP\App::isEnabled('files_encryption') && is_array($data) && array_key_exists('size', $data)) {
if (\OCP\App::isEnabled('files_encryption') && $data !== false && array_key_exists('size', $data)) {
// Disable encryption proxy to prevent recursive calls
$proxyStatus = \OC_FileProxy::$enabled;
@ -378,7 +378,7 @@ class Proxy extends \OC_FileProxy {
$size = $fileInfo['unencrypted_size'];
} else {
// self healing if file was removed from file cache
if (!is_array($fileInfo)) {
if (!$fileInfo) {
$fileInfo = array();
}

@ -150,7 +150,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename);
// check if we have a valid file info
$this->assertTrue(is_array($fileInfo));
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// check if the unencrypted file size is stored
$this->assertGreaterThan(0, $fileInfo['unencrypted_size']);
@ -308,7 +308,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1);
// check if we have a valid file info
$this->assertTrue(is_array($fileInfo));
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// re-enable the file proxy
\OC_FileProxy::$enabled = $proxyStatus;
@ -384,7 +384,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
. $this->subfolder);
// check if we have a valid file info
$this->assertTrue(is_array($fileInfoSubFolder));
$this->assertTrue($fileInfoSubFolder instanceof \OC\Files\FileInfo);
// re-enable the file proxy
\OC_FileProxy::$enabled = $proxyStatus;
@ -418,7 +418,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
. $this->subsubfolder . '/' . $this->filename);
// check if we have fileInfos
$this->assertTrue(is_array($fileInfo));
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// share the file with user3
\OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, OCP\PERMISSION_ALL);
@ -513,7 +513,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename);
// check if we have a valid file info
$this->assertTrue(is_array($fileInfo));
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// check if the unencrypted file size is stored
$this->assertGreaterThan(0, $fileInfo['unencrypted_size']);
@ -589,7 +589,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename);
// check if we have a valid file info
$this->assertTrue(is_array($fileInfo));
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// check if the unencrypted file size is stored
$this->assertGreaterThan(0, $fileInfo['unencrypted_size']);
@ -876,7 +876,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase {
'/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename);
// check if we have a valid file info
$this->assertTrue(is_array($fileInfo));
$this->assertTrue($fileInfo instanceof \OC\Files\FileInfo);
// check if the unencrypted file size is stored
$this->assertGreaterThan(0, $fileInfo['unencrypted_size']);

@ -328,7 +328,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
$this->assertTrue(is_array($fileInfoUnencrypted));
$this->assertTrue($fileInfoUnencrypted instanceof \OC\Files\FileInfo);
// enable file encryption again
\OC_App::enable('files_encryption');
@ -338,7 +338,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
$this->assertTrue(is_array($fileInfoEncrypted));
$this->assertTrue($fileInfoEncrypted instanceof \OC\Files\FileInfo);
// check if mtime and etags unchanged
$this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
@ -357,14 +357,14 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
$this->assertTrue(is_array($fileInfoEncrypted));
$this->assertTrue($fileInfoEncrypted instanceof \OC\Files\FileInfo);
// encrypt all unencrypted files
$util->decryptAll('/' . $this->userId . '/' . 'files');
$fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename);
$this->assertTrue(is_array($fileInfoUnencrypted));
$this->assertTrue($fileInfoUnencrypted instanceof \OC\Files\FileInfo);
// check if mtime and etags unchanged
$this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);

Loading…
Cancel
Save