Auto property for default settings. We needed the defaults for testing, but removed comment re appveyor because these tests failed on my local too, since these were not being set accurately as the default settings had no whitelist and therefore the logic was altered from false to true. Write to TestContext not debug.
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whitelist is empty in default settings file and is not populated by default, but disallowed is empty and is populated by default
|
||||
/// </summary>
|
||||
/// <param name="extension"></param>
|
||||
/// <param name="expected"></param>
|
||||
[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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user