improved tests
This commit is contained in:
parent
1c8e5d6873
commit
f2b1158add
|
@ -225,15 +225,20 @@ class Hooks {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$error = false;
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
if (!$view->file_exists($user . '.public.key')) {
|
if (!$view->file_exists($user . '.public.key')) {
|
||||||
// Set flag var 'run' to notify emitting
|
$error = true;
|
||||||
// script that hook execution failed
|
break;
|
||||||
$params['run']->run = false;
|
|
||||||
// TODO: Make sure files_sharing provides user
|
|
||||||
// feedback on failed share
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($error)
|
||||||
|
// Set flag var 'run' to notify emitting
|
||||||
|
// script that hook execution failed
|
||||||
|
$params['run']->run = false;
|
||||||
|
// TODO: Make sure files_sharing provides user
|
||||||
|
// feedback on failed share
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -706,7 +706,8 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->assertEquals($this->dataLong, $decrypt);
|
$this->assertEquals($this->dataLong, $decrypt);
|
||||||
|
|
||||||
$newFolder = '/newfolder' . time();
|
$newFolder = '/newfolder/subfolder' . time();
|
||||||
|
$view->mkdir('/newfolder');
|
||||||
|
|
||||||
$view->rename($folder, $newFolder);
|
$view->rename($folder, $newFolder);
|
||||||
|
|
||||||
|
@ -719,43 +720,9 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase
|
||||||
$view->unlink($newFolder);
|
$view->unlink($newFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testRenameFolder()
|
|
||||||
{
|
|
||||||
|
|
||||||
$filename = '/tmp-' . time();
|
|
||||||
|
|
||||||
$folder = '/folder';
|
|
||||||
$newFolder = '/newfolder';
|
|
||||||
$view = new \OC\Files\View('/' . $this->userId . '/files');
|
|
||||||
$view->mkdir($folder);
|
|
||||||
|
|
||||||
// Save long data as encrypted file using stream wrapper
|
|
||||||
$cryptedFile = file_put_contents('crypt://' . $folder . $filename, $this->dataLong);
|
|
||||||
|
|
||||||
// Test that data was successfully written
|
|
||||||
$this->assertTrue(is_int($cryptedFile));
|
|
||||||
|
|
||||||
// Get file decrypted contents
|
|
||||||
$decrypt = file_get_contents('crypt://' . $folder . $filename);
|
|
||||||
|
|
||||||
$this->assertEquals($this->dataLong, $decrypt);
|
|
||||||
|
|
||||||
// rename folder
|
|
||||||
$view->rename($folder, $newFolder);
|
|
||||||
|
|
||||||
// Get file decrypted contents
|
|
||||||
$newDecrypt = file_get_contents('crypt://' . $newFolder . $filename);
|
|
||||||
|
|
||||||
$this->assertEquals($this->dataLong, $newDecrypt);
|
|
||||||
|
|
||||||
// tear down
|
|
||||||
$view->unlink($newFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testChangePassphrase()
|
function testChangePassphrase()
|
||||||
{
|
{
|
||||||
|
$filename = 'tmp-' . time();
|
||||||
$filename = 'tmp-' . time();
|
|
||||||
|
|
||||||
// Save long data as encrypted file using stream wrapper
|
// Save long data as encrypted file using stream wrapper
|
||||||
$cryptedFile = file_put_contents('crypt://' . $filename, $this->dataLong);
|
$cryptedFile = file_put_contents('crypt://' . $filename, $this->dataLong);
|
||||||
|
|
Loading…
Reference in New Issue