From 9dcc96767239bec55dfa6f7a5da3b336f23b18c2 Mon Sep 17 00:00:00 2001
From: "mohit.bansal623" <mohitbansal623@3540187.no-reply.drupal.org>
Date: Sat, 18 Sep 2021 00:57:02 +0000
Subject: [PATCH] Issue #3236255 by mohit.bansal623: Remove rebuildAll from
 FileUploadtest where possible

---
 .../jsonapi/tests/src/Functional/FileUploadTest.php        | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php b/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
index 8f311b17d647..bbce0675d6e0 100644
--- a/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
+++ b/core/modules/jsonapi/tests/src/Functional/FileUploadTest.php
@@ -608,7 +608,6 @@ public function testFileUploadMaliciousExtension() {
     // Allow all file uploads but system.file::allow_insecure_uploads is set to
     // FALSE.
     $this->field->setSetting('file_extensions', '')->save();
-    $this->rebuildAll();
 
     $this->setUpAuthorization('POST');
     $this->config('jsonapi.settings')->set('read_only', FALSE)->save(TRUE);
@@ -630,7 +629,6 @@ public function testFileUploadMaliciousExtension() {
     // Add .php and .txt as allowed extensions. Since 'allow_insecure_uploads'
     // is FALSE, .php files should be renamed to have a .txt extension.
     $this->field->setSetting('file_extensions', 'php txt')->save();
-    $this->rebuildAll();
 
     $response = $this->fileRequest($uri, $php_string, ['Content-Disposition' => 'filename="example_2.php"']);
     $expected = $this->getExpectedDocument(2, 'example_2.php_.txt', TRUE);
@@ -643,7 +641,6 @@ public function testFileUploadMaliciousExtension() {
     // Allow .doc file uploads and ensure even a mis-configured apache will not
     // fallback to php because the filename will be munged.
     $this->field->setSetting('file_extensions', 'doc')->save();
-    $this->rebuildAll();
 
     // Test using a masked exploit file.
     $response = $this->fileRequest($uri, $php_string, ['Content-Disposition' => 'filename="example_3.php.doc"']);
@@ -660,7 +657,6 @@ public function testFileUploadMaliciousExtension() {
     // Test that a dangerous extension such as .php is munged even if it is in
     // the list of allowed extensions.
     $this->field->setSetting('file_extensions', 'doc php')->save();
-    $this->rebuildAll();
 
     // Test using a masked exploit file.
     $response = $this->fileRequest($uri, $php_string, ['Content-Disposition' => 'filename="example_4.php.doc"']);
@@ -676,7 +672,6 @@ public function testFileUploadMaliciousExtension() {
 
     // Dangerous extensions are munged even when all extensions are allowed.
     $this->field->setSetting('file_extensions', '')->save();
-    $this->rebuildAll();
     $response = $this->fileRequest($uri, $php_string, ['Content-Disposition' => 'filename="example_5.php.png"']);
     $expected = $this->getExpectedDocument(5, 'example_5.php_.png', TRUE);
     // Override the expected filesize.
@@ -699,8 +694,6 @@ public function testFileUploadMaliciousExtension() {
     // Add .php as an allowed extension without .txt. Since insecure uploads are
     // are not allowed, .php files will be rejected.
     $this->field->setSetting('file_extensions', 'php')->save();
-    $this->rebuildAll();
-
     $response = $this->fileRequest($uri, $php_string, ['Content-Disposition' => 'filename="example_7.php"']);
     $this->assertResourceErrorResponse(422, "Unprocessable Entity: file validation failed.\nFor security reasons, your upload has been rejected.", $uri, $response);
 
-- 
GitLab