Esempio n. 1
0
        protected void Init()
        {
            clients = TestClients.Get();
            var clientStore = new InMemoryClientStore(clients);
            var scopeStore  = new InMemoryScopeStore(TestScopes.Get());

            var factory = new IdentityServerServiceFactory
            {
                ScopeStore  = Registration.RegisterFactory <IScopeStore>((resolver) => scopeStore),
                ClientStore = Registration.RegisterFactory <IClientStore>((resolver) => clientStore)
            };

            server = TestServer.Create(app =>
            {
                appBuilder = app;

                mockUserService          = new Mock <InMemoryUserService>(TestUsers.Get());
                mockUserService.CallBase = true;
                factory.UserService      = Registration.RegisterFactory <IUserService>((resolver) => mockUserService.Object);

                options         = TestIdentityServerOptions.Create();
                options.Factory = factory;
                options.AuthenticationOptions.IdentityProviders = OverrideIdentityProviderConfiguration ?? ConfigureAdditionalIdentityProviders;

                protector = options.DataProtector;

                if (ConfigureIdentityServerOptions != null)
                {
                    ConfigureIdentityServerOptions(options);
                }
                app.UseIdentityServer(options);

                ticketFormatter = new TicketDataFormat(
                    new DataProtectorAdapter(protector, options.AuthenticationOptions.CookieOptions.Prefix + Constants.PartialSignInAuthenticationType));
            });

            client = server.HttpClient;
        }