-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Static files: Fix tree to only provide items from expected folders (closes #20962) #21001
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
Merged
Zeegaan
merged 7 commits into
main
from
v17/bugfix/apply-root-folders-to-static-file-tree
Dec 2, 2025
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e079358
Applies checks for root folders to static file tree service.
AndyButland 11327c0
Add integration tests.
AndyButland 835cbf2
Fix ancestor test.
AndyButland 48e9c21
Amends from code review.
AndyButland a60852c
Integration test compatibility suppressions.
AndyButland 6219d05
Merge branch 'main' into v17/bugfix/apply-root-folders-to-static-file…
AndyButland d7609a9
Reverted breaking change in test base class.
AndyButland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...raco.Tests.Integration/ManagementApi/Services/Trees/PhysicalFileSystemTreeServiceTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| using System.IO; | ||
| using Microsoft.Extensions.Logging; | ||
| using NUnit.Framework; | ||
| using Umbraco.Cms.Api.Management.Services.FileSystem; | ||
| using Umbraco.Cms.Api.Management.ViewModels.Tree; | ||
| using Umbraco.Cms.Core.IO; | ||
|
|
||
| namespace Umbraco.Cms.Tests.Integration.ManagementApi.Services.Trees; | ||
|
|
||
| public class PhysicalFileSystemTreeServiceTests : FileSystemTreeServiceTestsBase | ||
| { | ||
| protected override string FileExtension { get; set; } = string.Empty; | ||
|
|
||
| protected override string FileSystemPath => "/"; | ||
|
|
||
| protected override void CreateFiles() | ||
| { | ||
| var paths = new[] | ||
| { | ||
| Path.Join("App_Plugins", "test-extension", "test.js"), | ||
| Path.Join("wwwroot", "css", "test.css"), | ||
| Path.Join("wwwroot", "css", "test2.css"), | ||
| Path.Join("wwwroot", "css", "test3.css"), | ||
| Path.Join("wwwroot", "css", "test4.css"), | ||
| Path.Join("Program.cs"), | ||
| }; | ||
| foreach (var path in paths) | ||
| { | ||
| var stream = CreateStream(); | ||
| TestFileSystem.AddFile(path, stream); | ||
| } | ||
| } | ||
|
|
||
| [Test] | ||
| public void Can_Get_Siblings() | ||
| { | ||
| var service = CreateService(); | ||
|
|
||
| FileSystemTreeItemPresentationModel[] treeModels = service.GetSiblingsViewModels("wwwroot/css/test2.css", 1, 1, out long before, out var after); | ||
|
|
||
| Assert.AreEqual(3, treeModels.Length); | ||
| Assert.AreEqual(treeModels[0].Name, "test.css"); | ||
| Assert.AreEqual(treeModels[1].Name, "test2.css"); | ||
| Assert.AreEqual(treeModels[2].Name, "test3.css"); | ||
| Assert.AreEqual(before, 0); | ||
| Assert.AreEqual(after, 1); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Can_Get_Ancestors() | ||
| { | ||
| var service = CreateService(); | ||
|
|
||
| FileSystemTreeItemPresentationModel[] treeModels = service.GetAncestorModels(Path.Join("wwwroot", "css", "test.css"), true); | ||
|
|
||
| Assert.IsNotEmpty(treeModels); | ||
| Assert.AreEqual(treeModels.Length, 3); | ||
| Assert.AreEqual(treeModels[0].Name, "wwwroot"); | ||
| Assert.AreEqual(treeModels[1].Name, "css"); | ||
| Assert.AreEqual(treeModels[2].Name, "test.css"); | ||
| } | ||
AndyButland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [Test] | ||
| public void Can_Get_Root_PathViewModels() | ||
| { | ||
| var service = CreateService(); | ||
|
|
||
| FileSystemTreeItemPresentationModel[] treeModels = service.GetPathViewModels(string.Empty, 0, int.MaxValue, out var totalItems); | ||
|
|
||
| Assert.IsNotEmpty(treeModels); | ||
| Assert.AreEqual(totalItems, 2); | ||
| Assert.AreEqual(treeModels.Length, totalItems); | ||
| Assert.AreEqual(treeModels[0].Name, "App_Plugins"); | ||
| Assert.AreEqual(treeModels[1].Name, "wwwroot"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Can_Get_Child_PathViewModels() | ||
| { | ||
| var service = CreateService(); | ||
|
|
||
| FileSystemTreeItemPresentationModel[] treeModels = service.GetPathViewModels("App_Plugins/test-extension", 0, int.MaxValue, out var totalItems); | ||
|
|
||
| Assert.IsNotEmpty(treeModels); | ||
| Assert.AreEqual(totalItems, 1); | ||
| Assert.AreEqual(treeModels.Length, totalItems); | ||
| Assert.AreEqual(treeModels[0].Name, "test.js"); | ||
| } | ||
|
|
||
| private PhysicalFileSystemTreeService CreateService() | ||
| { | ||
| var physicalFileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, LoggerFactory.CreateLogger<PhysicalFileSystem>(), HostingEnvironment.MapPathWebRoot(FileSystemPath), HostingEnvironment.ToAbsolute(FileSystemPath)); | ||
| return new PhysicalFileSystemTreeService(physicalFileSystem); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.