コード例 #1
0
        private HttpClient GetTestClient()
        {
            Program.ConfigureSetupLogging();

            // No setup required for these services. They are not in use by the InstanceEventController
            Mock <ISasTokenProvider>           sasTokenProvider = new Mock <ISasTokenProvider>();
            Mock <IKeyVaultClientWrapper>      keyVaultWrapper  = new Mock <IKeyVaultClientWrapper>();
            Mock <IPartiesWithInstancesClient> partiesWrapper   = new Mock <IPartiesWithInstancesClient>();

            HttpClient client = _factory.WithWebHostBuilder(builder =>
            {
                builder.ConfigureTestServices(services =>
                {
                    services.AddMockRepositories();

                    services.AddSingleton(sasTokenProvider.Object);
                    services.AddSingleton(keyVaultWrapper.Object);
                    services.AddSingleton(partiesWrapper.Object);
                    services.AddSingleton <IPDP, PepWithPDPAuthorizationMockSI>();
                    services.AddSingleton <IPostConfigureOptions <JwtCookieOptions>, JwtCookiePostConfigureOptionsStub>();
                });
            }).CreateClient();

            return(client);
        }
コード例 #2
0
        private HttpClient CreateTestHttpClient(ITextRepository textRepository)
        {
            // No setup required for these services. They are not in use by the ApplicationController
            Mock <ISasTokenProvider>           sasTokenProvider = new Mock <ISasTokenProvider>();
            Mock <IKeyVaultClientWrapper>      keyVaultWrapper  = new Mock <IKeyVaultClientWrapper>();
            Mock <IPartiesWithInstancesClient> partiesWrapper   = new Mock <IPartiesWithInstancesClient>();

            HttpClient client = _factory.WithWebHostBuilder(builder =>
            {
                builder.ConfigureTestServices(services =>
                {
                    services.AddMockRepositories();

                    services.AddSingleton(textRepository);

                    services.AddSingleton(sasTokenProvider.Object);
                    services.AddSingleton(keyVaultWrapper.Object);
                    services.AddSingleton(partiesWrapper.Object);
                    services.AddSingleton <IPDP, PepWithPDPAuthorizationMockSI>();
                    services.AddSingleton <IPostConfigureOptions <JwtCookieOptions>, JwtCookiePostConfigureOptionsStub>();
                });
            }).CreateClient();

            string token = PrincipalUtil.GetAccessToken("studio.designer");

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

            return(client);
        }
コード例 #3
0
        private HttpClient GetTestClient()
        {
            HttpClient client = _factory.WithWebHostBuilder(builder =>
            {
                builder.ConfigureTestServices(services =>
                {
                });
            }).CreateClient();

            return(client);
        }