Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-01-21 19:19:26 +0400
committerVincent Petry <pvince81@owncloud.com>2014-01-21 20:47:46 +0400
commite46df97c3ae943fe943663dffef7fc4f9aa4fe37 (patch)
treeb48ec289af38c6dbffdcac9adeaf91b4de118629 /apps/files_encryption/tests/crypt.php
parent180bb9fa9f65061d1cc074ec1b749651d3c567b5 (diff)
Replaced time() with uniqid() to make sure the file name is unique
The cache isn't cleared properly because unlink() doesn't remove the cache entry which caused side-effects when reusing the same file name (which randomly happens when time() returns the same value) This fix first makes sure the unit tests don't fail any more. The unlink() case with the cache will be investigated separately. Backport of f09c19c to stable6
Diffstat (limited to 'apps/files_encryption/tests/crypt.php')
-rwxr-xr-xapps/files_encryption/tests/crypt.php34
1 files changed, 17 insertions, 17 deletions
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php
index ca14e3e2ccb..388980ad4fd 100755
--- a/apps/files_encryption/tests/crypt.php
+++ b/apps/files_encryption/tests/crypt.php
@@ -155,7 +155,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testSymmetricStreamEncryptShortFileContent() {
- $filename = 'tmp-' . time() . '.test';
+ $filename = 'tmp-' . uniqid() . '.test';
$util = new Encryption\Util(new \OC_FilesystemView(), $this->userId);
@@ -214,7 +214,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
function testSymmetricStreamEncryptLongFileContent() {
// Generate a a random filename
- $filename = 'tmp-' . time() . '.test';
+ $filename = 'tmp-' . uniqid() . '.test';
$util = new Encryption\Util(new \OC_FilesystemView(), $this->userId);
@@ -297,7 +297,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testSymmetricStreamDecryptShortFileContent() {
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///'. $this->userId . '/files/' . $filename, $this->dataShort);
@@ -327,7 +327,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testSymmetricStreamDecryptLongFileContent() {
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong);
@@ -418,7 +418,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testRenameFile() {
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong);
@@ -431,7 +431,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$this->assertEquals($this->dataLong, $decrypt);
- $newFilename = 'tmp-new-' . time();
+ $newFilename = 'tmp-new-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
$view->rename($filename, $newFilename);
@@ -449,7 +449,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testMoveFileIntoFolder() {
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong);
@@ -462,8 +462,8 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$this->assertEquals($this->dataLong, $decrypt);
- $newFolder = '/newfolder' . time();
- $newFilename = 'tmp-new-' . time();
+ $newFolder = '/newfolder' . uniqid();
+ $newFilename = 'tmp-new-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
$view->mkdir($newFolder);
$view->rename($filename, $newFolder . '/' . $newFilename);
@@ -484,8 +484,8 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$view = new \OC\Files\View('/' . $this->userId . '/files');
- $filename = '/tmp-' . time();
- $folder = '/folder' . time();
+ $filename = '/tmp-' . uniqid();
+ $folder = '/folder' . uniqid();
$view->mkdir($folder);
@@ -500,7 +500,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
$this->assertEquals($this->dataLong, $decrypt);
- $newFolder = '/newfolder/subfolder' . time();
+ $newFolder = '/newfolder/subfolder' . uniqid();
$view->mkdir('/newfolder');
$view->rename($folder, $newFolder);
@@ -519,7 +519,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
* @medium
*/
function testChangePassphrase() {
- $filename = 'tmp-' . time();
+ $filename = 'tmp-' . uniqid();
// Save long data as encrypted file using stream wrapper
$cryptedFile = file_put_contents('crypt:///' . $this->userId . '/files/' . $filename, $this->dataLong);
@@ -557,7 +557,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
*/
function testViewFilePutAndGetContents() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
// Save short data as encrypted file using stream wrapper
@@ -590,7 +590,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
* @large
*/
function testTouchExistingFile() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
// Save short data as encrypted file using stream wrapper
@@ -614,7 +614,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
* @medium
*/
function testTouchFile() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
$view->touch($filename);
@@ -638,7 +638,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
* @medium
*/
function testFopenFile() {
- $filename = '/tmp-' . time();
+ $filename = '/tmp-' . uniqid();
$view = new \OC\Files\View('/' . $this->userId . '/files');
// Save short data as encrypted file using stream wrapper