public void Setup() { _messageHandler = A.Fake <HttpMessageHandler>(); A.CallTo(_messageHandler) .Where(x => x.Method.Name == "SendAsync") .WithReturnType <Task <HttpResponseMessage> >() .Returns(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent( TokenEndpointResponse, Encoding.Default, "application/json") }); var cache = A.Fake <IDiscoveryCache>(); A.CallTo(() => cache.GetAsync()).Returns( new DiscoveryResponse( $"{{\"issuer\":\"{BasePath}\",\"jwks_uri\":\"{BasePath}/.well-known/jwks\",\"authorization_endpoint\":\"{AuthorizeEndpoint}\",\"token_endpoint\":\"{TokenEndpoint}\",\"userinfo_endpoint\":\"{UserInfoEndpoint}\",\"end_session_endpoint\":\"{EndSessionEndpoint}\",\"check_session_iframe\":\"{CheckSessionEndpoint}\",\"revocation_endpoint\":\"{RevocationEndpoint}\", \"device_authorization_endpoint\":\"{DeviceAuthorizationEndpoint}\",\"introspection_endpoint\":\"{IntrospectionEndpoint}\",\"frontchannel_logout_supported\":true,\"frontchannel_logout_session_supported\":true,\"scopes_supported\":[\"openid\",\"profile\",\"roles\",\"offline_access\"],\"claims_supported\":[\"sub\",\"name\",\"family_name\",\"given_name\",\"middle_name\",\"nickname\",\"preferred_username\",\"profile\",\"picture\",\"website\",\"email\",\"email_verified\",\"gender\",\"birthdate\",\"zoneinfo\",\"locale\",\"phone_number\",\"phone_number_verified\",\"address\",\"updated_at\",\"role\"],\"response_types_supported\":[\"code\",\"token\",\"id_token\",\"id_token token\",\"code id_token\",\"code token\",\"code id_token token\"],\"response_modes_supported\":[\"form_post\",\"query\",\"fragment\"],\"grant_types_supported\":[\"authorization_code\",\"client_credentials\",\"password\",\"refresh_token\",\"implicit\"],\"subject_types_supported\":[\"public\"],\"id_token_signing_alg_values_supported\":[\"RS256\"],\"code_challenge_methods_supported\":[\"plain\",\"S256\"],\"token_endpoint_auth_methods_supported\":[\"client_secret_post\",\"client_secret_basic\"]}}", new DiscoveryPolicy { Authority = BasePath })); _componentClient = new ComponentClient( new HttpClient(_messageHandler), cache); }
public IComponent Apply(IHostBuilder hostBuilder) { var eventMonitorSink = new EventMonitorSink(); var store = new Store(); hostBuilder.ConfigureServices(services => { services .AddSingleton <IClientStore, Store>(sp => store) .AddSingleton <IResourceStore, Store>(sp => store) .AddSingleton <IEventSink, EventMonitorSink>(sp => eventMonitorSink); services .AddIdentityServer(i => { i.Events.RaiseErrorEvents = true; i.Events.RaiseFailureEvents = true; i.Events.RaiseInformationEvents = true; i.Events.RaiseSuccessEvents = true; }) .AddDeveloperSigningCredential(); }); Uri?baseAddress = null; hostBuilder.ConfigureWebHostDefaults(w => { w.UseUrls("http://localhost:3501"); var urls = w.GetSetting("urls"); var url = urls.Split(';') .Select(x => x.Replace("*", "localhost")) .Select(x => new { Url = x, Rank = x.Contains("localhost") ? 0 : 1 }) .OrderBy(x => x.Rank) .Select(x => x.Url) .First(); baseAddress = new Uri(url); w.Configure((wctx, app) => app.UseIdentityServer(IdentityServerOptions)); }); var httpClient = new HttpClient() { BaseAddress = baseAddress }; var client = new ComponentClient( httpClient, new DiscoveryCache(baseAddress.AbsoluteUri.ToLower(), httpClient)); return(new IdSvr4Component(store, eventMonitorSink, client)); }
public void TearDown() { _componentClient = null; }
public void TearDown() { _componentClient = null; _messageHandler = null; }