2013-05-23 01:51:35 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ownCloud
|
|
|
|
*
|
|
|
|
* @author Florin Peter
|
|
|
|
* @copyright 2013 Florin Peter <owncloud@florin-peter.de>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-08-21 12:59:31 +04:00
|
|
|
require_once __DIR__ . '/util.php';
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
use OCA\Encryption;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Test_Encryption_Trashbin
|
2014-05-19 19:50:53 +04:00
|
|
|
* this class provide basic trashbin app tests
|
2013-05-23 01:51:35 +04:00
|
|
|
*/
|
2013-05-26 22:44:15 +04:00
|
|
|
class Test_Encryption_Trashbin extends \PHPUnit_Framework_TestCase {
|
|
|
|
|
|
|
|
const TEST_ENCRYPTION_TRASHBIN_USER1 = "test-trashbin-user1";
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
public $userId;
|
|
|
|
public $pass;
|
|
|
|
/**
|
2014-05-12 18:30:39 +04:00
|
|
|
* @var \OC\Files\View
|
2013-05-23 01:51:35 +04:00
|
|
|
*/
|
|
|
|
public $view;
|
|
|
|
public $dataShort;
|
|
|
|
public $stateFilesTrashbin;
|
|
|
|
public $folder1;
|
|
|
|
public $subfolder;
|
|
|
|
public $subsubfolder;
|
|
|
|
|
2013-05-26 05:22:16 +04:00
|
|
|
public static function setUpBeforeClass() {
|
2013-05-23 01:51:35 +04:00
|
|
|
// reset backend
|
2013-05-26 05:22:16 +04:00
|
|
|
\OC_User::clearBackends();
|
2013-05-26 22:44:15 +04:00
|
|
|
\OC_User::useBackend('database');
|
2013-05-23 01:51:35 +04:00
|
|
|
|
2013-05-26 22:44:15 +04:00
|
|
|
\OC_Hook::clear('OC_Filesystem');
|
|
|
|
\OC_Hook::clear('OC_User');
|
2013-05-26 05:22:16 +04:00
|
|
|
|
|
|
|
// trashbin hooks
|
|
|
|
\OCA\Files_Trashbin\Trashbin::registerHooks();
|
|
|
|
|
|
|
|
// Filesystem related hooks
|
|
|
|
\OCA\Encryption\Helper::registerFilesystemHooks();
|
|
|
|
|
|
|
|
// clear and register hooks
|
|
|
|
\OC_FileProxy::clearProxies();
|
2013-05-26 22:44:15 +04:00
|
|
|
\OC_FileProxy::register(new OCA\Encryption\Proxy());
|
|
|
|
|
|
|
|
// create test user
|
|
|
|
\Test_Encryption_Util::loginHelper(\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1, true);
|
2013-05-26 05:22:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function setUp() {
|
2013-05-23 01:51:35 +04:00
|
|
|
// set user id
|
2013-05-26 22:44:15 +04:00
|
|
|
\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;
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// init filesystem view
|
2014-05-12 18:30:39 +04:00
|
|
|
$this->view = new \OC\Files\View('/');
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// init short data
|
|
|
|
$this->dataShort = 'hats';
|
|
|
|
|
|
|
|
$this->folder1 = '/folder1';
|
|
|
|
$this->subfolder = '/subfolder1';
|
|
|
|
$this->subsubfolder = '/subsubfolder1';
|
|
|
|
|
|
|
|
// remember files_trashbin state
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->stateFilesTrashbin = OC_App::isEnabled('files_trashbin');
|
2013-05-23 01:51:35 +04:00
|
|
|
|
2013-05-26 05:22:16 +04:00
|
|
|
// we want to tests with app files_trashbin enabled
|
2013-05-26 22:44:15 +04:00
|
|
|
\OC_App::enable('files_trashbin');
|
2013-05-23 01:51:35 +04:00
|
|
|
}
|
|
|
|
|
2013-05-26 05:22:16 +04:00
|
|
|
function tearDown() {
|
2013-05-23 01:51:35 +04:00
|
|
|
// reset app files_trashbin
|
2013-05-26 22:44:15 +04:00
|
|
|
if ($this->stateFilesTrashbin) {
|
|
|
|
OC_App::enable('files_trashbin');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
OC_App::disable('files_trashbin');
|
2013-05-23 01:51:35 +04:00
|
|
|
}
|
2013-05-26 05:22:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function tearDownAfterClass() {
|
2013-05-26 22:44:15 +04:00
|
|
|
// cleanup test user
|
|
|
|
\OC_User::deleteUser(\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1);
|
2014-10-10 17:34:19 +04:00
|
|
|
|
|
|
|
\OC_Hook::clear();
|
|
|
|
\OC_FileProxy::clearProxies();
|
|
|
|
|
|
|
|
// Delete keys in /data/
|
|
|
|
$view = new \OC\Files\View('/');
|
|
|
|
$view->rmdir('public-keys');
|
|
|
|
$view->rmdir('owncloud_private_key');
|
2013-05-23 01:51:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-06-10 16:45:39 +04:00
|
|
|
* @medium
|
2014-05-19 19:50:53 +04:00
|
|
|
* test delete file
|
2013-05-23 01:51:35 +04:00
|
|
|
*/
|
|
|
|
function testDeleteFile() {
|
|
|
|
|
|
|
|
// generate filename
|
2014-01-21 19:19:26 +04:00
|
|
|
$filename = 'tmp-' . uniqid() . '.txt';
|
2014-09-17 20:50:29 +04:00
|
|
|
$filename2 = $filename . '.backup'; // a second file with similar name
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// save file with content
|
2013-07-30 20:21:23 +04:00
|
|
|
$cryptedFile = file_put_contents('crypt:///' .\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1. '/files/'. $filename, $this->dataShort);
|
2014-09-17 20:50:29 +04:00
|
|
|
$cryptedFile2 = file_put_contents('crypt:///' .\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1. '/files/'. $filename2, $this->dataShort);
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// test that data was successfully written
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertTrue(is_int($cryptedFile));
|
2014-09-17 20:50:29 +04:00
|
|
|
$this->assertTrue(is_int($cryptedFile2));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if key for admin exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename
|
|
|
|
. '.key'));
|
2014-09-17 20:50:29 +04:00
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename2
|
|
|
|
. '.key'));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if share key for admin exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$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'));
|
2014-09-17 20:50:29 +04:00
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
|
|
|
|
. $filename2 . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
2014-09-17 20:50:29 +04:00
|
|
|
// delete first file
|
2013-05-26 22:44:15 +04:00
|
|
|
\OC\FIles\Filesystem::unlink($filename);
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if file not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertFalse($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if key for admin not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertFalse($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename
|
|
|
|
. '.key'));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if share key for admin not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$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'));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
2014-09-17 20:50:29 +04:00
|
|
|
// check that second file still exists
|
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename2));
|
|
|
|
|
|
|
|
// check that key for second file still exists
|
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename2
|
|
|
|
. '.key'));
|
|
|
|
|
|
|
|
// check that share key for second file still exists
|
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
|
|
|
|
. $filename2 . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
|
|
|
|
|
2013-05-23 01:51:35 +04:00
|
|
|
// get files
|
2013-05-26 22:44:15 +04:00
|
|
|
$trashFiles = $this->view->getDirectoryContent(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/');
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
$trashFileSuffix = null;
|
|
|
|
// find created file with timestamp
|
2013-05-26 22:44:15 +04:00
|
|
|
foreach ($trashFiles as $file) {
|
|
|
|
if (strncmp($file['path'], $filename, strlen($filename))) {
|
|
|
|
$path_parts = pathinfo($file['name']);
|
2013-05-23 01:51:35 +04:00
|
|
|
$trashFileSuffix = $path_parts['extension'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if we found the file we created
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertNotNull($trashFileSuffix);
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if key for admin not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename
|
|
|
|
. '.key.' . $trashFileSuffix));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if share key for admin not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$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));
|
2013-05-23 01:51:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-06-10 11:31:22 +04:00
|
|
|
* @medium
|
2014-05-19 19:50:53 +04:00
|
|
|
* test restore file
|
2013-05-23 01:51:35 +04:00
|
|
|
*/
|
2014-09-17 20:50:29 +04:00
|
|
|
function testRestoreFile() {
|
|
|
|
// generate filename
|
|
|
|
$filename = 'tmp-' . uniqid() . '.txt';
|
|
|
|
$filename2 = $filename . '.backup'; // a second file with similar name
|
|
|
|
|
|
|
|
// save file with content
|
|
|
|
$cryptedFile = file_put_contents('crypt:///' .\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1. '/files/'. $filename, $this->dataShort);
|
|
|
|
$cryptedFile2 = file_put_contents('crypt:///' .\Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1. '/files/'. $filename2, $this->dataShort);
|
|
|
|
|
|
|
|
// delete both files
|
|
|
|
\OC\Files\Filesystem::unlink($filename);
|
|
|
|
\OC\Files\Filesystem::unlink($filename2);
|
|
|
|
|
|
|
|
$trashFiles = $this->view->getDirectoryContent(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/');
|
|
|
|
|
|
|
|
$trashFileSuffix = null;
|
|
|
|
$trashFileSuffix2 = null;
|
|
|
|
// find created file with timestamp
|
|
|
|
foreach ($trashFiles as $file) {
|
|
|
|
if (strncmp($file['path'], $filename, strlen($filename))) {
|
|
|
|
$path_parts = pathinfo($file['name']);
|
|
|
|
$trashFileSuffix = $path_parts['extension'];
|
|
|
|
}
|
|
|
|
if (strncmp($file['path'], $filename2, strlen($filename2))) {
|
|
|
|
$path_parts = pathinfo($file['name']);
|
|
|
|
$trashFileSuffix2 = $path_parts['extension'];
|
|
|
|
}
|
|
|
|
}
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// prepare file information
|
2013-05-26 22:44:15 +04:00
|
|
|
$timestamp = str_replace('d', '', $trashFileSuffix);
|
2013-05-23 01:51:35 +04:00
|
|
|
|
2014-09-17 20:50:29 +04:00
|
|
|
// restore first file
|
|
|
|
$this->assertTrue(\OCA\Files_Trashbin\Trashbin::restore($filename . '.' . $trashFileSuffix, $filename, $timestamp));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if file exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertTrue($this->view->file_exists(
|
2014-09-17 20:50:29 +04:00
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if key for admin exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/'
|
2014-09-17 20:50:29 +04:00
|
|
|
. $filename . '.key'));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if share key for admin exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
|
2014-09-17 20:50:29 +04:00
|
|
|
. $filename . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
|
|
|
|
|
|
|
|
// check that second file was NOT restored
|
|
|
|
$this->assertFalse($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename2));
|
|
|
|
|
|
|
|
// check if key for admin exists
|
|
|
|
$this->assertFalse($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/'
|
|
|
|
. $filename2 . '.key'));
|
|
|
|
|
|
|
|
// check if share key for admin exists
|
|
|
|
$this->assertFalse($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/share-keys/'
|
|
|
|
. $filename2 . '.' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '.shareKey'));
|
2013-05-23 01:51:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-06-10 11:31:22 +04:00
|
|
|
* @medium
|
2014-05-19 19:50:53 +04:00
|
|
|
* test delete file forever
|
2013-05-23 01:51:35 +04:00
|
|
|
*/
|
|
|
|
function testPermanentDeleteFile() {
|
|
|
|
|
|
|
|
// generate filename
|
2014-01-21 19:19:26 +04:00
|
|
|
$filename = 'tmp-' . uniqid() . '.txt';
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// save file with content
|
2013-07-30 16:18:01 +04:00
|
|
|
$cryptedFile = file_put_contents('crypt:///' .$this->userId. '/files/' . $filename, $this->dataShort);
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// test that data was successfully written
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertTrue(is_int($cryptedFile));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if key for admin exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename
|
|
|
|
. '.key'));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if share key for admin exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$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'));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// delete file
|
2014-09-17 20:50:29 +04:00
|
|
|
\OC\Files\Filesystem::unlink($filename);
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if file not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertFalse($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files/' . $filename));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if key for admin not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertFalse($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_encryption/keyfiles/' . $filename
|
|
|
|
. '.key'));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if share key for admin not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$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'));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// find created file with timestamp
|
2013-05-26 22:44:15 +04:00
|
|
|
$query = \OC_DB::prepare('SELECT `timestamp`,`type` FROM `*PREFIX*files_trash`'
|
|
|
|
. ' WHERE `id`=?');
|
|
|
|
$result = $query->execute(array($filename))->fetchRow();
|
2013-05-23 01:51:35 +04:00
|
|
|
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertTrue(is_array($result));
|
2013-05-26 05:22:16 +04:00
|
|
|
|
|
|
|
// build suffix
|
|
|
|
$trashFileSuffix = 'd' . $result['timestamp'];
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if key for admin exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertTrue($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename
|
|
|
|
. '.key.' . $trashFileSuffix));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if share key for admin exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$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));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// get timestamp from file
|
2013-05-26 22:44:15 +04:00
|
|
|
$timestamp = str_replace('d', '', $trashFileSuffix);
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// delete file forever
|
2014-06-18 00:30:39 +04:00
|
|
|
$this->assertGreaterThan(0, \OCA\Files_Trashbin\Trashbin::delete($filename, $this->userId, $timestamp));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if key for admin not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertFalse($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/files/' . $filename . '.'
|
|
|
|
. $trashFileSuffix));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if key for admin not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$this->assertFalse($this->view->file_exists(
|
|
|
|
'/' . \Test_Encryption_Trashbin::TEST_ENCRYPTION_TRASHBIN_USER1 . '/files_trashbin/keyfiles/' . $filename
|
|
|
|
. '.key.' . $trashFileSuffix));
|
2013-05-23 01:51:35 +04:00
|
|
|
|
|
|
|
// check if share key for admin not exists
|
2013-05-26 22:44:15 +04:00
|
|
|
$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));
|
2013-05-23 01:51:35 +04:00
|
|
|
}
|
|
|
|
|
2013-08-18 13:02:08 +04:00
|
|
|
}
|