2015-03-30 14:59:48 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Test\Files\Stream;
|
|
|
|
|
|
|
|
use OC\Files\View;
|
|
|
|
use OCA\Encryption_Dummy\DummyModule;
|
|
|
|
|
|
|
|
class Encryption extends \Test\TestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $mode
|
|
|
|
* @param integer $limit
|
|
|
|
*/
|
|
|
|
protected function getStream($mode) {
|
|
|
|
|
|
|
|
$source = fopen('php://temp', $mode);
|
|
|
|
$internalPath = '';
|
|
|
|
$fullPath = '';
|
|
|
|
$header = [];
|
|
|
|
$uid = '';
|
|
|
|
$encryptionModule = new DummyModule();
|
|
|
|
$storage = $this->getMockBuilder('\OC\Files\Storage\Storage')
|
|
|
|
->disableOriginalConstructor()->getMock();
|
|
|
|
$encStorage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption')
|
|
|
|
->disableOriginalConstructor()->getMock();
|
2015-03-31 00:19:35 +03:00
|
|
|
$config = $this->getMockBuilder('\OCP\IConfig')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$util = new \OC\Encryption\Util(new View(), new \OC\User\Manager(), $config);
|
2015-03-30 14:59:48 +03:00
|
|
|
$size = 12;
|
|
|
|
$unencryptedSize = 8000;
|
|
|
|
|
|
|
|
return \OC\Files\Stream\Encryption::wrap($source, $internalPath,
|
|
|
|
$fullPath, $header, $uid, $encryptionModule, $storage, $encStorage,
|
|
|
|
$util, $mode, $size, $unencryptedSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testWriteEnoughSpace() {
|
|
|
|
$stream = $this->getStream('w+');
|
|
|
|
$this->assertEquals(6, fwrite($stream, 'foobar'));
|
|
|
|
rewind($stream);
|
|
|
|
$this->assertEquals('foobar', fread($stream, 100));
|
|
|
|
}
|
|
|
|
}
|