diff --git a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/ContentElementDefaultTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/ContentElementDefaultTests.cs index 6fb4aac460..432a466355 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/ContentElementDefaultTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/ContentElementDefaultTests.cs @@ -1,15 +1,15 @@ -using System.Linq; +using System; +using System.Linq; using NUnit.Framework; +using Umbraco.Core; +using Umbraco.Core.Configuration.UmbracoSettings; namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings { [TestFixture] public class ContentElementDefaultTests : ContentElementTests { - protected override bool TestingDefaults - { - get { return true; } - } + protected override bool TestingDefaults => true; [Test] public override void DisableHtmlEmail() @@ -36,5 +36,34 @@ namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings Assert.IsTrue(ContentSettings.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension"); } + /// + /// Whitelist is empty in default settings file and is not populated by default, but disallowed is empty and is populated by default + /// + /// + /// + [Test] + [TestCase("png", true)] + [TestCase("jpg", true)] + [TestCase("gif", true)] + [TestCase("bmp", true)] + [TestCase("php", true)] + [TestCase("ashx", false)] + [TestCase("config", false)] + public override void IsFileAllowedForUpload_WithWhitelist(string extension, bool expected) + { + TestContext.WriteLine("Extension being tested: {0}", extension); + TestContext.WriteLine("Expected IsAllowed?: {0}", expected); + TestContext.WriteLine("AllowedUploadFiles: {0}", ContentSettings.AllowedUploadFiles); + TestContext.WriteLine("DisallowedUploadFiles: {0}", ContentSettings.DisallowedUploadFiles); + + bool allowedContainsExtension = ContentSettings.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)); + bool disallowedContainsExtension = ContentSettings.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)); + + TestContext.WriteLine("AllowedContainsExtension: {0}", allowedContainsExtension); + TestContext.WriteLine("DisallowedContainsExtension: {0}", disallowedContainsExtension); + + Assert.AreEqual(expected, ContentSettings.IsFileAllowedForUpload(extension)); + } + } } diff --git a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/ContentElementTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/ContentElementTests.cs index 5c9c457993..7ac3130b1a 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/ContentElementTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/ContentElementTests.cs @@ -94,25 +94,22 @@ namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings [TestCase("png", true)] [TestCase("jpg", true)] [TestCase("gif", true)] - // TODO: Why does it flip to TestingDefaults=true for these two tests on AppVeyor. WHY? - //[TestCase("bmp", false)] - //[TestCase("php", false)] + [TestCase("bmp", false)] + [TestCase("php", false)] [TestCase("ashx", false)] [TestCase("config", false)] - public void IsFileAllowedForUpload_WithWhitelist(string extension, bool expected) + public virtual void IsFileAllowedForUpload_WithWhitelist(string extension, bool expected) { - // Make really sure that defaults are NOT used - TestingDefaults = false; + Console.WriteLine("Extension being tested: {0}", extension); + Console.WriteLine("Expected IsAllowed?: {0}", expected); + Console.WriteLine("AllowedUploadFiles: {0}", ContentSettings.AllowedUploadFiles); + Console.WriteLine("DisallowedUploadFiles: {0}", ContentSettings.DisallowedUploadFiles); - Debug.WriteLine("Extension being tested", extension); - Debug.WriteLine("AllowedUploadFiles: {0}", ContentSettings.AllowedUploadFiles); - Debug.WriteLine("DisallowedUploadFiles: {0}", ContentSettings.DisallowedUploadFiles); + bool allowedContainsExtension = ContentSettings.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)); + bool disallowedContainsExtension = ContentSettings.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)); - var allowedContainsExtension = ContentSettings.AllowedUploadFiles.Any(x => x.InvariantEquals(extension)); - var disallowedContainsExtension = ContentSettings.DisallowedUploadFiles.Any(x => x.InvariantEquals(extension)); - - Debug.WriteLine("AllowedContainsExtension: {0}", allowedContainsExtension); - Debug.WriteLine("DisallowedContainsExtension: {0}", disallowedContainsExtension); + Console.WriteLine("AllowedContainsExtension: {0}", allowedContainsExtension); + Console.WriteLine("DisallowedContainsExtension: {0}", disallowedContainsExtension); Assert.AreEqual(expected, ContentSettings.IsFileAllowedForUpload(extension)); } diff --git a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/LoggingElementDefaultTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/LoggingElementDefaultTests.cs index d4681e9896..084c649f11 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/LoggingElementDefaultTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/LoggingElementDefaultTests.cs @@ -5,10 +5,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings [TestFixture] public class LoggingElementDefaultTests : LoggingElementTests { - protected override bool TestingDefaults - { - get { return true; } - } + protected override bool TestingDefaults => true; [Test] public override void MaxLogAge() diff --git a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/RequestHandlerElementDefaultTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/RequestHandlerElementDefaultTests.cs index 55c1c02bf2..c2e21c5e2c 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/RequestHandlerElementDefaultTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/RequestHandlerElementDefaultTests.cs @@ -5,9 +5,6 @@ namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings [TestFixture] public class RequestHandlerElementDefaultTests : RequestHandlerElementTests { - protected override bool TestingDefaults - { - get { return true; } - } + protected override bool TestingDefaults => true; } } diff --git a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/SecurityElementDefaultTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/SecurityElementDefaultTests.cs index e180aec496..f5566df5ed 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/SecurityElementDefaultTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/SecurityElementDefaultTests.cs @@ -5,9 +5,6 @@ namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings [TestFixture] public class SecurityElementDefaultTests : SecurityElementTests { - protected override bool TestingDefaults - { - get { return true; } - } + protected override bool TestingDefaults => true; } } diff --git a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/WebRoutingElementDefaultTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/WebRoutingElementDefaultTests.cs index 932b0e22e3..e85911d559 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/WebRoutingElementDefaultTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Configuration/UmbracoSettings/WebRoutingElementDefaultTests.cs @@ -5,11 +5,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Configuration.UmbracoSettings [TestFixture] public class WebRoutingElementDefaultTests : WebRoutingElementTests { - - protected override bool TestingDefaults - { - get { return true; } - } + protected override bool TestingDefaults => true; [Test] public override void UrlProviderMode()