diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs
index becf68bd24..332de45734 100644
--- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs
+++ b/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class ContentElement : UmbracoConfigurationElement, IContentSection
{
- private const string DefaultPreviewBadge = @"In Preview Mode - click to end";
+ private const string DefaultPreviewBadge = @"In Preview Mode - click to end";
[ConfigurationProperty("imaging")]
internal ContentImagingElement Imaging => (ContentImagingElement) this["imaging"];
diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs b/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs
index 0c52caf70f..f1ac463305 100644
--- a/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs
+++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/ContentElementTests.cs
@@ -16,28 +16,28 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public void EmailAddress()
{
- Assert.IsTrue(SettingsSection.Content.NotificationEmailAddress == "robot@umbraco.dk");
+ Assert.AreEqual(SettingsSection.Content.NotificationEmailAddress, "robot@umbraco.dk");
}
[Test]
public virtual void DisableHtmlEmail()
{
- Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail == true);
+ Assert.IsTrue(SettingsSection.Content.DisableHtmlEmail);
}
[Test]
public virtual void Can_Set_Multiple()
{
- Assert.IsTrue(SettingsSection.Content.Error404Collection.Count() == 3);
- Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).Culture == "default");
- Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId == 1047);
+ Assert.AreEqual(SettingsSection.Content.Error404Collection.Count(), 3);
+ Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).Culture, "default");
+ Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(0).ContentId, 1047);
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentId);
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(0).HasContentKey);
- Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(1).Culture == "en-US");
- Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(1).ContentXPath == "$site/error [@name = 'error']");
+ Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).Culture, "en-US");
+ Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(1).ContentXPath, "$site/error [@name = 'error']");
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentId);
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(1).HasContentKey);
- Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).Culture == "en-UK");
- Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).ContentKey == new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC"));
+ Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).Culture, "en-UK");
+ Assert.AreEqual(SettingsSection.Content.Error404Collection.ElementAt(2).ContentKey, new Guid("8560867F-B88F-4C74-A9A4-679D8E5B3BFC"));
Assert.IsTrue(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentKey);
Assert.IsFalse(SettingsSection.Content.Error404Collection.ElementAt(2).HasContentId);
}
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public void ScriptFolderPath()
{
- Assert.IsTrue(SettingsSection.Content.ScriptFolderPath == "/scripts");
+ Assert.AreEqual(SettingsSection.Content.ScriptFolderPath, "/scripts");
}
[Test]
public void ScriptFileTypes()
@@ -55,7 +55,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public void DisableScriptEditor()
{
- Assert.IsTrue(SettingsSection.Content.ScriptEditorDisable == false);
+ Assert.AreEqual(SettingsSection.Content.ScriptEditorDisable, false);
}
[Test]
@@ -71,80 +71,79 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public virtual void ImageAutoFillProperties()
{
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.Count() == 2);
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias == "umbracoFile");
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias == "umbracoWidth");
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias == "umbracoHeight");
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias == "umbracoBytes");
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension");
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).Alias == "umbracoFile2");
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias == "umbracoWidth2");
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias == "umbracoHeight2");
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias == "umbracoBytes2");
- Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias == "umbracoExtension2");
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.Count(), 2);
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).Alias, "umbracoFile");
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).WidthFieldAlias, "umbracoWidth");
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).HeightFieldAlias, "umbracoHeight");
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias, "umbracoBytes");
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias, "umbracoExtension");
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).Alias, "umbracoFile2");
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).WidthFieldAlias, "umbracoWidth2");
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).HeightFieldAlias, "umbracoHeight2");
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).LengthFieldAlias, "umbracoBytes2");
+ Assert.AreEqual(SettingsSection.Content.ImageAutoFillProperties.ElementAt(1).ExtensionFieldAlias, "umbracoExtension2");
}
[Test]
public void UploadAllowDirectories()
{
- Assert.IsTrue(SettingsSection.Content.UploadAllowDirectories == true);
+ Assert.IsTrue(SettingsSection.Content.UploadAllowDirectories);
}
[Test]
public void DefaultDocumentTypeProperty()
{
- Assert.IsTrue(SettingsSection.Content.DefaultDocumentTypeProperty == "Textstring");
+ Assert.AreEqual(SettingsSection.Content.DefaultDocumentTypeProperty, "Textstring");
}
[Test]
public void GlobalPreviewStorageEnabled()
{
- Assert.IsTrue(SettingsSection.Content.GlobalPreviewStorageEnabled == false);
+ Assert.IsFalse(SettingsSection.Content.GlobalPreviewStorageEnabled);
}
[Test]
public void CloneXmlContent()
{
- Assert.IsTrue(SettingsSection.Content.CloneXmlContent == true);
+ Assert.IsTrue(SettingsSection.Content.CloneXmlContent);
}
[Test]
public void EnsureUniqueNaming()
{
- Assert.IsTrue(SettingsSection.Content.EnsureUniqueNaming == true);
+ Assert.IsTrue(SettingsSection.Content.EnsureUniqueNaming);
}
-
[Test]
public void ForceSafeAliases()
{
- Assert.IsTrue(SettingsSection.Content.ForceSafeAliases == true);
+ Assert.IsTrue(SettingsSection.Content.ForceSafeAliases);
}
[Test]
public void XmlCacheEnabled()
{
- Assert.IsTrue(SettingsSection.Content.XmlCacheEnabled == true);
+ Assert.IsTrue(SettingsSection.Content.XmlCacheEnabled);
}
[Test]
public void ContinouslyUpdateXmlDiskCache()
{
- Assert.IsTrue(SettingsSection.Content.ContinouslyUpdateXmlDiskCache == true);
+ Assert.IsTrue(SettingsSection.Content.ContinouslyUpdateXmlDiskCache);
}
[Test]
public virtual void XmlContentCheckForDiskChanges()
{
- Assert.IsTrue(SettingsSection.Content.XmlContentCheckForDiskChanges == true);
+ Assert.IsTrue(SettingsSection.Content.XmlContentCheckForDiskChanges);
}
[Test]
public void EnableSplashWhileLoading()
{
- Assert.IsTrue(SettingsSection.Content.EnableSplashWhileLoading == false);
+ Assert.IsFalse(SettingsSection.Content.EnableSplashWhileLoading);
}
[Test]
public void PropertyContextHelpOption()
{
- Assert.IsTrue(SettingsSection.Content.PropertyContextHelpOption == "text");
+ Assert.AreEqual(SettingsSection.Content.PropertyContextHelpOption, "text");
}
[Test]
public void PreviewBadge()
{
- Assert.IsTrue(SettingsSection.Content.PreviewBadge == @"In Preview Mode - click to end");
+ Assert.AreEqual(SettingsSection.Content.PreviewBadge, @"In Preview Mode - click to end");
}
[Test]
public void ResolveUrlsFromTextString()
@@ -154,7 +153,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
[Test]
public void MacroErrors()
{
- Assert.IsTrue(SettingsSection.Content.MacroErrorBehaviour == MacroErrorBehaviour.Inline);
+ Assert.AreEqual(SettingsSection.Content.MacroErrorBehaviour, MacroErrorBehaviour.Inline);
}
[Test]
diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/umbracoSettings.config b/src/Umbraco.Tests/Configurations/UmbracoSettings/umbracoSettings.config
index 08f1c94e21..a436dad9f5 100644
--- a/src/Umbraco.Tests/Configurations/UmbracoSettings/umbracoSettings.config
+++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/umbracoSettings.config
@@ -75,7 +75,10 @@
true
- In Preview Mode - click to end]]>
+
+ In Preview Mode - click to end
+ ]]>
- In Preview Mode - click to end]]>
+ In Preview Mode - click to end
+ ]]>
- In Preview Mode - click to end
+ In Preview Mode - click to end
]]>
diff --git a/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesResolver.cs
index c268af2be7..9f6747ea95 100644
--- a/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesResolver.cs
+++ b/src/Umbraco.Web/Models/Mapping/MemberTabsAndPropertiesResolver.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
using System.Web.Security;
using AutoMapper;
@@ -28,7 +29,7 @@ namespace Umbraco.Web.Models.Mapping
private readonly IUserService _userService;
public MemberTabsAndPropertiesResolver(IUmbracoContextAccessor umbracoContextAccessor, ILocalizedTextService localizedTextService, IMemberService memberService, IUserService userService)
- : base(umbracoContextAccessor, localizedTextService)
+ : base(localizedTextService)
{
_umbracoContextAccessor = umbracoContextAccessor ?? throw new System.ArgumentNullException(nameof(umbracoContextAccessor));
_localizedTextService = localizedTextService ?? throw new System.ArgumentNullException(nameof(localizedTextService));
@@ -37,7 +38,7 @@ namespace Umbraco.Web.Models.Mapping
}
public MemberTabsAndPropertiesResolver(IUmbracoContextAccessor umbracoContextAccessor, ILocalizedTextService localizedTextService, IEnumerable ignoreProperties, IMemberService memberService, IUserService userService)
- : base(umbracoContextAccessor, localizedTextService, ignoreProperties)
+ : base(localizedTextService, ignoreProperties)
{
_umbracoContextAccessor = umbracoContextAccessor ?? throw new System.ArgumentNullException(nameof(umbracoContextAccessor));
_localizedTextService = localizedTextService ?? throw new System.ArgumentNullException(nameof(localizedTextService));
@@ -169,24 +170,25 @@ namespace Umbraco.Web.Models.Mapping
///
/// Overridden to assign the IsSensitive property values
///
- ///
///
///
///
///
- protected override List MapProperties(UmbracoContext umbracoContext, IContentBase content, List properties, ResolutionContext context)
+ protected override List MapProperties(IContentBase content, List properties, ResolutionContext context)
{
- var result = base.MapProperties(umbracoContext, content, properties, context);
+ var result = base.MapProperties(content, properties, context);
var member = (IMember)content;
var memberType = member.ContentType;
+ var umbracoContext = _umbracoContextAccessor.UmbracoContext;
+
//now update the IsSensitive value
foreach (var prop in result)
{
//check if this property is flagged as sensitive
var isSensitiveProperty = memberType.IsSensitiveProperty(prop.Alias);
//check permissions for viewing sensitive data
- if (isSensitiveProperty && umbracoContext.Security.CurrentUser.HasAccessToSensitiveData() == false)
+ if (isSensitiveProperty && (umbracoContext == null || umbracoContext.Security.CurrentUser.HasAccessToSensitiveData() == false))
{
//mark this property as sensitive
prop.IsSensitive = true;
diff --git a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs
index 44d69ad32e..ff55b3334e 100644
--- a/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs
+++ b/src/Umbraco.Web/Models/Mapping/TabsAndPropertiesResolver.cs
@@ -164,7 +164,6 @@ namespace Umbraco.Web.Models.Mapping
///
/// Maps properties on to the generic properties tab
///
- ///
///
///
///
@@ -172,14 +171,14 @@ namespace Umbraco.Web.Models.Mapping
/// The generic properties tab is responsible for
/// setting up the properties such as Created date, updated date, template selected, etc...
///
- protected virtual void MapGenericProperties(UmbracoContext umbracoContext, IContentBase content, List> tabs, ResolutionContext context)
+ protected virtual void MapGenericProperties(IContentBase content, List> tabs, ResolutionContext context)
{
// add the generic properties tab, for properties that don't belong to a tab
// get the properties, map and translate them, then add the tab
var noGroupProperties = content.GetNonGroupedProperties()
.Where(x => IgnoreProperties.Contains(x.Alias) == false) // skip ignored
.ToList();
- var genericproperties = MapProperties(umbracoContext, content, noGroupProperties, context);
+ var genericproperties = MapProperties(content, noGroupProperties, context);
tabs.Add(new Tab
{
@@ -225,12 +224,11 @@ namespace Umbraco.Web.Models.Mapping
///
/// Maps a list of to a list of
///
- ///
///
///
///
///
- protected virtual List MapProperties(UmbracoContext umbracoContext, IContentBase content, List properties, ResolutionContext context)
+ protected virtual List MapProperties(IContentBase content, List properties, ResolutionContext context)
{
//we need to map this way to pass the context through, I don't like it but we'll see what AutoMapper says: https://github.com/AutoMapper/AutoMapper/issues/2588
var result = context.Mapper.Map, IEnumerable>(
@@ -250,25 +248,18 @@ namespace Umbraco.Web.Models.Mapping
internal class TabsAndPropertiesResolver : TabsAndPropertiesResolver, IValueResolver>>
where TSource : IContentBase
{
- private readonly IUmbracoContextAccessor _umbracoContextAccessor;
-
- public TabsAndPropertiesResolver(IUmbracoContextAccessor umbracoContextAccessor, ILocalizedTextService localizedTextService)
+ public TabsAndPropertiesResolver(ILocalizedTextService localizedTextService)
: base(localizedTextService)
{
- _umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
}
- public TabsAndPropertiesResolver(IUmbracoContextAccessor umbracoContextAccessor, ILocalizedTextService localizedTextService, IEnumerable ignoreProperties)
+ public TabsAndPropertiesResolver(ILocalizedTextService localizedTextService, IEnumerable ignoreProperties)
: base(localizedTextService, ignoreProperties)
{
- _umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor));
}
public virtual IEnumerable> Resolve(TSource source, TDestination destination, IEnumerable> destMember, ResolutionContext context)
{
- var umbracoContext = _umbracoContextAccessor.UmbracoContext;
- if (umbracoContext == null) throw new InvalidOperationException("Cannot resolve value without an UmbracoContext available");
-
var tabs = new List>();
// add the tabs, for properties that belong to a tab
@@ -293,7 +284,7 @@ namespace Umbraco.Web.Models.Mapping
continue;
//map the properties
- var mappedProperties = MapProperties(umbracoContext, source, properties, context);
+ var mappedProperties = MapProperties(source, properties, context);
// add the tab
// we need to pick an identifier... there is no "right" way...
@@ -311,7 +302,7 @@ namespace Umbraco.Web.Models.Mapping
});
}
- MapGenericProperties(umbracoContext, source, tabs, context);
+ MapGenericProperties(source, tabs, context);
// activate the first tab, if any
if (tabs.Count > 0)