deleted old files

This commit is contained in:
Peter Papp
2021-07-28 18:33:13 +02:00
parent 71a1eb8e7c
commit 6a805b03fa
14 changed files with 9 additions and 361 deletions
-9
View File
@@ -264,11 +264,6 @@ class AdminTest extends TestCase
$user->favouriteFolders()->attach($folder->id);
});
// Create zips
Zip::factory(Zip::class)
->count(2)
->create(['user_id' => $user->id]);
// Create shares
Share::factory(Share::class)
->count(2)
@@ -334,10 +329,6 @@ class AdminTest extends TestCase
'user_id' => $user->id,
]);
$this->assertDatabaseMissing('zips', [
'user_id' => $user->id,
]);
$file_ids
->each(function ($id, $index) use ($user) {
Storage::disk('local')
-56
View File
@@ -97,30 +97,6 @@ class ContentAccessTest extends TestCase
->assertStatus(200);
}
/**
* @test
*/
public function it_get_private_user_zip()
{
$user = User::factory(User::class)
->create();
$file = UploadedFile::fake()
->create('archive.zip', 2000, 'application/zip');
Storage::putFileAs('zip', $file, 'EHWKcuvKzA4Gv29v-archive.zip');
$zip = Zip::factory(Zip::class)->create([
'basename' => 'EHWKcuvKzA4Gv29v-archive.zip',
'user_id' => $user->id,
]);
$this
->actingAs($user)
->get("zip/$zip->id")
->assertOk();
}
/**
* @test
*/
@@ -175,29 +151,6 @@ class ContentAccessTest extends TestCase
->assertStatus(404);
}
/**
* @test
*/
public function logged_user_try_to_get_another_private_user_zip()
{
$user = User::factory(User::class)
->create();
$file = UploadedFile::fake()
->create('archive.zip', 2000, 'application/zip');
Storage::putFileAs('zip', $file, 'EHWKcuvKzA4Gv29v-archive.zip');
$zip = Zip::factory(Zip::class)->create([
'basename' => 'EHWKcuvKzA4Gv29v-archive.zip',
]);
$this
->actingAs($user)
->get("zip/$zip->id")
->assertNotFound();
}
/**
* @test
*/
@@ -207,15 +160,6 @@ class ContentAccessTest extends TestCase
->assertRedirect();
}
/**
* @test
*/
public function guest_try_to_get_private_user_zip()
{
$this->get('zip/EHWKcuvKzA4Gv29v-archive.zip')
->assertRedirect();
}
/**
* @test
*/
@@ -186,57 +186,4 @@ class VisitorAccessToItemsTest extends TestCase
]);
});
}
/**
* @test
*/
public function it_download_publicly_zipped_files()
{
collect([true, false])
->each(function ($is_protected) {
$user = User::factory(User::class)
->create();
$share = Share::factory(Share::class)
->create([
'user_id' => $user->id,
'type' => 'folder',
'is_protected' => $is_protected,
]);
$zip = Zip::factory(Zip::class)->create([
'basename' => 'EHWKcuvKzA4Gv29v-archive.zip',
'user_id' => $user->id,
'shared_token' => $share->token,
]);
$file = UploadedFile::fake()
->create($zip->basename, 1000, 'application/zip');
Storage::putFileAs('zip', $file, $file->name);
if ($is_protected) {
$cookie = [
'share_session' => json_encode([
'token' => $share->token,
'authenticated' => true,
]),
];
$this->withCookies($cookie)
->get("/zip/$zip->id/$share->token")
->assertStatus(200);
}
if (! $is_protected) {
$this->get("/zip/$zip->id/$share->token")
->assertStatus(200);
}
$this->assertDatabaseMissing('traffic', [
'user_id' => $user->id,
'download' => null,
]);
});
}
}
-27
View File
@@ -4,10 +4,8 @@ namespace Tests\Support\Scheduler;
use Storage;
use Tests\TestCase;
use App\Users\Models\User;
use Domain\Zip\Models\Zip;
use Domain\Sharing\Models\Share;
use Illuminate\Http\UploadedFile;
use Support\Scheduler\Actions\DeleteOldZipsAction;
use Support\Scheduler\Actions\DeleteFailedFilesAction;
use Support\Scheduler\Actions\DeleteUnverifiedUsersAction;
use Support\Scheduler\Actions\DeleteExpiredShareLinksAction;
@@ -32,31 +30,6 @@ class SchedulerTest extends TestCase
]);
}
/**
* @test
*/
public function it_delete_zips_older_than_one_day()
{
$file = UploadedFile::fake()
->create('archive.zip', 2000, 'application/zip');
Storage::putFileAs('zip', $file, 'EHWKcuvKzA4Gv29v-archive.zip');
$zip = Zip::factory(Zip::class)->create([
'basename' => 'EHWKcuvKzA4Gv29v-archive.zip',
'created_at' => now()->subDay(),
]);
resolve(DeleteOldZipsAction::class)();
$this->assertDatabaseMissing('zips', [
'id' => $zip->id,
]);
Storage::disk('local')
->assertMissing('zip/EHWKcuvKzA4Gv29v-archive.zip');
}
/**
* @test
*/