public ContentRetrieverTests() { httpResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(DummyChildAppContent), }; var fakeHttpRequestSender = A.Fake <IFakeHttpRequestSender>(); A.CallTo(() => fakeHttpRequestSender.Send(A <HttpRequestMessage> .Ignored)).Returns(httpResponse); fakeHttpMessageHandler = new FakeHttpMessageHandler(fakeHttpRequestSender); httpClient = new HttpClient(fakeHttpMessageHandler) { BaseAddress = new Uri("http://SomeRegionBaseAddress"), }; defaultFormPostParams = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("formParam1", "test value") }; logger = A.Fake <ILogger <ContentRetriever> >(); appRegistryDataService = A.Fake <IAppRegistryDataService>(); httpResponseMessageHandler = A.Fake <IHttpResponseMessageHandler>(); markupMessages = new MarkupMessages { AppOfflineHtml = "<h3>App offline</h3>", RegionOfflineHtml = new Dictionary <PageRegion, string> { { PageRegion.Head, "<h3>Head Region is offline</h3>" }, { PageRegion.Breadcrumb, "<h3>Breadcrumb Region is offline</h3>" }, { PageRegion.BodyTop, "<h3>BodyTop Region is offline</h3>" }, { PageRegion.Body, "<h3>Body Region is offline</h3>" }, { PageRegion.SidebarRight, "<h3>SidebarRight Region is offline</h3>" }, { PageRegion.SidebarLeft, "<h3>SidebarLeft Region is offline</h3>" }, { PageRegion.BodyFooter, "<h3>BodyFooter Region is offline</h3>" }, { PageRegion.HeroBanner, "<h3>HeroBanner Region is offline</h3>" }, }, }; defaultService = new ContentRetriever(httpClient, logger, appRegistryDataService, httpResponseMessageHandler, markupMessages); }
public ContentRetriever(HttpClient httpClient, ILogger <ContentRetriever> logger, IAppRegistryDataService appRegistryDataService, IHttpResponseMessageHandler responseHandler, MarkupMessages markupMessages) { this.httpClient = httpClient; this.logger = logger; this.appRegistryDataService = appRegistryDataService; this.responseHandler = responseHandler; this.markupMessages = markupMessages; }
public HealthControllerTests() { appRegistryDataService = A.Fake <IAppRegistryDataService>(); logger = A.Fake <ILogger <HealthController> >(); bearerTokenRetriever = A.Fake <IBearerTokenRetriever>(); applicationHealthService = A.Fake <IApplicationHealthService>(); healthController = new HealthController(appRegistryDataService, logger, bearerTokenRetriever, applicationHealthService); }
public SitemapControllerTests() { defaultAppRegistryDataService = A.Fake <IAppRegistryDataService>(); defaultLogger = A.Fake <ILogger <SitemapController> >(); defaultBaseUrlService = A.Fake <IBaseUrlService>(); var appRegistrationModels = new List <AppRegistrationModel> { new AppRegistrationModel { SitemapURL = new Uri("http://SomeSitemapUrl.xyz", UriKind.Absolute), IsOnline = true, }, }; A.CallTo(() => defaultAppRegistryDataService.GetAppRegistrationModels()).Returns(appRegistrationModels); var user = A.Fake <ClaimsPrincipal>(); A.CallTo(() => user.Identity.IsAuthenticated).Returns(true); defaultHttpContext = A.Fake <HttpContext>(); defaultHttpContext.Request.Scheme = DummyScheme; defaultHttpContext.Request.Host = new HostString(DummyHost); var fakeIdentity = new GenericIdentity("User"); var principal = new GenericPrincipal(fakeIdentity, null); A.CallTo(() => defaultHttpContext.User).Returns(principal); defaultUrlHelper = A.Fake <IUrlHelper>(); defaultTokenRetriever = A.Fake <IBearerTokenRetriever>(); A.CallTo(() => defaultTokenRetriever.GetToken(A <HttpContext> .Ignored)).Returns("SomeToken"); A.CallTo(() => defaultBaseUrlService.GetBaseUrl(A <HttpRequest> .Ignored, A <IUrlHelper> .Ignored)).Returns("http://SomeBaseUrl"); defaultSitemapService = A.Fake <IApplicationSitemapService>(); A.CallTo(() => defaultSitemapService.GetAsync(A <ApplicationSitemapModel> .Ignored)) .Returns(Task.FromResult <IEnumerable <SitemapLocation> >(new List <SitemapLocation>() { new SitemapLocation { Url = "http://Sitemap.xml", }, })); defaultController = new SitemapController(defaultAppRegistryDataService, defaultLogger, defaultTokenRetriever, defaultBaseUrlService, defaultSitemapService) { ControllerContext = new ControllerContext { HttpContext = defaultHttpContext, }, Url = defaultUrlHelper, }; }
public ContentRetriever(IUriSpecifcHttpClientFactory httpClientFactory, ILogger <ContentRetriever> logger, IAppRegistryDataService appRegistryDataService, IHttpResponseMessageHandler responseHandler, MarkupMessages markupMessages, IMemoryCache memoryCache, IOptions <PassOnHeaderSettings> headerSettings) { this.httpClientFactory = httpClientFactory; this.logger = logger; this.appRegistryDataService = appRegistryDataService; this.responseHandler = responseHandler; this.markupMessages = markupMessages; this.memoryCache = memoryCache; this.headerSettings = headerSettings?.Value ?? new PassOnHeaderSettings(); }
public HealthController( IAppRegistryDataService appRegistryDataService, ILogger <HealthController> logger, IBearerTokenRetriever bearerTokenRetriever, IApplicationHealthService applicationHealthService) { this.appRegistryDataService = appRegistryDataService; this.logger = logger; this.bearerTokenRetriever = bearerTokenRetriever; this.applicationHealthService = applicationHealthService; }
public RobotControllerTests() { defaultAppRegistryDataService = A.Fake <IAppRegistryDataService>(); defaultLogger = A.Fake <ILogger <RobotController> >(); defaultWebHostEnvironment = A.Fake <IWebHostEnvironment>(); defaultBaseUrlService = A.Fake <IBaseUrlService>(); var appRegistrationModels = new List <AppRegistrationModel> { new AppRegistrationModel { RobotsURL = new Uri("http://SomeRobotUrl.xyz", UriKind.Absolute), IsOnline = true, }, }; A.CallTo(() => defaultAppRegistryDataService.GetAppRegistrationModels()).Returns(appRegistrationModels); var user = A.Fake <ClaimsPrincipal>(); A.CallTo(() => user.Identity.IsAuthenticated).Returns(true); defaultHttpContext = A.Fake <HttpContext>(); defaultHttpContext.Request.Scheme = DummyScheme; defaultHttpContext.Request.Host = new HostString(DummyHost); var fakeIdentity = new GenericIdentity("User"); var principal = new GenericPrincipal(fakeIdentity, null); A.CallTo(() => defaultHttpContext.User).Returns(principal); defaultUrlHelper = A.Fake <IUrlHelper>(); A.CallTo(() => defaultUrlHelper.Content(A <string> .Ignored)).Returns("DummyUrl"); A.CallTo(() => defaultUrlHelper.RouteUrl(A <UrlRouteContext> .Ignored)).Returns(DummySitemapUrl); defaultTokenRetriever = A.Fake <IBearerTokenRetriever>(); A.CallTo(() => defaultTokenRetriever.GetToken(A <HttpContext> .Ignored)).Returns("SomeToken"); defaultApplicationRobotService = A.Fake <IApplicationRobotService>(); A.CallTo(() => defaultApplicationRobotService.GetAsync(A <ApplicationRobotModel> .Ignored)).Returns("RetrievedValue: SomeValue"); defaultShellRobotFileService = A.Fake <IShellRobotFileService>(); A.CallTo(() => defaultShellRobotFileService.GetStaticFileText(A <string> .Ignored)).Returns("{Insertion}"); defaultController = new RobotController(defaultAppRegistryDataService, defaultLogger, defaultWebHostEnvironment, defaultTokenRetriever, defaultApplicationRobotService, defaultShellRobotFileService, defaultBaseUrlService) { ControllerContext = new ControllerContext { HttpContext = defaultHttpContext, }, Url = defaultUrlHelper, }; }
public ApplicationService( IAppRegistryDataService appRegistryDataService, IContentRetriever contentRetriever, IContentProcessorService contentProcessorService, ITaskHelper taskHelper, MarkupMessages markupMessages) { this.appRegistryDataService = appRegistryDataService; this.contentRetriever = contentRetriever; this.contentProcessorService = contentProcessorService; this.taskHelper = taskHelper; this.markupMessages = markupMessages; }
public SitemapController( IAppRegistryDataService aappRegistryDataService, ILogger <SitemapController> logger, IBearerTokenRetriever bearerTokenRetriever, IBaseUrlService baseUrlService, IApplicationSitemapService sitemapService) { this.aappRegistryDataService = aappRegistryDataService; this.logger = logger; this.bearerTokenRetriever = bearerTokenRetriever; this.baseUrlService = baseUrlService; this.sitemapService = sitemapService; }
public RobotController( IAppRegistryDataService appRegistryDataService, ILogger <RobotController> logger, IWebHostEnvironment webHostEnvironment, IBearerTokenRetriever bearerTokenRetriever, IApplicationRobotService applicationRobotService, IShellRobotFileService shellRobotFileService, IBaseUrlService baseUrlService) { this.appRegistryDataService = appRegistryDataService; this.logger = logger; this.webHostEnvironment = webHostEnvironment; this.bearerTokenRetriever = bearerTokenRetriever; this.applicationRobotService = applicationRobotService; this.shellRobotFileService = shellRobotFileService; this.baseUrlService = baseUrlService; }
public VersionedFiles(WebchatOptions webchatOptions, IAppRegistryDataService appRegistryDataService) { _ = webchatOptions ?? throw new ArgumentNullException(nameof(webchatOptions)); _ = appRegistryDataService ?? throw new ArgumentNullException(nameof(appRegistryDataService)); var shellAppRegistrationModel = appRegistryDataService.GetShellAppRegistrationModel().Result; if (shellAppRegistrationModel?.CssScriptNames != null && shellAppRegistrationModel.CssScriptNames.Any()) { foreach (var key in shellAppRegistrationModel.CssScriptNames.Keys) { var value = shellAppRegistrationModel.CssScriptNames[key]; var fullPathname = key.StartsWith("/", StringComparison.Ordinal) ? shellAppRegistrationModel.CdnLocation + key : key; VersionedPathForCssScripts.Add($"{fullPathname}?{value}"); } } if (shellAppRegistrationModel?.JavaScriptNames != null && shellAppRegistrationModel.JavaScriptNames.Any()) { foreach (var key in shellAppRegistrationModel.JavaScriptNames.Keys) { var value = shellAppRegistrationModel.JavaScriptNames[key]; if (key.Equals(webchatOptions.ScriptUrl, StringComparison.OrdinalIgnoreCase)) { VersionedPathForWebChatJs = $"{key}?{value}"; } else { var fullPathname = key.StartsWith("/", StringComparison.Ordinal) ? shellAppRegistrationModel.CdnLocation + key : key; VersionedPathForJavaScripts.Add($"{fullPathname}?{value}"); } } } if (webchatOptions.Enabled) { WebchatEnabled = webchatOptions.Enabled; } }
public ListPathsViewComponent(IAppRegistryDataService appRegistryDataService) { this.appRegistryDataService = appRegistryDataService; }
public ApplicationToPageModelMapper(IAppRegistryDataService appRegistryDataService) { this.appRegistryDataService = appRegistryDataService; }
public ApplicationControllerTests() { defaultAppRegistryDataService = A.Fake <IAppRegistryDataService>(); defaultMapper = new ApplicationToPageModelMapper(defaultAppRegistryDataService); defaultLogger = A.Fake <ILogger <ApplicationController> >(); defaultApplicationService = A.Fake <IApplicationService>(); defaultVersionedFiles = A.Fake <IVersionedFiles>(); defaultConfiguration = A.Fake <IConfiguration>(); defaultBaseUrlService = A.Fake <IBaseUrlService>(); neo4JService = A.Fake <INeo4JService>(); defaultApplicationModel = new ApplicationModel { AppRegistrationModel = new AppRegistrationModel { Path = ChildAppPath, Regions = new List <RegionModel> { new RegionModel { IsHealthy = true, PageRegion = PageRegion.Body, RegionEndpoint = "http://childApp/bodyRegion", }, }, }, }; defaultPostRequestViewModel = new ActionPostRequestModel { Path = ChildAppPath, Data = ChildAppData, FormCollection = new FormCollection(new Dictionary <string, StringValues> { { "someKey", "someFormValue" }, }), }; childAppActionGetRequestModel = defaultPostRequestViewModel; A.CallTo(() => defaultApplicationService.GetApplicationAsync(childAppActionGetRequestModel)).Returns(defaultApplicationModel); var fakeHttpContext = new DefaultHttpContext { Request = { QueryString = QueryString.Create("test", "testvalue") } }; defaultGetController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService) { ControllerContext = new ControllerContext { HttpContext = fakeHttpContext, }, }; defaultPostController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { Request = { Method = "POST" }, }, }, }; bearerTokenController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim> { new Claim("bearer", "test") }, "mock")) }, }, }; postBearerTokenController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService, neo4JService) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(new ClaimsIdentity(new List <Claim> { new Claim("bearer", "test") }, "mock")) }, }, }; }
public ApplicationServiceTests() { appRegistryDataService = A.Fake <IAppRegistryDataService>(); mapper = new ApplicationToPageModelMapper(appRegistryDataService); contentRetriever = A.Fake <IContentRetriever>(); contentProcessor = A.Fake <IContentProcessorService>(); markupMessages = new MarkupMessages { AppOfflineHtml = "<h3>App offline</h3>", RegionOfflineHtml = new Dictionary <PageRegion, string> { { PageRegion.Head, "<h3>Head Region is offline</h3>" }, { PageRegion.Breadcrumb, "<h3>Breadcrumb Region is offline</h3>" }, { PageRegion.BodyTop, "<h3>BodyTop Region is offline</h3>" }, { PageRegion.Body, "<h3>Body Region is offline</h3>" }, { PageRegion.SidebarRight, "<h3>SidebarRight Region is offline</h3>" }, { PageRegion.SidebarLeft, "<h3>SidebarLeft Region is offline</h3>" }, { PageRegion.BodyFooter, "<h3>BodyFooter Region is offline</h3>" }, { PageRegion.HeroBanner, "<h3>HeroBanner Region is offline</h3>" }, }, }; var headRegionEndPoint = $"{RequestBaseUrl}/headRegionEndpoint"; var bodyRegionEndPoint = $"{RequestBaseUrl}/bodyRegionEndpoint"; var footerRegionEndPoint = $"{RequestBaseUrl}/footerRegionEndpoint"; defaultHeadRegion = new RegionModel { PageRegion = PageRegion.Head, RegionEndpoint = headRegionEndPoint, IsHealthy = true, OfflineHtml = OfflineHtml }; defaultBodyRegion = new RegionModel { PageRegion = PageRegion.Body, RegionEndpoint = bodyRegionEndPoint, IsHealthy = true, OfflineHtml = OfflineHtml }; defaultBodyFooterRegion = new RegionModel { PageRegion = PageRegion.BodyFooter, RegionEndpoint = footerRegionEndPoint, IsHealthy = true, OfflineHtml = OfflineHtml }; defaultRegions = new List <RegionModel> { defaultHeadRegion, defaultBodyRegion, defaultBodyFooterRegion, }; defaultAppRegistrationModel = new AppRegistrationModel { Path = ChildAppPath, TopNavigationOrder = 1, IsOnline = true, Regions = defaultRegions }; pagesAppRegistrationModel = new AppRegistrationModel { Path = AppRegistryPathNameForPagesApp, TopNavigationOrder = 1, IsOnline = true, Regions = defaultRegions }; defaultPageViewModel = new PageViewModel { PageRegionContentModels = new List <PageRegionContentModel> { new PageRegionContentModel { PageRegionType = PageRegion.Body, }, }, }; defaultApplicationModel = new ApplicationModel { AppRegistrationModel = defaultAppRegistrationModel, Article = "index" }; pagesApplicationModel = new ApplicationModel { AppRegistrationModel = pagesAppRegistrationModel }; offlineApplicationModel = new ApplicationModel { AppRegistrationModel = new AppRegistrationModel { IsOnline = false, OfflineHtml = OfflineHtml } }; offlineApplicationModelWithoutMarkup = new ApplicationModel { AppRegistrationModel = new AppRegistrationModel { IsOnline = false, OfflineHtml = null } }; A.CallTo(() => appRegistryDataService.GetAppRegistrationModel($"{ChildAppPath}/{ChildAppData}")).Returns(nullAppRegistrationModel); A.CallTo(() => appRegistryDataService.GetAppRegistrationModel(ChildAppPath)).Returns(defaultAppRegistrationModel); A.CallTo(() => appRegistryDataService.GetAppRegistrationModel(AppRegistryPathNameForPagesApp)).Returns(pagesAppRegistrationModel); A.CallTo(() => contentRetriever.GetContent($"{defaultHeadRegion.RegionEndpoint}/index", defaultApplicationModel.AppRegistrationModel.Path, defaultHeadRegion, A <bool> .Ignored, RequestBaseUrl)).Returns(HeadRegionContent); A.CallTo(() => contentRetriever.GetContent($"{defaultBodyRegion.RegionEndpoint}/index", defaultApplicationModel.AppRegistrationModel.Path, defaultBodyRegion, A <bool> .Ignored, RequestBaseUrl)).Returns(BodyRegionContent); A.CallTo(() => contentRetriever.GetContent($"{defaultBodyFooterRegion.RegionEndpoint}", defaultApplicationModel.AppRegistrationModel.Path, defaultBodyFooterRegion, A <bool> .Ignored, RequestBaseUrl)).Returns(BodyFooterRegionContent); A.CallTo(() => contentRetriever.GetContent($"{defaultBodyFooterRegion.RegionEndpoint}/index", defaultApplicationModel.AppRegistrationModel.Path, defaultBodyFooterRegion, A <bool> .Ignored, RequestBaseUrl)).Returns(BodyFooterRegionContent); A.CallTo(() => contentProcessor.Process(HeadRegionContent, A <string> .Ignored, A <string> .Ignored)).Returns(HeadRegionContent); A.CallTo(() => contentProcessor.Process(BodyRegionContent, A <string> .Ignored, A <string> .Ignored)).Returns(BodyRegionContent); A.CallTo(() => contentProcessor.Process(BodyFooterRegionContent, A <string> .Ignored, A <string> .Ignored)).Returns(BodyFooterRegionContent); defaultFormPostParams = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("formParam1", "testvalue") }; taskHelper = A.Fake <ITaskHelper>(); A.CallTo(() => taskHelper.TaskCompletedSuccessfully(A <Task> .Ignored)).Returns(true); applicationService = new ApplicationService(appRegistryDataService, contentRetriever, contentProcessor, taskHelper, markupMessages) { RequestBaseUrl = RequestBaseUrl }; }
public AjaxController(IAjaxRequestService ajaxRequestService, IAppRegistryDataService appRegistryDataService) { this.ajaxRequestService = ajaxRequestService; this.appRegistryDataService = appRegistryDataService; }
public AjaxRequestService(ILogger <AjaxRequestService> logger, IAppRegistryDataService appRegistryDataService, HttpClient httpClient) { this.logger = logger; this.appRegistryDataService = appRegistryDataService; this.httpClient = httpClient; }