createOne(); $response = $this->get(route('dump.show', ['dump' => $dump])); $response->assertForbidden(); } /** * Unsafe dumps shall be forbidden. */ public function testDumpDownloadingForbiddenForUnsafeDumps(): void { Feature::activate(AllowDumpDownloading::class); $dump = Dump::factory() ->unsafe() ->createOne(); $response = $this->get(route('dump.show', ['dump' => $dump])); $response->assertForbidden(); } /** * Users with the bypass feature flag permission shall be permitted to download dumps * even if the Allow Dump Downloading feature is disabled. */ public function testVideoStreamingPermittedForBypass(): void { Feature::activate(AllowDumpDownloading::class, $this->faker->boolean()); $fs = Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); $filename = Dump::factory()->makeOne()->path.'.sql'; $file = File::fake()->create($filename); $fsFile = $fs->putFileAs('', $file, $filename); $dump = Dump::factory()->createOne([ Dump::ATTRIBUTE_PATH => $fsFile, ]); $user = User::factory()->withPermissions(SpecialPermission::BYPASS_FEATURE_FLAGS->value)->createOne(); Sanctum::actingAs($user); $response = $this->get(route('dump.show', ['dump' => $dump])); $response->assertDownload($dump->path); } /** * If dump downloading is enabled, the dump is downloaded from storage through the response. */ public function testDownloadedThroughResponse(): void { Feature::activate(AllowDumpDownloading::class); $fs = Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); $filename = Dump::factory()->makeOne()->path.'.sql'; $file = File::fake()->create($filename); $fsFile = $fs->putFileAs('', $file, $filename); $dump = Dump::factory()->createOne([ Dump::ATTRIBUTE_PATH => $fsFile, ]); $response = $this->get(route('dump.show', ['dump' => $dump])); $response->assertDownload($dump->path); } }