updated unit test logic
This commit is contained in:
@@ -35,6 +35,11 @@ namespace Umbraco.Core.Configuration
|
||||
private static volatile string _reservedUrlsCache;
|
||||
private static string _reservedPathsCache;
|
||||
private static StartsWithContainer _reservedList = new StartsWithContainer();
|
||||
private static string _reservedPaths;
|
||||
private static string _reservedUrls;
|
||||
//ensure the built on (non-changeable) reserved paths are there at all times
|
||||
private const string StaticReservedPaths = "~/app_plugins/,~/install/,";
|
||||
private const string StaticReservedUrls = "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd,";
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -44,6 +49,8 @@ namespace Umbraco.Core.Configuration
|
||||
internal static void ResetCache()
|
||||
{
|
||||
_reservedUrlsCache = null;
|
||||
_reservedPaths = null;
|
||||
_reservedUrls = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,16 +60,19 @@ namespace Umbraco.Core.Configuration
|
||||
public static string ReservedUrls
|
||||
{
|
||||
get
|
||||
{
|
||||
//ensure the built on (non-changeable) reserved paths are there at all times
|
||||
const string staticReservedUrls = "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd,";
|
||||
{
|
||||
if (_reservedUrls == null)
|
||||
{
|
||||
var urls = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedUrls")
|
||||
? ConfigurationManager.AppSettings["umbracoReservedUrls"]
|
||||
: string.Empty;
|
||||
|
||||
var urls = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedUrls")
|
||||
? ConfigurationManager.AppSettings["umbracoReservedUrls"]
|
||||
: string.Empty;
|
||||
|
||||
return staticReservedUrls + urls;
|
||||
//ensure the built on (non-changeable) reserved paths are there at all times
|
||||
_reservedUrls = StaticReservedUrls + urls;
|
||||
}
|
||||
return _reservedUrls;
|
||||
}
|
||||
internal set { _reservedUrls = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -73,22 +83,25 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
//ensure the built on (non-changeable) reserved paths are there at all times
|
||||
var staticReservedPaths = "~/app_plugins/,~/install/,";
|
||||
|
||||
//always add the umbraco path to the list
|
||||
if (ConfigurationManager.AppSettings.ContainsKey("umbracoPath")
|
||||
&& !ConfigurationManager.AppSettings["umbracoPath"].IsNullOrWhiteSpace())
|
||||
if (_reservedPaths == null)
|
||||
{
|
||||
staticReservedPaths += ConfigurationManager.AppSettings["umbracoPath"].EnsureEndsWith(',');
|
||||
var reservedPaths = StaticReservedPaths;
|
||||
//always add the umbraco path to the list
|
||||
if (ConfigurationManager.AppSettings.ContainsKey("umbracoPath")
|
||||
&& !ConfigurationManager.AppSettings["umbracoPath"].IsNullOrWhiteSpace())
|
||||
{
|
||||
reservedPaths += ConfigurationManager.AppSettings["umbracoPath"].EnsureEndsWith(',');
|
||||
}
|
||||
|
||||
var allPaths = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedPaths")
|
||||
? ConfigurationManager.AppSettings["umbracoReservedPaths"]
|
||||
: string.Empty;
|
||||
|
||||
_reservedPaths = reservedPaths + allPaths;
|
||||
}
|
||||
|
||||
var paths = ConfigurationManager.AppSettings.ContainsKey("umbracoReservedPaths")
|
||||
? ConfigurationManager.AppSettings["umbracoReservedPaths"]
|
||||
: string.Empty;
|
||||
|
||||
return staticReservedPaths + paths;
|
||||
return _reservedPaths;
|
||||
}
|
||||
internal set { _reservedPaths = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -15,18 +15,14 @@ namespace Umbraco.Tests
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
{
|
||||
base.Initialize();
|
||||
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "~/umbraco,~/install/");
|
||||
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd");
|
||||
SettingsForTests.UmbracoPath = "~/umbraco";
|
||||
}
|
||||
|
||||
public override void TearDown()
|
||||
{
|
||||
//reset the app config
|
||||
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "");
|
||||
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "");
|
||||
Umbraco.Core.Configuration.GlobalSettings.ResetCache();
|
||||
//reset the app config
|
||||
base.TearDown();
|
||||
|
||||
}
|
||||
@@ -72,8 +68,8 @@ namespace Umbraco.Tests
|
||||
public void Is_Reserved_By_Route(string url, bool shouldMatch)
|
||||
{
|
||||
//reset the app config, we only want to test routes not the hard coded paths
|
||||
ConfigurationManager.AppSettings.Set("umbracoReservedPaths", "");
|
||||
ConfigurationManager.AppSettings.Set("umbracoReservedUrls", "");
|
||||
Umbraco.Core.Configuration.GlobalSettings.ReservedPaths = "";
|
||||
Umbraco.Core.Configuration.GlobalSettings.ReservedUrls = "";
|
||||
|
||||
var routes = new RouteCollection();
|
||||
|
||||
|
||||
@@ -75,13 +75,13 @@ namespace Umbraco.Tests.TestHelpers
|
||||
public static string ReservedPaths
|
||||
{
|
||||
get { return GlobalSettings.ReservedPaths; }
|
||||
set { ConfigurationManager.AppSettings.Set("umbracoReservedPaths", value); }
|
||||
set { GlobalSettings.ReservedPaths = value; }
|
||||
}
|
||||
|
||||
public static string ReservedUrls
|
||||
{
|
||||
get { return GlobalSettings.ReservedUrls; }
|
||||
set { ConfigurationManager.AppSettings.Set("umbracoReservedUrls", value); }
|
||||
set { GlobalSettings.ReservedUrls = value; }
|
||||
}
|
||||
|
||||
public static string ConfigurationStatus
|
||||
@@ -100,7 +100,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
public static void Reset()
|
||||
{
|
||||
UmbracoSettings.ResetSetters();
|
||||
|
||||
GlobalSettings.ResetCache();
|
||||
foreach (var kvp in SavedAppSettings)
|
||||
ConfigurationManager.AppSettings.Set(kvp.Key, kvp.Value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user