public void Is_Reserved_By_Route(string url, bool isReserved) { var globalSettings = new GlobalSettings { ReservedPaths = string.Empty, ReservedUrls = string.Empty }; var routingSettings = new WebRoutingSettings { TryMatchingEndpointsForAllPages = true }; RouteEndpoint endpoint1 = CreateEndpoint( "Umbraco/RenderMvc/{action?}/{id?}", new { controller = "RenderMvc" }, 0); RouteEndpoint endpoint2 = CreateEndpoint( "api/{controller?}/{id?}", new { action = "Index" }, 1); var endpointDataSource = new DefaultEndpointDataSource(endpoint1, endpoint2); var routableDocFilter = new RoutableDocumentFilter( Options.Create(globalSettings), Options.Create(routingSettings), GetHostingEnvironment(), endpointDataSource); Assert.AreEqual( !isReserved, // not reserved if it's a document request routableDocFilter.IsDocumentRequest(url)); }
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 var globalSettingsMock = Mock.Get(Factory.GetInstance <IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container globalSettingsMock.Setup(x => x.ReservedPaths).Returns(""); globalSettingsMock.Setup(x => x.ReservedUrls).Returns(""); var routableDocFilter = new RoutableDocumentFilter(globalSettingsMock.Object); var routes = new RouteCollection(); routes.MapRoute( "Umbraco_default", "Umbraco/RenderMvc/{action}/{id}", new { controller = "RenderMvc", action = "Index", id = UrlParameter.Optional }); routes.MapRoute( "WebAPI", "api/{controller}/{id}", new { controller = "WebApiTestController", action = "Index", id = UrlParameter.Optional }); var context = new FakeHttpContextFactory(url); Assert.AreEqual( shouldMatch, routableDocFilter.IsReservedPathOrUrl(url, context.HttpContext, routes)); }
public void Is_Reserved_By_Default_Back_Office_Route(string url, bool isReserved) { var globalSettings = new GlobalSettings { ReservedPaths = string.Empty, ReservedUrls = string.Empty }; var routingSettings = new WebRoutingSettings { TryMatchingEndpointsForAllPages = true }; var endpoint1 = CreateEndpoint( "umbraco/{action?}/{id?}", new { controller = "BackOffice" }); var endpointDataSource = new DefaultEndpointDataSource(endpoint1); var routableDocFilter = new RoutableDocumentFilter( new TestOptionsSnapshot <GlobalSettings>(globalSettings), Options.Create(routingSettings), GetHostingEnvironment(), endpointDataSource); Assert.AreEqual( !isReserved, // not reserved if it's a document request routableDocFilter.IsDocumentRequest(url)); }
public void Is_Not_Reserved_Path_Or_Url(string url) { var globalSettings = TestObjects.GetGlobalSettings(); var routableDocFilter = new RoutableDocumentFilter(globalSettings); Assert.IsFalse(routableDocFilter.IsReservedPathOrUrl(url)); }
public void Is_Not_Reserved_Path_Or_Url(string url) { var routableDocFilter = new RoutableDocumentFilter( GetGlobalSettings(), GetWebRoutingSettings(), GetHostingEnvironment(), new DefaultEndpointDataSource()); // Will be true if it's not reserved Assert.IsTrue(routableDocFilter.IsDocumentRequest(url)); }