public HomeControllerTests() { defaultVersionedFiles = A.Fake <IVersionedFiles>(); defaultConfiguration = A.Fake <IConfiguration>(); defaultController = new HomeController(defaultVersionedFiles, defaultConfiguration); }
public AuthControllerTests() { authClient = A.Fake <IOpenIdConnectClient>(); log = A.Fake <ILogger <AuthController> >(); defaultVersionedFiles = A.Fake <IVersionedFiles>(); defaultConfiguration = A.Fake <IConfiguration>(); var requestServices = A.Fake <IServiceProvider>(); defaultAuthService = A.Fake <IAuthenticationService>(); session = new MockHttpSession(); baseUrlService = A.Fake <IBaseUrlService>(); defaultUrlHelper = A.Fake <IUrlHelper>(); A.CallTo(() => defaultAuthService.SignInAsync(A <HttpContext> .Ignored, A <string> .Ignored, A <ClaimsPrincipal> .Ignored, A <AuthenticationProperties> .Ignored)).Returns(Task.CompletedTask); A.CallTo(() => requestServices.GetService(typeof(IAuthenticationService))).Returns(defaultAuthService); A.CallTo(() => baseUrlService.GetBaseUrl(A <HttpRequest> .Ignored, A <IUrlHelper> .Ignored)) .Returns(baseAddress); defaultContext = new DefaultHttpContext { RequestServices = requestServices, Session = session, Request = { Headers = { new KeyValuePair <string, StringValues>("Referer", refererUrl) } }, }; defaultsettings = Options.Create(new AuthSettings { Audience = "audience", ClientSecret = "clientSecret123456", Issuer = "issuer", DefaultRedirectUrl = "test", AuthDssEndpoint = "test/{url}", }); defaultSettings = Options.Create(new OpenIDConnectSettings { RedirectUrl = "test/", SignOutRedirectUrl = "test/", Issuer = "issuer", AuthdUrl = "auth", AuthorizeUrl = "AuthorizeUrl", ClientId = "clientid", EndSessionUrl = "Endsesison", JWK = "jjjjjjfhfjjfjfjfjfhfjkhdfkhdfkjhskfhsldkjhfskdljfhsdlkfhsdflksdhsdlkfh", Exponent = "AQAB", }); tokenHandler = A.Fake <SecurityTokenHandler>(); configurationManager = A.Fake <IConfigurationManager <OpenIdConnectConfiguration> >(); A.CallTo(() => configurationManager.GetConfigurationAsync(CancellationToken.None)).Returns( new OpenIdConnectConfiguration { AuthorizationEndpoint = "auth", EndSessionEndpoint = "end", Issuer = "issuer", }); _urlHelper = A.Fake <IUrlHelper>(); }
public ApplicationControllerTests() { defaultMapper = new ApplicationToPageModelMapper(); defaultLogger = A.Fake <ILogger <ApplicationController> >(); defaultApplicationService = A.Fake <IApplicationService>(); defaultVersionedFiles = A.Fake <IVersionedFiles>(); defaultConfiguration = A.Fake <IConfiguration>(); defaultBaseUrlService = A.Fake <IBaseUrlService>(); defaultApplicationModel = new ApplicationModel { Path = new PathModel { Path = ChildAppPath }, Regions = new List <RegionModel> { new RegionModel { Path = ChildAppPath, IsHealthy = true, PageRegion = PageRegion.Body, RegionEndpoint = "http://childApp/bodyRegion", }, }, }; A.CallTo(() => defaultApplicationService.GetApplicationAsync(ChildAppPath)).Returns(defaultApplicationModel); var fakeHttpContext = new DefaultHttpContext { Request = { QueryString = QueryString.Create("test", "testvalue") } }; defaultPostRequestViewModel = new ActionPostRequestModel { Path = ChildAppPath, FormCollection = new FormCollection(new Dictionary <string, StringValues> { { "someKey", "someFormValue" }, }), }; defaultGetController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService) { ControllerContext = new ControllerContext { HttpContext = fakeHttpContext, }, }; defaultPostController = new ApplicationController(defaultMapper, defaultLogger, defaultApplicationService, defaultVersionedFiles, defaultConfiguration, defaultBaseUrlService) { ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { Request = { Method = "POST" }, }, }, }; }
public static PageViewModel BuildDefaultPageViewModel(this IVersionedFiles versionedFiles, IConfiguration configuration) { return(new PageViewModel { BrandingAssetsCdn = configuration.GetValue <string>(nameof(PageViewModel.BrandingAssetsCdn)), VersionedPathForMainMinCss = versionedFiles?.VersionedPathForMainMinCss, VersionedPathForGovukMinCss = versionedFiles?.VersionedPathForGovukMinCss, VersionedPathForAllIe8Css = versionedFiles?.VersionedPathForAllIe8Css, VersionedPathForJQueryBundleMinJs = versionedFiles?.VersionedPathForJQueryBundleMinJs, VersionedPathForAllMinJs = versionedFiles?.VersionedPathForAllMinJs, VersionedPathForDfcDigitalMinJs = versionedFiles?.VersionedPathForDfcDigitalMinJs, }); }
public static PageViewModel BuildDefaultPageViewModel(this IVersionedFiles versionedFiles, IConfiguration configuration) { _ = versionedFiles ?? throw new ArgumentNullException(nameof(versionedFiles)); return(new PageViewModel { BrandingAssetsCdn = configuration.GetValue <string>(nameof(PageViewModel.BrandingAssetsCdn)), VersionedPathForCssScripts = versionedFiles.VersionedPathForCssScripts.ToList(), VersionedPathForJavaScripts = versionedFiles.VersionedPathForJavaScripts.ToList(), VersionedPathForWebChatJs = versionedFiles.VersionedPathForWebChatJs, WebchatEnabled = versionedFiles.WebchatEnabled, }); }
public AuthController(IOpenIdConnectClient client, ILogger <AuthController> logger, IOptions <AuthSettings> settings, IVersionedFiles versionedFiles, IConfiguration configuration, IBaseUrlService baseUrlService) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } authClient = client; this.logger = logger; this.settings = settings.Value; this.versionedFiles = versionedFiles; this.configuration = configuration; this.baseUrlService = baseUrlService; }
public ApplicationController( IMapper <ApplicationModel, PageViewModel> mapper, ILogger <ApplicationController> logger, IApplicationService applicationService, IVersionedFiles versionedFiles, IConfiguration configuration, IBaseUrlService baseUrlService) { this.mapper = mapper; this.logger = logger; this.applicationService = applicationService; this.versionedFiles = versionedFiles; this.configuration = configuration; this.baseUrlService = baseUrlService; }
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 HomeController(IVersionedFiles versionedFiles, IConfiguration configuration) { this.versionedFiles = versionedFiles; this.configuration = configuration; }
public ErrorControllerTests() { fakeLogger = A.Fake <ILogger <ApplicationController> >(); fakeVersionedFiles = A.Fake <IVersionedFiles>(); fakeConfiguration = A.Fake <IConfiguration>(); }
public ErrorController(ILogger <ApplicationController> logger, IVersionedFiles versionedFiles, IConfiguration configuration) { this.logger = logger; this.versionedFiles = versionedFiles; this.configuration = configuration; }