Merge pull request #3496 from owncloud/file_encryption_tests
improved tests for files_encryption
This commit is contained in:
commit
d878926256
9 changed files with 751 additions and 575 deletions
|
@ -16,14 +16,16 @@ require_once realpath(dirname(__FILE__) . '/../lib/stream.php');
|
|||
require_once realpath(dirname(__FILE__) . '/../lib/util.php');
|
||||
require_once realpath(dirname(__FILE__) . '/../lib/helper.php');
|
||||
require_once realpath(dirname(__FILE__) . '/../appinfo/app.php');
|
||||
require_once realpath(dirname(__FILE__) . '/util.php');
|
||||
|
||||
use OCA\Encryption;
|
||||
|
||||
/**
|
||||
* Class Test_Encryption_Crypt
|
||||
*/
|
||||
class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
const TEST_ENCRYPTION_CRYPT_USER1 = "test-crypt-user1";
|
||||
|
||||
public $userId;
|
||||
public $pass;
|
||||
|
@ -39,12 +41,31 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
public $genPrivateKey;
|
||||
public $genPublicKey;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
public static function setUpBeforeClass() {
|
||||
// reset backend
|
||||
\OC_User::clearBackends();
|
||||
\OC_User::useBackend('database');
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerUserHooks();
|
||||
|
||||
// clear and register hooks
|
||||
\OC_FileProxy::clearProxies();
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// create test user
|
||||
\Test_Encryption_Util::loginHelper(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1, true);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
// set user id
|
||||
\OC_User::setUserId(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1);
|
||||
$this->userId = \Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1;
|
||||
$this->pass = \Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1;
|
||||
|
||||
// set content for encrypting / decrypting in tests
|
||||
$this->dataLong = file_get_contents(realpath(dirname(__FILE__) . '/../lib/crypt.php'));
|
||||
$this->dataShort = 'hats';
|
||||
|
@ -60,53 +81,29 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->view = new \OC_FilesystemView('/');
|
||||
|
||||
\OC_User::setUserId('admin');
|
||||
$this->userId = 'admin';
|
||||
$this->pass = 'admin';
|
||||
|
||||
$userHome = \OC_User::getHome($this->userId);
|
||||
$this->dataDir = str_replace('/' . $this->userId, '', $userHome);
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerUserHooks();
|
||||
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// remember files_trashbin state
|
||||
$this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
|
||||
|
||||
// we don't want to tests with app files_trashbin enabled
|
||||
\OC_App::disable('files_trashbin');
|
||||
|
||||
\OC_Util::tearDownFS();
|
||||
\OC_User::setUserId('');
|
||||
\OC\Files\Filesystem::tearDown();
|
||||
\OC_Util::setupFS($this->userId);
|
||||
\OC_User::setUserId($this->userId);
|
||||
|
||||
$params['uid'] = $this->userId;
|
||||
$params['password'] = $this->pass;
|
||||
OCA\Encryption\Hooks::login($params);
|
||||
|
||||
}
|
||||
|
||||
function tearDown()
|
||||
{
|
||||
\OC_FileProxy::clearProxies();
|
||||
|
||||
function tearDown() {
|
||||
// reset app files_trashbin
|
||||
if ($this->stateFilesTrashbin) {
|
||||
OC_App::enable('files_trashbin');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
OC_App::disable('files_trashbin');
|
||||
}
|
||||
}
|
||||
|
||||
function testGenerateKey()
|
||||
{
|
||||
public static function tearDownAfterClass() {
|
||||
// cleanup test user
|
||||
\OC_User::deleteUser(\Test_Encryption_Crypt::TEST_ENCRYPTION_CRYPT_USER1);
|
||||
}
|
||||
|
||||
function testGenerateKey() {
|
||||
|
||||
# TODO: use more accurate (larger) string length for test confirmation
|
||||
|
||||
|
@ -119,8 +116,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @return String
|
||||
*/
|
||||
function testGenerateIv()
|
||||
{
|
||||
function testGenerateIv() {
|
||||
|
||||
$iv = Encryption\Crypt::generateIv();
|
||||
|
||||
|
@ -133,8 +129,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @depends testGenerateIv
|
||||
*/
|
||||
function testConcatIv($iv)
|
||||
{
|
||||
function testConcatIv($iv) {
|
||||
|
||||
$catFile = Encryption\Crypt::concatIv($this->dataLong, $iv);
|
||||
|
||||
|
@ -157,7 +152,8 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
return array(
|
||||
'iv' => $iv
|
||||
, 'catfile' => $catFile
|
||||
,
|
||||
'catfile' => $catFile
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -165,8 +161,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @depends testConcatIv
|
||||
*/
|
||||
function testSplitIv($testConcatIv)
|
||||
{
|
||||
function testSplitIv($testConcatIv) {
|
||||
|
||||
// Split catfile into components
|
||||
$splitCatfile = Encryption\Crypt::splitIv($testConcatIv['catfile']);
|
||||
|
@ -182,8 +177,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @return string padded
|
||||
*/
|
||||
function testAddPadding()
|
||||
{
|
||||
function testAddPadding() {
|
||||
|
||||
$padded = Encryption\Crypt::addPadding($this->dataLong);
|
||||
|
||||
|
@ -198,8 +192,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @depends testAddPadding
|
||||
*/
|
||||
function testRemovePadding($padded)
|
||||
{
|
||||
function testRemovePadding($padded) {
|
||||
|
||||
$noPadding = Encryption\Crypt::RemovePadding($padded);
|
||||
|
||||
|
@ -207,8 +200,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testEncrypt()
|
||||
{
|
||||
function testEncrypt() {
|
||||
|
||||
$random = openssl_random_pseudo_bytes(13);
|
||||
|
||||
|
@ -220,8 +212,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testDecrypt()
|
||||
{
|
||||
function testDecrypt() {
|
||||
|
||||
$random = openssl_random_pseudo_bytes(13);
|
||||
|
||||
|
@ -235,8 +226,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testSymmetricEncryptFileContent()
|
||||
{
|
||||
function testSymmetricEncryptFileContent() {
|
||||
|
||||
# TODO: search in keyfile for actual content as IV will ensure this test always passes
|
||||
|
||||
|
@ -251,8 +241,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testSymmetricStreamEncryptShortFileContent()
|
||||
{
|
||||
function testSymmetricStreamEncryptShortFileContent() {
|
||||
|
||||
$filename = 'tmp-' . time() . '.test';
|
||||
|
||||
|
@ -307,8 +296,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
* @note If this test fails with truncate content, check that enough array slices are being rejoined to form $e, as the crypt.php file may have gotten longer and broken the manual
|
||||
* reassembly of its data
|
||||
*/
|
||||
function testSymmetricStreamEncryptLongFileContent()
|
||||
{
|
||||
function testSymmetricStreamEncryptLongFileContent() {
|
||||
|
||||
// Generate a a random filename
|
||||
$filename = 'tmp-' . time() . '.test';
|
||||
|
@ -339,7 +327,14 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
//print_r($r);
|
||||
|
||||
// Join IVs and their respective data chunks
|
||||
$e = array($r[0] . $r[1], $r[2] . $r[3], $r[4] . $r[5], $r[6] . $r[7], $r[8] . $r[9], $r[10] . $r[11]); //.$r[11], $r[12].$r[13], $r[14] );
|
||||
$e = array(
|
||||
$r[0] . $r[1],
|
||||
$r[2] . $r[3],
|
||||
$r[4] . $r[5],
|
||||
$r[6] . $r[7],
|
||||
$r[8] . $r[9],
|
||||
$r[10] . $r[11]
|
||||
); //.$r[11], $r[12].$r[13], $r[14] );
|
||||
|
||||
//print_r($e);
|
||||
|
||||
|
@ -384,8 +379,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @brief Test that data that is read by the crypto stream wrapper
|
||||
*/
|
||||
function testSymmetricStreamDecryptShortFileContent()
|
||||
{
|
||||
function testSymmetricStreamDecryptShortFileContent() {
|
||||
|
||||
$filename = 'tmp-' . time();
|
||||
|
||||
|
@ -412,8 +406,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
$this->view->unlink($this->userId . '/files/' . $filename);
|
||||
}
|
||||
|
||||
function testSymmetricStreamDecryptLongFileContent()
|
||||
{
|
||||
function testSymmetricStreamDecryptLongFileContent() {
|
||||
|
||||
$filename = 'tmp-' . time();
|
||||
|
||||
|
@ -432,8 +425,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
$this->view->unlink($this->userId . '/files/' . $filename);
|
||||
}
|
||||
|
||||
function testSymmetricEncryptFileContentKeyfile()
|
||||
{
|
||||
function testSymmetricEncryptFileContentKeyfile() {
|
||||
|
||||
# TODO: search in keyfile for actual content as IV will ensure this test always passes
|
||||
|
||||
|
@ -448,8 +440,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testIsEncryptedContent()
|
||||
{
|
||||
function testIsEncryptedContent() {
|
||||
|
||||
$this->assertFalse(Encryption\Crypt::isCatfileContent($this->dataUrl));
|
||||
|
||||
|
@ -461,8 +452,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testMultiKeyEncrypt()
|
||||
{
|
||||
function testMultiKeyEncrypt() {
|
||||
|
||||
# TODO: search in keyfile for actual content as IV will ensure this test always passes
|
||||
|
||||
|
@ -486,8 +476,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testKeyEncrypt()
|
||||
{
|
||||
function testKeyEncrypt() {
|
||||
|
||||
// Generate keypair
|
||||
$pair1 = Encryption\Crypt::createKeypair();
|
||||
|
@ -507,8 +496,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @brief test encryption using legacy blowfish method
|
||||
*/
|
||||
function testLegacyEncryptShort()
|
||||
{
|
||||
function testLegacyEncryptShort() {
|
||||
|
||||
$crypted = Encryption\Crypt::legacyEncrypt($this->dataShort, $this->pass);
|
||||
|
||||
|
@ -525,8 +513,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
* @brief test decryption using legacy blowfish method
|
||||
* @depends testLegacyEncryptShort
|
||||
*/
|
||||
function testLegacyDecryptShort($crypted)
|
||||
{
|
||||
function testLegacyDecryptShort($crypted) {
|
||||
|
||||
$decrypted = Encryption\Crypt::legacyDecrypt($crypted, $this->pass);
|
||||
|
||||
|
@ -537,8 +524,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @brief test encryption using legacy blowfish method
|
||||
*/
|
||||
function testLegacyEncryptLong()
|
||||
{
|
||||
function testLegacyEncryptLong() {
|
||||
|
||||
$crypted = Encryption\Crypt::legacyEncrypt($this->dataLong, $this->pass);
|
||||
|
||||
|
@ -555,8 +541,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
* @brief test decryption using legacy blowfish method
|
||||
* @depends testLegacyEncryptLong
|
||||
*/
|
||||
function testLegacyDecryptLong($crypted)
|
||||
{
|
||||
function testLegacyDecryptLong($crypted) {
|
||||
|
||||
$decrypted = Encryption\Crypt::legacyDecrypt($crypted, $this->pass);
|
||||
|
||||
|
@ -569,8 +554,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
* @brief test generation of legacy encryption key
|
||||
* @depends testLegacyDecryptShort
|
||||
*/
|
||||
function testLegacyCreateKey()
|
||||
{
|
||||
function testLegacyCreateKey() {
|
||||
|
||||
// Create encrypted key
|
||||
$encKey = Encryption\Crypt::legacyCreateKey($this->pass);
|
||||
|
@ -589,8 +573,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
* @brief test decryption using legacy blowfish method
|
||||
* @depends testLegacyEncryptLong
|
||||
*/
|
||||
function testLegacyKeyRecryptKeyfileEncrypt($crypted)
|
||||
{
|
||||
function testLegacyKeyRecryptKeyfileEncrypt($crypted) {
|
||||
|
||||
$recrypted = Encryption\Crypt::LegacyKeyRecryptKeyfile($crypted, $this->pass, array($this->genPublicKey), $this->pass, '');
|
||||
|
||||
|
@ -603,8 +586,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testRenameFile()
|
||||
{
|
||||
function testRenameFile() {
|
||||
|
||||
$filename = 'tmp-' . time();
|
||||
|
||||
|
@ -632,8 +614,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
$view->unlink($newFilename);
|
||||
}
|
||||
|
||||
function testMoveFileIntoFolder()
|
||||
{
|
||||
function testMoveFileIntoFolder() {
|
||||
|
||||
$filename = 'tmp-' . time();
|
||||
|
||||
|
@ -663,8 +644,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
$view->unlink($newFolder);
|
||||
}
|
||||
|
||||
function testMoveFolder()
|
||||
{
|
||||
function testMoveFolder() {
|
||||
|
||||
$view = new \OC\Files\View('/' . $this->userId . '/files');
|
||||
|
||||
|
@ -696,11 +676,11 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
|
||||
// tear down
|
||||
$view->unlink($newFolder);
|
||||
$view->unlink('/newfolder');
|
||||
}
|
||||
|
||||
function testChangePassphrase()
|
||||
{
|
||||
$filename = 'tmp-' . time();
|
||||
function testChangePassphrase() {
|
||||
$filename = 'tmp-' . time();
|
||||
|
||||
// Save long data as encrypted file using stream wrapper
|
||||
$cryptedFile = file_put_contents('crypt://' . $filename, $this->dataLong);
|
||||
|
@ -733,8 +713,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
$view->unlink($filename);
|
||||
}
|
||||
|
||||
function testViewFilePutAndGetContents()
|
||||
{
|
||||
function testViewFilePutAndGetContents() {
|
||||
|
||||
$filename = '/tmp-' . time();
|
||||
$view = new \OC\Files\View('/' . $this->userId . '/files');
|
||||
|
@ -765,8 +744,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
$view->unlink($filename);
|
||||
}
|
||||
|
||||
function testTouchExistingFile()
|
||||
{
|
||||
function testTouchExistingFile() {
|
||||
$filename = '/tmp-' . time();
|
||||
$view = new \OC\Files\View('/' . $this->userId . '/files');
|
||||
|
||||
|
@ -787,8 +765,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
$view->unlink($filename);
|
||||
}
|
||||
|
||||
function testTouchFile()
|
||||
{
|
||||
function testTouchFile() {
|
||||
$filename = '/tmp-' . time();
|
||||
$view = new \OC\Files\View('/' . $this->userId . '/files');
|
||||
|
||||
|
@ -809,8 +786,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
|||
$view->unlink($filename);
|
||||
}
|
||||
|
||||
function testFopenFile()
|
||||
{
|
||||
function testFopenFile() {
|
||||
$filename = '/tmp-' . time();
|
||||
$view = new \OC\Files\View('/' . $this->userId . '/files');
|
||||
|
||||
|
|
Binary file not shown.
|
@ -20,8 +20,7 @@ use OCA\Encryption;
|
|||
/**
|
||||
* Class Test_Encryption_Keymanager
|
||||
*/
|
||||
class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
public $userId;
|
||||
public $pass;
|
||||
|
@ -33,14 +32,35 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase
|
|||
public $randomKey;
|
||||
public $dataShort;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
public static function setUpBeforeClass() {
|
||||
// reset backend
|
||||
\OC_User::clearBackends();
|
||||
\OC_User::useBackend('database');
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
// clear and register hooks
|
||||
\OC_FileProxy::clearProxies();
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// disable file proxy by default
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
// setup filesystem
|
||||
\OC_Util::tearDownFS();
|
||||
\OC_User::setUserId('');
|
||||
\OC\Files\Filesystem::tearDown();
|
||||
\OC_Util::setupFS('admin');
|
||||
\OC_User::setUserId('admin');
|
||||
|
||||
// login admin
|
||||
$params['uid'] = 'admin';
|
||||
$params['password'] = 'admin';
|
||||
OCA\Encryption\Hooks::login($params);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
// set content for encrypting / decrypting in tests
|
||||
$this->dataLong = file_get_contents(realpath(dirname(__FILE__) . '/../lib/crypt.php'));
|
||||
$this->dataShort = 'hats';
|
||||
|
@ -62,44 +82,28 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase
|
|||
$userHome = \OC_User::getHome($this->userId);
|
||||
$this->dataDir = str_replace('/' . $this->userId, '', $userHome);
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// remember files_trashbin state
|
||||
$this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
|
||||
|
||||
// we don't want to tests with app files_trashbin enabled
|
||||
\OC_App::disable('files_trashbin');
|
||||
|
||||
\OC_Util::tearDownFS();
|
||||
\OC_User::setUserId('');
|
||||
\OC\Files\Filesystem::tearDown();
|
||||
\OC_Util::setupFS($this->userId);
|
||||
\OC_User::setUserId($this->userId);
|
||||
|
||||
$params['uid'] = $this->userId;
|
||||
$params['password'] = $this->pass;
|
||||
OCA\Encryption\Hooks::login($params);
|
||||
}
|
||||
|
||||
function tearDown()
|
||||
{
|
||||
|
||||
\OC_FileProxy::$enabled = true;
|
||||
\OC_FileProxy::clearProxies();
|
||||
|
||||
function tearDown() {
|
||||
// reset app files_trashbin
|
||||
if ($this->stateFilesTrashbin) {
|
||||
OC_App::enable('files_trashbin');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
OC_App::disable('files_trashbin');
|
||||
}
|
||||
}
|
||||
|
||||
function testGetPrivateKey()
|
||||
{
|
||||
public static function tearDownAfterClass() {
|
||||
\OC_FileProxy::$enabled = true;
|
||||
}
|
||||
|
||||
function testGetPrivateKey() {
|
||||
|
||||
$key = Encryption\Keymanager::getPrivateKey($this->view, $this->userId);
|
||||
|
||||
|
@ -115,8 +119,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testGetPublicKey()
|
||||
{
|
||||
function testGetPublicKey() {
|
||||
|
||||
$publiceKey = Encryption\Keymanager::getPublicKey($this->view, $this->userId);
|
||||
|
||||
|
@ -129,8 +132,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase
|
|||
$this->assertArrayHasKey('key', $sslInfo);
|
||||
}
|
||||
|
||||
function testSetFileKey()
|
||||
{
|
||||
function testSetFileKey() {
|
||||
|
||||
# NOTE: This cannot be tested until we are able to break out
|
||||
# of the FileSystemView data directory root
|
||||
|
@ -163,8 +165,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testGetUserKeys()
|
||||
{
|
||||
function testGetUserKeys() {
|
||||
|
||||
$keys = Encryption\Keymanager::getUserKeys($this->view, $this->userId);
|
||||
|
||||
|
@ -187,8 +188,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase
|
|||
$this->assertArrayHasKey('key', $sslInfoPrivate);
|
||||
}
|
||||
|
||||
function testFixPartialFilePath()
|
||||
{
|
||||
function testFixPartialFilePath() {
|
||||
|
||||
$partFilename = 'testfile.txt.part';
|
||||
$filename = 'testfile.txt';
|
||||
|
@ -202,8 +202,7 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals('testfile.txt', Encryption\Keymanager::fixPartialFilePath($filename));
|
||||
}
|
||||
|
||||
function testRecursiveDelShareKeys()
|
||||
{
|
||||
function testRecursiveDelShareKeys() {
|
||||
|
||||
// generate filename
|
||||
$filename = '/tmp-' . time() . '.txt';
|
||||
|
@ -230,7 +229,8 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase
|
|||
Encryption\Keymanager::delShareKey($this->view, array('admin'), '/folder1/');
|
||||
|
||||
// check if share key not exists
|
||||
$this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/folder1/subfolder/subsubfolder/' . $filename . '.admin.shareKey'));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/admin/files_encryption/share-keys/folder1/subfolder/subsubfolder/' . $filename . '.admin.shareKey'));
|
||||
|
||||
// enable encryption proxy
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
|
|
|
@ -1 +1 @@
|
|||
«ß•’tÕ.µ¤—dS@t9øQJ
|
||||
ð˜¯5–¡‹Ç¡i›òë³Zg§ESlÁF=<3D>Àªð
|
File diff suppressed because it is too large
Load diff
|
@ -27,6 +27,7 @@ require_once realpath(dirname(__FILE__) . '/../lib/proxy.php');
|
|||
require_once realpath(dirname(__FILE__) . '/../lib/stream.php');
|
||||
require_once realpath(dirname(__FILE__) . '/../lib/util.php');
|
||||
require_once realpath(dirname(__FILE__) . '/../appinfo/app.php');
|
||||
require_once realpath(dirname(__FILE__) . '/util.php');
|
||||
|
||||
use OCA\Encryption;
|
||||
|
||||
|
@ -34,8 +35,9 @@ use OCA\Encryption;
|
|||
* Class Test_Encryption_Stream
|
||||
* @brief this class provide basic stream tests
|
||||
*/
|
||||
class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
const TEST_ENCRYPTION_STREAM_USER1 = "test-stream-user1";
|
||||
|
||||
public $userId;
|
||||
public $pass;
|
||||
|
@ -46,15 +48,27 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase
|
|||
public $dataShort;
|
||||
public $stateFilesTrashbin;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
public static function setUpBeforeClass() {
|
||||
// reset backend
|
||||
\OC_User::clearBackends();
|
||||
\OC_User::useBackend('database');
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
// clear and register hooks
|
||||
\OC_FileProxy::clearProxies();
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// create test user
|
||||
\Test_Encryption_Util::loginHelper(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1, true);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
// set user id
|
||||
\OC_User::setUserId('admin');
|
||||
$this->userId = 'admin';
|
||||
$this->pass = 'admin';
|
||||
\OC_User::setUserId(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1);
|
||||
$this->userId = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1;
|
||||
$this->pass = \Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1;
|
||||
|
||||
// init filesystem view
|
||||
$this->view = new \OC_FilesystemView('/');
|
||||
|
@ -62,42 +76,26 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase
|
|||
// init short data
|
||||
$this->dataShort = 'hats';
|
||||
|
||||
// init filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
// register encryption file proxy
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// remember files_trashbin state
|
||||
$this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
|
||||
|
||||
// we don't want to tests with app files_trashbin enabled
|
||||
\OC_App::disable('files_trashbin');
|
||||
|
||||
// init filesystem for user
|
||||
\OC_Util::tearDownFS();
|
||||
\OC_User::setUserId('');
|
||||
\OC\Files\Filesystem::tearDown();
|
||||
\OC_Util::setupFS($this->userId);
|
||||
\OC_User::setUserId($this->userId);
|
||||
|
||||
// login user
|
||||
$params['uid'] = $this->userId;
|
||||
$params['password'] = $this->pass;
|
||||
OCA\Encryption\Hooks::login($params);
|
||||
}
|
||||
|
||||
function tearDown()
|
||||
{
|
||||
function tearDown() {
|
||||
// reset app files_trashbin
|
||||
if ($this->stateFilesTrashbin) {
|
||||
OC_App::enable('files_trashbin');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
OC_App::disable('files_trashbin');
|
||||
}
|
||||
}
|
||||
|
||||
// clear all proxies
|
||||
\OC_FileProxy::clearProxies();
|
||||
public static function tearDownAfterClass() {
|
||||
// cleanup test user
|
||||
\OC_User::deleteUser(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1);
|
||||
}
|
||||
|
||||
function testStreamOptions() {
|
||||
|
@ -113,7 +111,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase
|
|||
$handle = $view->fopen($filename, 'r');
|
||||
|
||||
// check if stream is at position zero
|
||||
$this->assertEquals(0,ftell($handle));
|
||||
$this->assertEquals(0, ftell($handle));
|
||||
|
||||
// set stream options
|
||||
$this->assertTrue(flock($handle, LOCK_SH));
|
||||
|
@ -136,7 +134,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase
|
|||
$handle = $view->fopen($filename, 'r');
|
||||
|
||||
// set stream options
|
||||
$this->assertTrue(stream_set_blocking($handle,1));
|
||||
$this->assertTrue(stream_set_blocking($handle, 1));
|
||||
|
||||
// tear down
|
||||
$view->unlink($filename);
|
||||
|
@ -155,7 +153,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase
|
|||
$handle = $view->fopen($filename, 'r');
|
||||
|
||||
// set stream options
|
||||
$this->assertFalse(stream_set_timeout($handle,1));
|
||||
$this->assertFalse(stream_set_timeout($handle, 1));
|
||||
|
||||
// tear down
|
||||
$view->unlink($filename);
|
||||
|
@ -174,7 +172,7 @@ class Test_Encryption_Stream extends \PHPUnit_Framework_TestCase
|
|||
$handle = $view->fopen($filename, 'r');
|
||||
|
||||
// set stream options
|
||||
$this->assertEquals(0, stream_set_write_buffer($handle,1024));
|
||||
$this->assertEquals(0, stream_set_write_buffer($handle, 1024));
|
||||
|
||||
// tear down
|
||||
$view->unlink($filename);
|
||||
|
|
|
@ -28,6 +28,7 @@ require_once realpath(dirname(__FILE__) . '/../lib/stream.php');
|
|||
require_once realpath(dirname(__FILE__) . '/../lib/util.php');
|
||||
require_once realpath(dirname(__FILE__) . '/../appinfo/app.php');
|
||||
require_once realpath(dirname(__FILE__) . '/../../files_trashbin/appinfo/app.php');
|
||||
require_once realpath(dirname(__FILE__) . '/util.php');
|
||||
|
||||
use OCA\Encryption;
|
||||
|
||||
|
@ -35,8 +36,9 @@ use OCA\Encryption;
|
|||
* Class Test_Encryption_Trashbin
|
||||
* @brief this class provide basic trashbin app tests
|
||||
*/
|
||||
class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
const TEST_ENCRYPTION_TRASHBIN_USER1 = "test-trashbin-user1";
|
||||
|
||||
public $userId;
|
||||
public $pass;
|
||||
|
@ -50,15 +52,33 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase
|
|||
public $subfolder;
|
||||
public $subsubfolder;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
public static function setUpBeforeClass() {
|
||||
// reset backend
|
||||
\OC_User::clearBackends();
|
||||
\OC_User::useBackend('database');
|
||||
|
||||
\OC_Hook::clear('OC_Filesystem');
|
||||
\OC_Hook::clear('OC_User');
|
||||
|
||||
// trashbin hooks
|
||||
\OCA\Files_Trashbin\Trashbin::registerHooks();
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
// clear and register hooks
|
||||
\OC_FileProxy::clearProxies();
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// create test user
|
||||
\Test_Encryption_Util::loginHelper(\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1, true);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
// set user id
|
||||
\OC_User::setUserId('admin');
|
||||
$this->userId = 'admin';
|
||||
$this->pass = 'admin';
|
||||
\OC_User::setUserId(\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1);
|
||||
$this->userId = \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1;
|
||||
$this->pass = \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1;
|
||||
|
||||
// init filesystem view
|
||||
$this->view = new \OC_FilesystemView('/');
|
||||
|
@ -70,48 +90,26 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase
|
|||
$this->subfolder = '/subfolder1';
|
||||
$this->subsubfolder = '/subsubfolder1';
|
||||
|
||||
\OC_Hook::clear('OC_Filesystem');
|
||||
\OC_Hook::clear('OC_User');
|
||||
|
||||
// init filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
// register encryption file proxy
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// trashbin hooks
|
||||
\OCA\Files_Trashbin\Trashbin::registerHooks();
|
||||
|
||||
// remember files_trashbin state
|
||||
$this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
|
||||
|
||||
// we don't want to tests with app files_trashbin enabled
|
||||
// we want to tests with app files_trashbin enabled
|
||||
\OC_App::enable('files_trashbin');
|
||||
|
||||
// init filesystem for user
|
||||
\OC_Util::tearDownFS();
|
||||
\OC_User::setUserId('');
|
||||
\OC\Files\Filesystem::tearDown();
|
||||
\OC_Util::setupFS($this->userId);
|
||||
\OC_User::setUserId($this->userId);
|
||||
|
||||
// login user
|
||||
$params['uid'] = $this->userId;
|
||||
$params['password'] = $this->pass;
|
||||
OCA\Encryption\Hooks::login($params);
|
||||
}
|
||||
|
||||
function tearDown()
|
||||
{
|
||||
function tearDown() {
|
||||
// reset app files_trashbin
|
||||
if ($this->stateFilesTrashbin) {
|
||||
OC_App::enable('files_trashbin');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
OC_App::disable('files_trashbin');
|
||||
}
|
||||
}
|
||||
|
||||
// clear all proxies
|
||||
\OC_FileProxy::clearProxies();
|
||||
public static function tearDownAfterClass() {
|
||||
// cleanup test user
|
||||
\OC_User::deleteUser(\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,30 +127,40 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase
|
|||
$this->assertTrue(is_int($cryptedFile));
|
||||
|
||||
// check if key for admin exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files_encryption/keyfiles/' . $filename . '.key'));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename
|
||||
. '.key'));
|
||||
|
||||
// check if share key for admin exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $filename . '.admin.shareKey'));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
|
||||
. $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
|
||||
|
||||
// delete file
|
||||
\OC\FIles\Filesystem::unlink($filename);
|
||||
|
||||
// check if file not exists
|
||||
$this->assertFalse($this->view->file_exists('/admin/files/' . $filename));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename));
|
||||
|
||||
// check if key for admin not exists
|
||||
$this->assertFalse($this->view->file_exists('/admin/files_encryption/keyfiles/' . $filename . '.key'));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename
|
||||
. '.key'));
|
||||
|
||||
// check if share key for admin not exists
|
||||
$this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $filename . '.admin.shareKey'));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
|
||||
. $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
|
||||
|
||||
// get files
|
||||
$trashFiles = $this->view->getDirectoryContent('/admin/files_trashbin/files/');
|
||||
$trashFiles = $this->view->getDirectoryContent(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/');
|
||||
|
||||
$trashFileSuffix = null;
|
||||
// find created file with timestamp
|
||||
foreach($trashFiles as $file) {
|
||||
if(strncmp($file['path'], $filename, strlen($filename))) {
|
||||
foreach ($trashFiles as $file) {
|
||||
if (strncmp($file['path'], $filename, strlen($filename))) {
|
||||
$path_parts = pathinfo($file['name']);
|
||||
$trashFileSuffix = $path_parts['extension'];
|
||||
}
|
||||
|
@ -162,10 +170,14 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase
|
|||
$this->assertNotNull($trashFileSuffix);
|
||||
|
||||
// check if key for admin not exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files_trashbin/keyfiles/' . $filename . '.key.' . $trashFileSuffix));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename
|
||||
. '.key.' . $trashFileSuffix));
|
||||
|
||||
// check if share key for admin not exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files_trashbin/share-keys/' . $filename . '.admin.shareKey.' . $trashFileSuffix));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/share-keys/' . $filename
|
||||
. '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey.' . $trashFileSuffix));
|
||||
|
||||
// return filename for next test
|
||||
return $filename . '.' . $trashFileSuffix;
|
||||
|
@ -182,19 +194,24 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase
|
|||
$path_parts = pathinfo($filename);
|
||||
$trashFileSuffix = $path_parts['extension'];
|
||||
$timestamp = str_replace('d', '', $trashFileSuffix);
|
||||
$fileNameWithoutSuffix = str_replace('.'.$trashFileSuffix, '', $filename);
|
||||
$fileNameWithoutSuffix = str_replace('.' . $trashFileSuffix, '', $filename);
|
||||
|
||||
// restore file
|
||||
$this->assertTrue(\OCA\Files_Trashbin\Trashbin::restore($filename, $fileNameWithoutSuffix, $timestamp));
|
||||
|
||||
// check if file exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files/' . $fileNameWithoutSuffix));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $fileNameWithoutSuffix));
|
||||
|
||||
// check if key for admin exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files_encryption/keyfiles/' . $fileNameWithoutSuffix . '.key'));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/'
|
||||
. $fileNameWithoutSuffix . '.key'));
|
||||
|
||||
// check if share key for admin exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $fileNameWithoutSuffix . '.admin.shareKey'));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
|
||||
. $fileNameWithoutSuffix . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,44 +229,51 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase
|
|||
$this->assertTrue(is_int($cryptedFile));
|
||||
|
||||
// check if key for admin exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files_encryption/keyfiles/' . $filename . '.key'));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename
|
||||
. '.key'));
|
||||
|
||||
// check if share key for admin exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files_encryption/share-keys/' . $filename . '.admin.shareKey'));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
|
||||
. $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
|
||||
|
||||
// delete file
|
||||
\OC\FIles\Filesystem::unlink($filename);
|
||||
|
||||
// check if file not exists
|
||||
$this->assertFalse($this->view->file_exists('/admin/files/' . $filename));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename));
|
||||
|
||||
// check if key for admin not exists
|
||||
$this->assertFalse($this->view->file_exists('/admin/files_encryption/keyfiles/' . $filename . '.key'));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename
|
||||
. '.key'));
|
||||
|
||||
// check if share key for admin not exists
|
||||
$this->assertFalse($this->view->file_exists('/admin/files_encryption/share-keys/' . $filename . '.admin.shareKey'));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
|
||||
. $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
|
||||
|
||||
// get files
|
||||
$trashFiles = $this->view->getDirectoryContent('/admin/files_trashbin/files/');
|
||||
|
||||
$trashFileSuffix = null;
|
||||
// find created file with timestamp
|
||||
foreach($trashFiles as $file) {
|
||||
if(strncmp($file['name'], $filename, strlen($filename)) == 0) {
|
||||
$path_parts = pathinfo($file['name']);
|
||||
$trashFileSuffix = $path_parts['extension'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$query = \OC_DB::prepare('SELECT `timestamp`,`type` FROM `*PREFIX*files_trash`'
|
||||
. ' WHERE `id`=?');
|
||||
$result = $query->execute(array($filename))->fetchRow();
|
||||
|
||||
// check if we found the file we created
|
||||
$this->assertNotNull($trashFileSuffix);
|
||||
$this->assertTrue(is_array($result));
|
||||
|
||||
// build suffix
|
||||
$trashFileSuffix = 'd' . $result['timestamp'];
|
||||
|
||||
// check if key for admin exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files_trashbin/keyfiles/' . $filename . '.key.' . $trashFileSuffix));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename
|
||||
. '.key.' . $trashFileSuffix));
|
||||
|
||||
// check if share key for admin exists
|
||||
$this->assertTrue($this->view->file_exists('/admin/files_trashbin/share-keys/' . $filename . '.admin.shareKey.' . $trashFileSuffix));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/share-keys/' . $filename
|
||||
. '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey.' . $trashFileSuffix));
|
||||
|
||||
// get timestamp from file
|
||||
$timestamp = str_replace('d', '', $trashFileSuffix);
|
||||
|
@ -258,13 +282,19 @@ class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase
|
|||
$this->assertGreaterThan(0, \OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp));
|
||||
|
||||
// check if key for admin not exists
|
||||
$this->assertFalse($this->view->file_exists('/admin/files_trashbin/files/' . $filename . '.' . $trashFileSuffix));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/' . $filename . '.'
|
||||
. $trashFileSuffix));
|
||||
|
||||
// check if key for admin not exists
|
||||
$this->assertFalse($this->view->file_exists('/admin/files_trashbin/keyfiles/' . $filename . '.key.' . $trashFileSuffix));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename
|
||||
. '.key.' . $trashFileSuffix));
|
||||
|
||||
// check if share key for admin not exists
|
||||
$this->assertFalse($this->view->file_exists('/admin/files_trashbin/share-keys/' . $filename . '.admin.shareKey.' . $trashFileSuffix));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/share-keys/' . $filename
|
||||
. '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey.' . $trashFileSuffix));
|
||||
}
|
||||
|
||||
}
|
|
@ -19,8 +19,10 @@ use OCA\Encryption;
|
|||
/**
|
||||
* Class Test_Encryption_Util
|
||||
*/
|
||||
class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
const TEST_ENCRYPTION_UTIL_USER1 = "test-util-user1";
|
||||
const TEST_ENCRYPTION_UTIL_LEGACY_USER = "test-legacy-user";
|
||||
|
||||
public $userId;
|
||||
public $encryptionDir;
|
||||
|
@ -40,16 +42,31 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
|||
public $dataShort;
|
||||
public $legacyEncryptedData;
|
||||
public $legacyEncryptedDataKey;
|
||||
public $lagacyKey;
|
||||
public $legacyKey;
|
||||
public $stateFilesTrashbin;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
public static function setUpBeforeClass() {
|
||||
// reset backend
|
||||
\OC_User::clearBackends();
|
||||
\OC_User::useBackend('database');
|
||||
|
||||
\OC_User::setUserId('admin');
|
||||
$this->userId = 'admin';
|
||||
$this->pass = 'admin';
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
// clear and register hooks
|
||||
\OC_FileProxy::clearProxies();
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// create test user
|
||||
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, true);
|
||||
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER, true);
|
||||
}
|
||||
|
||||
|
||||
function setUp() {
|
||||
\OC_User::setUserId(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
|
||||
$this->userId = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1;
|
||||
$this->pass = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1;
|
||||
|
||||
// set content for encrypting / decrypting in tests
|
||||
$this->dataUrl = realpath(dirname(__FILE__) . '/../lib/crypt.php');
|
||||
|
@ -58,7 +75,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
|||
$this->legacyData = realpath(dirname(__FILE__) . '/legacy-text.txt');
|
||||
$this->legacyEncryptedData = realpath(dirname(__FILE__) . '/legacy-encrypted-text.txt');
|
||||
$this->legacyEncryptedDataKey = realpath(dirname(__FILE__) . '/encryption.key');
|
||||
$this->lagacyKey = '62829813025828180801';
|
||||
$this->legacyKey = '30943623843030686906';
|
||||
|
||||
$keypair = Encryption\Crypt::createKeypair();
|
||||
|
||||
|
@ -68,43 +85,42 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
|||
$this->publicKeyDir = '/' . 'public-keys';
|
||||
$this->encryptionDir = '/' . $this->userId . '/' . 'files_encryption';
|
||||
$this->keyfilesPath = $this->encryptionDir . '/' . 'keyfiles';
|
||||
$this->publicKeyPath = $this->publicKeyDir . '/' . $this->userId . '.public.key'; // e.g. data/public-keys/admin.public.key
|
||||
$this->privateKeyPath = $this->encryptionDir . '/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key
|
||||
$this->publicKeyPath =
|
||||
$this->publicKeyDir . '/' . $this->userId . '.public.key'; // e.g. data/public-keys/admin.public.key
|
||||
$this->privateKeyPath =
|
||||
$this->encryptionDir . '/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key
|
||||
|
||||
$this->view = new \OC_FilesystemView('/');
|
||||
|
||||
$userHome = \OC_User::getHome($this->userId);
|
||||
$this->dataDir = str_replace('/' . $this->userId, '', $userHome);
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
\OC_Util::tearDownFS();
|
||||
\OC_User::setUserId('');
|
||||
\OC\Files\Filesystem::tearDown();
|
||||
\OC_Util::setupFS($this->userId);
|
||||
\OC_User::setUserId($this->userId);
|
||||
|
||||
$params['uid'] = $this->userId;
|
||||
$params['password'] = $this->pass;
|
||||
OCA\Encryption\Hooks::login($params);
|
||||
|
||||
$this->util = new Encryption\Util($this->view, $this->userId);
|
||||
|
||||
// remember files_trashbin state
|
||||
$this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
|
||||
|
||||
// we don't want to tests with app files_trashbin enabled
|
||||
\OC_App::disable('files_trashbin');
|
||||
}
|
||||
|
||||
function tearDown()
|
||||
{
|
||||
function tearDown() {
|
||||
// reset app files_trashbin
|
||||
if ($this->stateFilesTrashbin) {
|
||||
OC_App::enable('files_trashbin');
|
||||
}
|
||||
else {
|
||||
OC_App::disable('files_trashbin');
|
||||
}
|
||||
}
|
||||
|
||||
\OC_FileProxy::clearProxies();
|
||||
public static function tearDownAfterClass() {
|
||||
// cleanup test user
|
||||
\OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
|
||||
\OC_User::deleteUser(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief test that paths set during User construction are correct
|
||||
*/
|
||||
function testKeyPaths()
|
||||
{
|
||||
function testKeyPaths() {
|
||||
$util = new Encryption\Util($this->view, $this->userId);
|
||||
|
||||
$this->assertEquals($this->publicKeyDir, $util->getPath('publicKeyDir'));
|
||||
|
@ -118,39 +134,37 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
|||
/**
|
||||
* @brief test setup of encryption directories
|
||||
*/
|
||||
function testSetupServerSide()
|
||||
{
|
||||
function testSetupServerSide() {
|
||||
$this->assertEquals(true, $this->util->setupServerSide($this->pass));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief test checking whether account is ready for encryption,
|
||||
*/
|
||||
function testUserIsReady()
|
||||
{
|
||||
function testUserIsReady() {
|
||||
$this->assertEquals(true, $this->util->ready());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief test checking whether account is not ready for encryption,
|
||||
*/
|
||||
function testUserIsNotReady()
|
||||
{
|
||||
$this->view->unlink($this->publicKeyDir);
|
||||
|
||||
$params['uid'] = $this->userId;
|
||||
$params['password'] = $this->pass;
|
||||
$this->assertFalse(OCA\Encryption\Hooks::login($params));
|
||||
|
||||
$this->view->unlink($this->privateKeyPath);
|
||||
}
|
||||
// function testUserIsNotReady() {
|
||||
// $this->view->unlink($this->publicKeyDir);
|
||||
//
|
||||
// $params['uid'] = $this->userId;
|
||||
// $params['password'] = $this->pass;
|
||||
// $this->assertFalse(OCA\Encryption\Hooks::login($params));
|
||||
//
|
||||
// $this->view->unlink($this->privateKeyPath);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief test checking whether account is not ready for encryption,
|
||||
*/
|
||||
function testIsLagacyUser()
|
||||
{
|
||||
$userView = new \OC_FilesystemView( '/' . $this->userId );
|
||||
function testIsLegacyUser() {
|
||||
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER);
|
||||
|
||||
$userView = new \OC_FilesystemView('/' . \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER);
|
||||
|
||||
// Disable encryption proxy to prevent recursive calls
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
|
@ -161,19 +175,18 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
|||
|
||||
\OC_FileProxy::$enabled = $proxyStatus;
|
||||
|
||||
$params['uid'] = $this->userId;
|
||||
$params['password'] = $this->pass;
|
||||
$params['uid'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER;
|
||||
$params['password'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER;
|
||||
|
||||
$util = new Encryption\Util($this->view, $this->userId);
|
||||
$util = new Encryption\Util($this->view, \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER);
|
||||
$util->setMigrationStatus(0);
|
||||
|
||||
$this->assertTrue(OCA\Encryption\Hooks::login($params));
|
||||
|
||||
$this->assertEquals($this->lagacyKey, $_SESSION['legacyKey']);
|
||||
$this->assertEquals($this->legacyKey, $_SESSION['legacyKey']);
|
||||
}
|
||||
|
||||
function testRecoveryEnabledForUser()
|
||||
{
|
||||
function testRecoveryEnabledForUser() {
|
||||
|
||||
$util = new Encryption\Util($this->view, $this->userId);
|
||||
|
||||
|
@ -193,10 +206,9 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
|||
|
||||
}
|
||||
|
||||
function testGetUidAndFilename()
|
||||
{
|
||||
function testGetUidAndFilename() {
|
||||
|
||||
\OC_User::setUserId('admin');
|
||||
\OC_User::setUserId(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1);
|
||||
|
||||
$filename = 'tmp-' . time() . '.test';
|
||||
|
||||
|
@ -213,9 +225,11 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
|||
|
||||
list($fileOwnerUid, $file) = $util->getUidAndFilename($filename);
|
||||
|
||||
$this->assertEquals('admin', $fileOwnerUid);
|
||||
$this->assertEquals(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, $fileOwnerUid);
|
||||
|
||||
$this->assertEquals($file, $filename);
|
||||
|
||||
$this->view->unlink($this->userId . '/files/' . $filename);
|
||||
}
|
||||
|
||||
function testIsSharedPath() {
|
||||
|
@ -227,10 +241,11 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
|||
$this->assertFalse($this->util->isSharedPath($path));
|
||||
}
|
||||
|
||||
function testEncryptLagacyFiles()
|
||||
{
|
||||
$userView = new \OC_FilesystemView( '/' . $this->userId);
|
||||
$view = new \OC_FilesystemView( '/' . $this->userId . '/files' );
|
||||
function testEncryptLegacyFiles() {
|
||||
\Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER);
|
||||
|
||||
$userView = new \OC_FilesystemView('/' . \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER);
|
||||
$view = new \OC_FilesystemView('/' . \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER . '/files');
|
||||
|
||||
// Disable encryption proxy to prevent recursive calls
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
|
@ -250,23 +265,23 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
|||
|
||||
\OC_FileProxy::$enabled = $proxyStatus;
|
||||
|
||||
$params['uid'] = $this->userId;
|
||||
$params['password'] = $this->pass;
|
||||
$params['uid'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER;
|
||||
$params['password'] = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER;
|
||||
|
||||
$util = new Encryption\Util($this->view, $this->userId);
|
||||
$util = new Encryption\Util($this->view, \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER);
|
||||
$util->setMigrationStatus(0);
|
||||
|
||||
$this->assertTrue(OCA\Encryption\Hooks::login($params));
|
||||
|
||||
$this->assertEquals($this->lagacyKey, $_SESSION['legacyKey']);
|
||||
$this->assertEquals($this->legacyKey, $_SESSION['legacyKey']);
|
||||
|
||||
$files = $util->findEncFiles('/' . $this->userId . '/files/');
|
||||
$files = $util->findEncFiles('/' . \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER . '/files/');
|
||||
|
||||
$this->assertTrue(is_array($files));
|
||||
|
||||
$found = false;
|
||||
foreach($files['encrypted'] as $encryptedFile) {
|
||||
if($encryptedFile['name'] === 'legacy-encrypted-text.txt') {
|
||||
foreach ($files['encrypted'] as $encryptedFile) {
|
||||
if ($encryptedFile['name'] === 'legacy-encrypted-text.txt') {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -274,4 +289,29 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->assertTrue($found);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user
|
||||
* @param bool $create
|
||||
* @param bool $password
|
||||
*/
|
||||
public static function loginHelper($user, $create = false, $password = false) {
|
||||
if ($create) {
|
||||
\OC_User::createUser($user, $user);
|
||||
}
|
||||
|
||||
if ($password === false) {
|
||||
$password = $user;
|
||||
}
|
||||
|
||||
\OC_Util::tearDownFS();
|
||||
\OC_User::setUserId('');
|
||||
\OC\Files\Filesystem::tearDown();
|
||||
\OC_Util::setupFS($user);
|
||||
\OC_User::setUserId($user);
|
||||
|
||||
$params['uid'] = $user;
|
||||
$params['password'] = $password;
|
||||
OCA\Encryption\Hooks::login($params);
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ require_once realpath(dirname(__FILE__) . '/../lib/proxy.php');
|
|||
require_once realpath(dirname(__FILE__) . '/../lib/stream.php');
|
||||
require_once realpath(dirname(__FILE__) . '/../lib/util.php');
|
||||
require_once realpath(dirname(__FILE__) . '/../appinfo/app.php');
|
||||
require_once realpath(dirname(__FILE__) . '/util.php');
|
||||
|
||||
use OCA\Encryption;
|
||||
|
||||
|
@ -34,8 +35,9 @@ use OCA\Encryption;
|
|||
* Class Test_Encryption_Webdav
|
||||
* @brief this class provide basic webdav tests for PUT,GET and DELETE
|
||||
*/
|
||||
class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
const TEST_ENCRYPTION_WEBDAV_USER1 = "test-webdav-user1";
|
||||
|
||||
public $userId;
|
||||
public $pass;
|
||||
|
@ -46,15 +48,33 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase
|
|||
public $dataShort;
|
||||
public $stateFilesTrashbin;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
public static function setUpBeforeClass() {
|
||||
// reset backend
|
||||
\OC_User::clearBackends();
|
||||
\OC_User::useBackend('database');
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
// Filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerUserHooks();
|
||||
|
||||
// clear and register hooks
|
||||
\OC_FileProxy::clearProxies();
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// create test user
|
||||
\Test_Encryption_Util::loginHelper(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1, true);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
// reset backend
|
||||
\OC_User::useBackend('database');
|
||||
|
||||
// set user id
|
||||
\OC_User::setUserId('admin');
|
||||
$this->userId = 'admin';
|
||||
$this->pass = 'admin';
|
||||
\OC_User::setUserId(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1);
|
||||
$this->userId = \Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1;
|
||||
$this->pass = \Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1;
|
||||
|
||||
// init filesystem view
|
||||
$this->view = new \OC_FilesystemView('/');
|
||||
|
@ -62,42 +82,29 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase
|
|||
// init short data
|
||||
$this->dataShort = 'hats';
|
||||
|
||||
// init filesystem related hooks
|
||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||
|
||||
// register encryption file proxy
|
||||
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
||||
|
||||
// remember files_trashbin state
|
||||
$this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
|
||||
|
||||
// we don't want to tests with app files_trashbin enabled
|
||||
\OC_App::disable('files_trashbin');
|
||||
|
||||
// init filesystem for user
|
||||
\OC_Util::tearDownFS();
|
||||
\OC_User::setUserId('');
|
||||
\OC\Files\Filesystem::tearDown();
|
||||
\OC_Util::setupFS($this->userId);
|
||||
\OC_User::setUserId($this->userId);
|
||||
|
||||
// login user
|
||||
$params['uid'] = $this->userId;
|
||||
$params['password'] = $this->pass;
|
||||
OCA\Encryption\Hooks::login($params);
|
||||
// create test user
|
||||
\Test_Encryption_Util::loginHelper(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1);
|
||||
}
|
||||
|
||||
function tearDown()
|
||||
{
|
||||
function tearDown() {
|
||||
// reset app files_trashbin
|
||||
if ($this->stateFilesTrashbin) {
|
||||
OC_App::enable('files_trashbin');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
OC_App::disable('files_trashbin');
|
||||
}
|
||||
}
|
||||
|
||||
// clear all proxies
|
||||
\OC_FileProxy::clearProxies();
|
||||
public static function tearDownAfterClass() {
|
||||
// cleanup test user
|
||||
\OC_User::deleteUser(\Test_Encryption_Webdav::TEST_ENCRYPTION_WEBDAV_USER1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,10 +132,12 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase
|
|||
$this->assertTrue($this->view->file_exists('/' . $this->userId . '/files' . $filename));
|
||||
|
||||
// check if key-file was created
|
||||
$this->assertTrue($this->view->file_exists('/' . $this->userId . '/files_encryption/keyfiles/' . $filename . '.key'));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . $this->userId . '/files_encryption/keyfiles/' . $filename . '.key'));
|
||||
|
||||
// check if shareKey-file was created
|
||||
$this->assertTrue($this->view->file_exists('/' . $this->userId . '/files_encryption/share-keys/' . $filename . '.' . $this->userId . '.shareKey'));
|
||||
$this->assertTrue($this->view->file_exists(
|
||||
'/' . $this->userId . '/files_encryption/share-keys/' . $filename . '.' . $this->userId . '.shareKey'));
|
||||
|
||||
// disable encryption proxy to prevent recursive calls
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
|
@ -194,10 +203,12 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase
|
|||
$this->assertFalse($this->view->file_exists('/' . $this->userId . '/files' . $filename));
|
||||
|
||||
// check if key-file was removed
|
||||
$this->assertFalse($this->view->file_exists('/' . $this->userId . '/files_encryption/keyfiles' . $filename . '.key'));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . $this->userId . '/files_encryption/keyfiles' . $filename . '.key'));
|
||||
|
||||
// check if shareKey-file was removed
|
||||
$this->assertFalse($this->view->file_exists('/' . $this->userId . '/files_encryption/share-keys' . $filename . '.' . $this->userId . '.shareKey'));
|
||||
$this->assertFalse($this->view->file_exists(
|
||||
'/' . $this->userId . '/files_encryption/share-keys' . $filename . '.' . $this->userId . '.shareKey'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -229,7 +240,7 @@ class Test_Encryption_Webdav extends \PHPUnit_Framework_TestCase
|
|||
$server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin());
|
||||
|
||||
// And off we go!
|
||||
if($body) {
|
||||
if ($body) {
|
||||
$server->httpRequest->setBody($body);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue