public async Task CreateAsync_should_return_notify_provider_added() { using var documentStore = new RavenDbTestDriverWrapper().GetDocumentStore(); var services = new ServiceCollection() .AddLogging(); services.AddIdentity <IdentityUser, IdentityRole>() .AddRavenDbStores(p => documentStore); services.AddSingleton(p => documentStore) .AddAuthentication() .AddDynamic <SchemeDefinition>() .AddRavenDbStore() .AddGoogle(); IServiceProvider provider = services.AddIdentityServer4AdminRavenDbkStores <IdentityUser, IdentityRole>(p => documentStore).BuildServiceProvider(); using var scope = provider.CreateScope(); provider = scope.ServiceProvider; var manager = provider.GetRequiredService <PersistentDynamicManager <SchemeDefinition> >(); var serializer = provider.GetRequiredService <IAuthenticationSchemeOptionsSerializer>(); var mockProviderClient = new Mock <IProviderClient>(); mockProviderClient.Setup(m => m.ProviderAddedAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).Verifiable(); var sut = new ExternalProviderStore(manager, serializer, new ScopedAsynDocumentcSession(documentStore.OpenAsyncSession()), mockProviderClient.Object); await sut.CreateAsync(new Entity.ExternalProvider { DisplayName = Guid.NewGuid().ToString(), Id = Guid.NewGuid().ToString(), SerializedHandlerType = serializer.SerializeType(typeof(GoogleHandler)), SerializedOptions = serializer.SerializeOptions(new GoogleOptions(), typeof(GoogleOptions)) } as object); mockProviderClient.Verify(); }
public async Task CreateAsync_should_return_scheme_id() { using var documentStore = new RavenDbTestDriverWrapper().GetDocumentStore(); var services = new ServiceCollection() .AddLogging(); services.AddIdentity <IdentityUser, IdentityRole>() .AddRavenDbStores(p => documentStore); services.AddSingleton(p => documentStore) .AddAuthentication() .AddDynamic <SchemeDefinition>() .AddRavenDbStore() .AddGoogle(); IServiceProvider provider = services.AddIdentityServer4AdminRavenDbkStores <IdentityUser, IdentityRole>(p => documentStore).BuildServiceProvider(); using var scope = provider.CreateScope(); provider = scope.ServiceProvider; var manager = provider.GetRequiredService <PersistentDynamicManager <SchemeDefinition> >(); var serializer = provider.GetRequiredService <IAuthenticationSchemeOptionsSerializer>(); var sut = new ExternalProviderStore(manager, serializer, new ScopedAsynDocumentcSession(documentStore.OpenAsyncSession()), null); var result = await sut.CreateAsync(new Entity.ExternalProvider { DisplayName = Guid.NewGuid().ToString(), Id = Guid.NewGuid().ToString(), SerializedHandlerType = serializer.SerializeType(typeof(GoogleHandler)), SerializedOptions = serializer.SerializeOptions(new GoogleOptions(), typeof(GoogleOptions)) } as object); Assert.NotNull(result); Assert.NotNull(((Entity.ExternalProvider)result).Id); }