Static files: Fix tree to only provide items from expected folders (closes #20962) (#21001)

* Applies checks for root folders to static file tree service.

* Add integration tests.

* Fix ancestor test.

* Amends from code review.

* Integration test compatibility suppressions.

* Reverted breaking change in test base class.

(cherry picked from commit 84c15ff4d7)
This commit is contained in:
Andy Butland
2025-12-02 10:20:08 +09:00
committed by Zeegaan
parent f408d2a1b3
commit 706ac2d8f6
10 changed files with 229 additions and 39 deletions

View File

@@ -36,21 +36,23 @@ public abstract class FileSystemTreeServiceTestsBase : UmbracoIntegrationTest
GetStylesheetsFileSystem(),
GetScriptsFileSystem(),
null);
CreateFiles();
}
protected virtual void CreateFiles()
{
for (int i = 0; i < 10; i++)
{
using var stream = CreateStream(Path.Join("tests"));
using var stream = CreateStream();
TestFileSystem.AddFile($"file{i}{FileExtension}", stream);
}
}
protected static Stream CreateStream(string contents = null)
{
if (string.IsNullOrEmpty(contents))
{
contents = "/* test */";
}
var bytes = Encoding.UTF8.GetBytes(contents);
const string DefaultFileContent = "/* test */";
var bytes = Encoding.UTF8.GetBytes(contents ?? DefaultFileContent);
return new MemoryStream(bytes);
}