improved tests
This commit is contained in:
parent
42b4963dd0
commit
a4c0eb1756
|
@ -62,8 +62,17 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
|
||||||
// Filesystem related hooks
|
// Filesystem related hooks
|
||||||
\OCA\Encryption\Helper::registerFilesystemHooks();
|
\OCA\Encryption\Helper::registerFilesystemHooks();
|
||||||
|
|
||||||
|
// Filesystem related hooks
|
||||||
|
\OCA\Encryption\Helper::registerUserHooks();
|
||||||
|
|
||||||
\OC_FileProxy::register(new OCA\Encryption\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');
|
||||||
|
|
||||||
\OC_Util::tearDownFS();
|
\OC_Util::tearDownFS();
|
||||||
\OC_User::setUserId('');
|
\OC_User::setUserId('');
|
||||||
\OC\Files\Filesystem::tearDown();
|
\OC\Files\Filesystem::tearDown();
|
||||||
|
@ -78,6 +87,13 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
\OC_FileProxy::clearProxies();
|
\OC_FileProxy::clearProxies();
|
||||||
|
|
||||||
|
// reset app files_trashbin
|
||||||
|
if ($this->stateFilesTrashbin) {
|
||||||
|
OC_App::enable('files_trashbin');
|
||||||
|
} else {
|
||||||
|
OC_App::disable('files_trashbin');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testGenerateKey() {
|
function testGenerateKey() {
|
||||||
|
@ -686,7 +702,6 @@ class Test_Crypt extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals( $this->dataLong, $newDecrypt );
|
$this->assertEquals( $this->dataLong, $newDecrypt );
|
||||||
|
|
||||||
// tear down
|
// tear down
|
||||||
$view->unlink( $newFolder . '/' . $newFilename );
|
|
||||||
$view->unlink( $newFolder );
|
$view->unlink( $newFolder );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,12 @@ class Test_Keymanager extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
\OC_FileProxy::register(new OCA\Encryption\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');
|
||||||
|
|
||||||
\OC_Util::tearDownFS();
|
\OC_Util::tearDownFS();
|
||||||
\OC_User::setUserId('');
|
\OC_User::setUserId('');
|
||||||
\OC\Files\Filesystem::tearDown();
|
\OC\Files\Filesystem::tearDown();
|
||||||
|
@ -72,6 +78,13 @@ class Test_Keymanager extends \PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
\OC_FileProxy::$enabled = true;
|
\OC_FileProxy::$enabled = true;
|
||||||
\OC_FileProxy::clearProxies();
|
\OC_FileProxy::clearProxies();
|
||||||
|
|
||||||
|
// reset app files_trashbin
|
||||||
|
if ($this->stateFilesTrashbin) {
|
||||||
|
OC_App::enable('files_trashbin');
|
||||||
|
} else {
|
||||||
|
OC_App::disable('files_trashbin');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testGetPrivateKey() {
|
function testGetPrivateKey() {
|
||||||
|
@ -117,6 +130,16 @@ class Test_Keymanager extends \PHPUnit_Framework_TestCase {
|
||||||
//$view = new \OC_FilesystemView( '/' . $this->userId . '/files_encryption/keyfiles' );
|
//$view = new \OC_FilesystemView( '/' . $this->userId . '/files_encryption/keyfiles' );
|
||||||
Encryption\Keymanager::setFileKey( $this->view, $file, $this->userId, $key['key'] );
|
Encryption\Keymanager::setFileKey( $this->view, $file, $this->userId, $key['key'] );
|
||||||
|
|
||||||
|
// Disable encryption proxy to prevent recursive calls
|
||||||
|
$proxyStatus = \OC_FileProxy::$enabled;
|
||||||
|
\OC_FileProxy::$enabled = true;
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
$this->view->unlink('/'.$this->userId . '/files/' . $file);
|
||||||
|
|
||||||
|
// Re-enable proxy - our work is done
|
||||||
|
\OC_FileProxy::$enabled = $proxyStatus;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
|
|
Loading…
Reference in New Issue