diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/FolderManagerTests.cs b/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/FolderManagerTests.cs index 397ea91f42c..49801b4a42b 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/FolderManagerTests.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Core/Providers/Folder/FolderManagerTests.cs @@ -186,6 +186,54 @@ public void AddFolder_Throws_When_Folder_Already_Exists() } + [Test] + [ExpectedException(typeof(InvalidFolderPathException))] + public void AddFolder_Throws_When_FolderPath_Is_Invalid() + { + // arrange + var folderMapping = new FolderMappingInfo + { + PortalID = Constants.CONTENT_ValidPortalId + }; + + _mockFolderManager + .Setup(mfm => mfm.FolderExists(It.IsAny(), It.IsAny())) + .Returns(false); + + _mockFolderManager + .Setup(mfm => mfm.IsValidFolderPath(It.IsAny())) + .Returns(false); + + // act + _mockFolderManager.Object.AddFolder(folderMapping, Constants.FOLDER_ValidSubFolderRelativePath); + + // assert (implicit) + } + + [Test] + public void IsValidFolderPath_Returns_True_When_FolderPath_Is_Valid() + { + // arrange (implicit) + + // act + var result = _mockFolderManager.Object.IsValidFolderPath(Constants.FOLDER_ValidSubFolderRelativePath); + + // assert + Assert.IsTrue(result); + } + + [Test] + public void IsValidFolderPath_Returns_False_When_FolderPath_Is_Invalid() + { + // arrange (implicit) + + // act + var result = _mockFolderManager.Object.IsValidFolderPath(Constants.FOLDER_InvalidSubFolderRelativePath); + + // assert + Assert.IsFalse(result); + } + #endregion #region DeleteFolder diff --git a/DNN Platform/Tests/DotNetNuke.Tests.Utilities/Constants.cs b/DNN Platform/Tests/DotNetNuke.Tests.Utilities/Constants.cs index 7e1ae971258..712859f0f11 100644 --- a/DNN Platform/Tests/DotNetNuke.Tests.Utilities/Constants.cs +++ b/DNN Platform/Tests/DotNetNuke.Tests.Utilities/Constants.cs @@ -343,6 +343,7 @@ public class Constants public const string FOLDER_ValidSubFolderName = "subfolder"; public const string FOLDER_ValidSubFolderPath = "C:\\folder\\subfolder"; public const string FOLDER_ValidSubFolderRelativePath = "folder/subfolder/"; + public const string FOLDER_InvalidSubFolderRelativePath = "folder/subfolder/../"; public const string FOLDER_ValidUNCFolderPath = @"\\SERVER\folder"; public const string FOLDER_ValidUNCSubFolderPath = @"\\SERVER\folder\subfolder"; public const string FOLDER_ValidZipFileName = "file.zip";