diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs b/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs index 5ad7f9cc51..b41b0d2683 100644 --- a/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs +++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using NUnit.Framework; using Umbraco.Core; @@ -183,15 +184,28 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings public void AllowedUploadFiles() { Assert.IsTrue(SettingsSection.Content.AllowedUploadFiles.All(x => "jpg,gif,png".Split(',').Contains(x))); - } - + } + [Test] - public void IsFileAllowedForUpload_WithWhitelist() + [TestCase("png", true)] + [TestCase("jpg", true)] + [TestCase("gif", true)] + [TestCase("bmp", false)] + [TestCase("php", false)] + [TestCase("ashx", false)] + [TestCase("config", false)] + public void IsFileAllowedForUpload_WithWhitelist(string extension, bool expected) { - Assert.IsTrue(SettingsSection.Content.IsFileAllowedForUpload("png")); - // TODO: why does this fail on the build server but not locally? - //Assert.IsFalse(SettingsSection.Content.IsFileAllowedForUpload("bmp")); - Assert.IsFalse(SettingsSection.Content.IsFileAllowedForUpload("php")); + Debug.WriteLine("AllowedUploadFiles: {0}", SettingsSection.Content.AllowedUploadFiles); + Debug.WriteLine("DisallowedUploadFiles: {0}", SettingsSection.Content.DisallowedUploadFiles); + + var allowedContainsExtension = SettingsSection.Content.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)); + var disallowedContainsExtension = SettingsSection.Content.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)); + + Debug.WriteLine("AllowedContainsBmp: {0}", allowedContainsExtension); + Debug.WriteLine("DisallowedContainsBmp: {0}", disallowedContainsExtension); + + Assert.AreEqual(SettingsSection.Content.IsFileAllowedForUpload(extension), expected); } } }