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 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; }