use OCA\Encryption;
+/**
+ * Class Test_Encryption_Crypt
+ */
class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
-
+
+ public $userId;
+ public $pass;
+ public $stateFilesTrashbin;
+ public $dataLong;
+ public $dataUrl;
+ public $dataShort;
+ /**
+ * @var OC_FilesystemView
+ */
+ public $view;
+ public $legacyEncryptedData;
+ public $genPrivateKey;
+ public $genPublicKey;
+
function setUp() {
// reset backend
\OC_User::clearBackends();
$this->assertTrue( strlen( $key ) > 16 );
}
-
+
+ /**
+ * @return String
+ */
function testGenerateIv() {
$iv = Encryption\Crypt::generateIv();
$this->assertEquals( $this->dataLong, $splitCatfile['encrypted'] );
}
-
+
+ /**
+ * @return string padded
+ */
function testAddPadding() {
$padded = Encryption\Crypt::addPadding( $this->dataLong );
$this->assertEquals( $this->dataShort, $decrypt );
}
-
- // These aren't used for now
-// function testSymmetricBlockEncryptShortFileContent() {
-//
-// $crypted = Encryption\Crypt::symmetricBlockEncryptFileContent( $this->dataShort, $this->randomKey );
-//
-// $this->assertNotEquals( $this->dataShort, $crypted );
-//
-//
-// $decrypt = Encryption\Crypt::symmetricBlockDecryptFileContent( $crypted, $this->randomKey );
-//
-// $this->assertEquals( $this->dataShort, $decrypt );
-//
-// }
-//
-// function testSymmetricBlockEncryptLongFileContent() {
-//
-// $crypted = Encryption\Crypt::symmetricBlockEncryptFileContent( $this->dataLong, $this->randomKey );
-//
-// $this->assertNotEquals( $this->dataLong, $crypted );
-//
-//
-// $decrypt = Encryption\Crypt::symmetricBlockDecryptFileContent( $crypted, $this->randomKey );
-//
-// $this->assertEquals( $this->dataLong, $decrypt );
-//
-// }
-
+
function testSymmetricStreamEncryptShortFileContent() {
$filename = 'tmp-'.time().'.test';
$decrypt = '';
// Manually decrypt chunk
- foreach ($e as $e) {
+ foreach ($e as $chunk) {
- $chunkDecrypt = Encryption\Crypt::symmetricDecryptFileContent( $e, $plainKeyfile );
+ $chunkDecrypt = Encryption\Crypt::symmetricDecryptFileContent( $chunk, $plainKeyfile );
// Assemble decrypted chunks
$decrypt .= $chunkDecrypt;
$this->assertEquals( $this->dataLong, $decrypt );
// change password
- \OC_User::setPassword($this->userId, 'test');
+ \OC_User::setPassword($this->userId, 'test', null);
// relogin
$params['uid'] = $this->userId;
use OCA\Encryption;
+/**
+ * Class Test_Encryption_Share
+ */
class Test_Encryption_Share extends \PHPUnit_Framework_TestCase
{
- function setUp()
+ public $stateFilesTrashbin;
+ public $filename;
+ public $dataShort;
+ /**
+ * @var OC_FilesystemView
+ */
+ public $view;
+ public $folder1;
+ public $subfolder;
+ public $subsubfolder;
+
+ function setUp()
{
// reset backend
\OC_User::clearBackends();
\OC_FileProxy::clearProxies();
}
- function testShareFile($withTeardown = true)
+ /**
+ * @param bool $withTeardown
+ */
+ function testShareFile($withTeardown = true)
{
// login as admin
$this->loginHelper('admin');
}
}
- function testReShareFile($withTeardown = true)
+ /**
+ * @param bool $withTeardown
+ */
+ function testReShareFile($withTeardown = true)
{
$this->testShareFile(false);
}
}
- function testShareFolder($withTeardown = true)
+ /**
+ * @param bool $withTeardown
+ * @return array
+ */
+ function testShareFolder($withTeardown = true)
{
// login as admin
$this->loginHelper('admin');
return $fileInfo;
}
- function testReShareFolder($withTeardown = true)
+ /**
+ * @param bool $withTeardown
+ */
+ function testReShareFolder($withTeardown = true)
{
$fileInfoFolder1 = $this->testShareFolder(false);
$this->assertTrue($util->setRecoveryForUser(false));
}
+ /**
+ * @param $user
+ * @param bool $create
+ * @param bool $password
+ */
function loginHelper($user, $create = false, $password = false)
{
if ($create) {