public void CreateClient_Works()
        {
            var factory = new ProxyHttpClientFactory(Mock <ILogger <ProxyHttpClientFactory> >().Object);

            var actual1 = factory.CreateClient(new ProxyHttpClientContext());
            var actual2 = factory.CreateClient(new ProxyHttpClientContext());

            Assert.NotNull(actual1);
            Assert.NotNull(actual2);
            Assert.NotSame(actual2, actual1);
        }
예제 #2
0
        public void CreateClient_Works()
        {
            // Arrange
            var factory = new ProxyHttpClientFactory();

            // Act
            var actual1 = factory.CreateClient();
            var actual2 = factory.CreateClient();

            // Assert
            Assert.NotNull(actual1);
            Assert.NotNull(actual2);
            Assert.NotSame(actual2, actual1);
        }
예제 #3
0
        public void CreateClient_ApplyDangerousAcceptAnyServerCertificate_Success()
        {
            var factory = new ProxyHttpClientFactory(Mock <ILogger <ProxyHttpClientFactory> >().Object);
            var options = new ProxyHttpClientOptions {
                DangerousAcceptAnyServerCertificate = true
            };
            var client = factory.CreateClient(new ProxyHttpClientContext {
                NewOptions = options
            });

            var handler = GetHandler(client);

            Assert.NotNull(handler);
            Assert.NotNull(handler.SslOptions.RemoteCertificateValidationCallback);
            Assert.True(handler.SslOptions.RemoteCertificateValidationCallback(default, default, default, default));
예제 #4
0
        public void CreateClient_ApplySslProtocols_Success()
        {
            var factory = new ProxyHttpClientFactory(Mock <ILogger <ProxyHttpClientFactory> >().Object);
            var options = new ProxyHttpClientOptions
            {
                SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13,
            };
            var client = factory.CreateClient(new ProxyHttpClientContext {
                NewOptions = options
            });

            var handler = GetHandler(client);

            Assert.NotNull(handler);
            Assert.Equal(SslProtocols.Tls12 | SslProtocols.Tls13, handler.SslOptions.EnabledSslProtocols);
            VerifyDefaultValues(handler, "SslProtocols");
        }