public void SetApplicationUrlFromDcSettingsSsl1() { // set from distributed call settings // first server is master server var settings = Mock.Of <IUmbracoSettingsSection>(section => section.DistributedCall == Mock.Of <IDistributedCallSection>(callSection => callSection.Enabled == true && callSection.Servers == new IServer[] { Mock.Of <IServer>(server => server.ServerName == NetworkHelper.MachineName && server.ServerAddress == "server1.com"), Mock.Of <IServer>(server => server.ServerName == "ANOTHERNAME" && server.ServerAddress == "server2.com"), }) && section.WebRouting == Mock.Of <IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string)null) && section.ScheduledTasks == Mock.Of <IScheduledTasksSection>(tasksSection => tasksSection.BaseUrl == (string)null)); Initialize(settings); var appCtx = new ApplicationContext(CacheHelper.CreateDisabledCacheHelper(), new ProfilingLogger(Mock.Of <ILogger>(), Mock.Of <IProfiler>())); ConfigurationManager.AppSettings.Set("umbracoUseSSL", "true"); ApplicationUrlHelper.TrySetApplicationUrl(appCtx, settings); Assert.AreEqual("http://server1.com:80/umbraco", appCtx._umbracoApplicationUrl); var registrar = ServerRegistrarResolver.Current.Registrar as IServerRegistrar2; var role = registrar.GetCurrentServerRole(); Assert.AreEqual(ServerRole.Master, role); }
public void SetApplicationUrlFromWrSettingsSsl() { var settings = Mock.Of <IUmbracoSettingsSection>(section => section.DistributedCall == Mock.Of <IDistributedCallSection>(callSection => callSection.Servers == Enumerable.Empty <IServer>()) && section.WebRouting == Mock.Of <IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == "httpx://whatever.com/umbraco/") && section.ScheduledTasks == Mock.Of <IScheduledTasksSection>(tasksSection => tasksSection.BaseUrl == "mycoolhost.com/umbraco")); Initialize(settings); var appCtx = new ApplicationContext(CacheHelper.CreateDisabledCacheHelper(), new ProfilingLogger(Mock.Of <ILogger>(), Mock.Of <IProfiler>())); ConfigurationManager.AppSettings.Set("umbracoUseSSL", "true"); // does not make a diff here ApplicationUrlHelper.TrySetApplicationUrl(appCtx, settings); Assert.AreEqual("httpx://whatever.com/umbraco", appCtx._umbracoApplicationUrl); }
public void SetApplicationUrlWhenNoSettings() { // no applicable settings, cannot set url var settings = Mock.Of <IUmbracoSettingsSection>(section => section.DistributedCall == Mock.Of <IDistributedCallSection>(callSection => callSection.Servers == Enumerable.Empty <IServer>()) && section.WebRouting == Mock.Of <IWebRoutingSection>(wrSection => wrSection.UmbracoApplicationUrl == (string)null) && section.ScheduledTasks == Mock.Of <IScheduledTasksSection>()); Initialize(settings); var appCtx = new ApplicationContext(CacheHelper.CreateDisabledCacheHelper(), new ProfilingLogger(Mock.Of <ILogger>(), Mock.Of <IProfiler>())); ConfigurationManager.AppSettings.Set("umbracoUseSSL", "true"); // does not make a diff here ApplicationUrlHelper.TrySetApplicationUrl(appCtx, settings); // still NOT set Assert.IsNull(appCtx._umbracoApplicationUrl); }