コード例 #1
0
        protected void Init()
        {
            clients = TestClients.Get();
            var clientStore = new InMemoryClientStore(clients);
            var scopeStore  = new InMemoryScopeStore(TestScopes.Get());

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

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

                mockUserService          = new Mock <InMemoryUserService>(TestUsers.Get());
                mockUserService.CallBase = true;
                factory.UserService      = new Registration <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;
        }