-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server side checksum verification #26655 #27097
Changes from all commits
241a172
8b33c6e
e207e04
ad8c417
8af929c
862506b
5d9c4b1
2cf5d16
ee1c201
fd277fd
395de64
2a6b626
d6ba656
18c632e
fc780db
5e2ca3c
4cb2c05
b985261
4dd7a11
05e11ce
63495df
6bd3aaf
0721f31
2caae3e
d8bd987
0e68f69
c826ea3
d7091b5
eeb8f07
5f18c5f
0496a82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,50 +146,8 @@ protected function tearDown() { | |
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* test expiration of files older then the max storage time defined for the trash | ||
*/ | ||
public function testExpireOldFiles() { | ||
|
||
$currentTime = time(); | ||
$expireAt = $currentTime - 2 * 24 * 60 * 60; | ||
$expiredDate = $currentTime - 3 * 24 * 60 * 60; | ||
|
||
// create some files | ||
\OC\Files\Filesystem::file_put_contents('file1.txt', 'file1'); | ||
\OC\Files\Filesystem::file_put_contents('file2.txt', 'file2'); | ||
\OC\Files\Filesystem::file_put_contents('file3.txt', 'file3'); | ||
|
||
// delete them so that they end up in the trash bin | ||
\OC\Files\Filesystem::unlink('file1.txt'); | ||
\OC\Files\Filesystem::unlink('file2.txt'); | ||
\OC\Files\Filesystem::unlink('file3.txt'); | ||
|
||
//make sure that files are in the trash bin | ||
$filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'name'); | ||
$this->assertSame(3, count($filesInTrash)); | ||
|
||
// every second file will get a date in the past so that it will get expired | ||
$manipulatedList = $this->manipulateDeleteTime($filesInTrash, $this->trashRoot1, $expiredDate); | ||
|
||
$testClass = new TrashbinForTesting(); | ||
list($sizeOfDeletedFiles, $count) = $testClass->dummyDeleteExpiredFiles($manipulatedList, $expireAt); | ||
|
||
$this->assertSame(10, $sizeOfDeletedFiles); | ||
$this->assertSame(2, $count); | ||
|
||
// only file2.txt should be left | ||
$remainingFiles = array_slice($manipulatedList, $count); | ||
$this->assertSame(1, count($remainingFiles)); | ||
$remainingFile = reset($remainingFiles); | ||
$this->assertSame('file2.txt', $remainingFile['name']); | ||
|
||
// check that file1.txt and file3.txt was really deleted | ||
$newTrashContent = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1); | ||
$this->assertSame(1, count($newTrashContent)); | ||
$element = reset($newTrashContent); | ||
$this->assertSame('file2.txt', $element['name']); | ||
} | ||
|
||
/** | ||
* test expiration of files older then the max storage time defined for the trash | ||
|
@@ -267,6 +225,52 @@ public function testExpireOldFilesShared() { | |
$this->verifyArray($filesInTrashUser1AfterDelete, ['user1-2.txt', 'user1-4.txt']); | ||
} | ||
|
||
/** | ||
* test expiration of files older then the max storage time defined for the trash | ||
*/ | ||
public function testExpireOldFiles() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What a weird coincidence. Some of my test was affected by this one in another location. The reason was that a test disabled the trashbin permanently which made other tests fail. Ref: #27042 (comment) Anyway, I'm fine leaving this as is to not waste more time with old cruddy tests. |
||
|
||
$currentTime = time(); | ||
$expireAt = $currentTime - 2 * 24 * 60 * 60; | ||
$expiredDate = $currentTime - 3 * 24 * 60 * 60; | ||
|
||
// create some files | ||
\OC\Files\Filesystem::file_put_contents('file1.txt', 'file1'); | ||
\OC\Files\Filesystem::file_put_contents('file2.txt', 'file2'); | ||
\OC\Files\Filesystem::file_put_contents('file3.txt', 'file3'); | ||
|
||
// delete them so that they end up in the trash bin | ||
\OC\Files\Filesystem::unlink('file1.txt'); | ||
\OC\Files\Filesystem::unlink('file2.txt'); | ||
\OC\Files\Filesystem::unlink('file3.txt'); | ||
|
||
//make sure that files are in the trash bin | ||
$filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'name'); | ||
$this->assertSame(3, count($filesInTrash)); | ||
|
||
// every second file will get a date in the past so that it will get expired | ||
$manipulatedList = $this->manipulateDeleteTime($filesInTrash, $this->trashRoot1, $expiredDate); | ||
|
||
$testClass = new TrashbinForTesting(); | ||
list($sizeOfDeletedFiles, $count) = $testClass->dummyDeleteExpiredFiles($manipulatedList, $expireAt); | ||
|
||
$this->assertSame(10, $sizeOfDeletedFiles); | ||
$this->assertSame(2, $count); | ||
|
||
// only file2.txt should be left | ||
$remainingFiles = array_slice($manipulatedList, $count); | ||
$this->assertSame(1, count($remainingFiles)); | ||
$remainingFile = reset($remainingFiles); | ||
$this->assertSame('file2.txt', $remainingFile['name']); | ||
|
||
// check that file1.txt and file3.txt was really deleted | ||
$newTrashContent = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1); | ||
$this->assertSame(1, count($newTrashContent)); | ||
$element = reset($newTrashContent); | ||
$this->assertSame('file2.txt', $element['name']); | ||
} | ||
|
||
|
||
/** | ||
* verify that the array contains the expected results | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why no direct equality ?