Example #1
0
        public void HttpProxy_Local_Parsing(string bypass, int count)
        {
            RemoteInvoke((bypassValue, expected) =>
            {
                int expectedCount = Convert.ToInt32(expected);
                IWebProxy p;

                FakeRegistry.Reset();
                FakeRegistry.WinInetProxySettings.Proxy       = FakeProxyString;
                FakeRegistry.WinInetProxySettings.ProxyBypass = bypassValue;

                Assert.True(HttpSystemProxy.TryCreate(out p));
                Assert.NotNull(p);

                HttpSystemProxy sp = p as HttpSystemProxy;
                Assert.NotNull(sp);

                if (expectedCount > 0)
                {
                    Assert.Equal(expectedCount, sp.BypassList.Count);
                }
                else
                {
                    Assert.Null(sp.BypassList);
                }
                return(SuccessExitCode);
            }, bypass, count.ToString()).Dispose();
        }
        // On Windows we get default proxy configuration from either environment variables or the Windows system proxy.
        public static IWebProxy ConstructSystemProxy()
        {
            if (!HttpEnvironmentProxy.TryCreate(out IWebProxy proxy))
            {
                HttpSystemProxy.TryCreate(out proxy);
            }

            return(proxy);
        }
Example #3
0
        public void HttpProxy_SystemProxy_Loaded()
        {
            IWebProxy p;

            FakeRegistry.Reset();
            Assert.False(HttpSystemProxy.TryCreate(out p));

            FakeRegistry.WinInetProxySettings.Proxy = FakeProxyString;

            Assert.True(HttpSystemProxy.TryCreate(out p));
            Assert.NotNull(p);
            Assert.Equal(fakeProxyUri, p.GetProxy(fooHttp));
            Assert.Equal(fakeProxyUri, p.GetProxy(fooHttps));
        }
Example #4
0
        public void HttpProxy_SystemProxy_Loaded(string rawProxyString, string expectedUri)
        {
            RemoteInvoke((proxyString, expectedString) =>
            {
                IWebProxy p;

                FakeRegistry.Reset();

                FakeRegistry.WinInetProxySettings.Proxy = proxyString;
                WinInetProxyHelper proxyHelper          = new WinInetProxyHelper();

                Assert.True(HttpSystemProxy.TryCreate(out p));
                Assert.NotNull(p);
                Assert.Equal(expectedString, p.GetProxy(new Uri(fooHttp)).ToString());
                Assert.Equal(expectedString, p.GetProxy(new Uri(fooHttps)).ToString());

                return(SuccessExitCode);
            }, rawProxyString, expectedUri).Dispose();
        }
Example #5
0
        public void HttpProxy_Local_Bypassed(string name, bool shouldBypass)
        {
            RemoteInvoke((url, expected) =>
            {
                bool expectedResult = Boolean.Parse(expected);
                IWebProxy p;

                FakeRegistry.Reset();
                FakeRegistry.WinInetProxySettings.Proxy       = FakeProxyString;
                FakeRegistry.WinInetProxySettings.ProxyBypass = "******";

                Assert.True(HttpSystemProxy.TryCreate(out p));
                Assert.NotNull(p);

                Uri u = new Uri(url);
                Assert.Equal(expectedResult, p.GetProxy(u) == null);

                return(SuccessExitCode);
            }, name, shouldBypass.ToString()).Dispose();
        }
Example #6
0
        public void HttpProxy_SystemProxy_Loaded(string rawProxyString, bool hasInsecureProxy, bool hasSecureProxy)
        {
            RemoteInvoke((proxyString, insecureProxy, secureProxy) =>
            {
                IWebProxy p;

                FakeRegistry.Reset();
                Assert.False(HttpSystemProxy.TryCreate(out p));

                FakeRegistry.WinInetProxySettings.Proxy = proxyString;
                WinInetProxyHelper proxyHelper          = new WinInetProxyHelper();

                Assert.True(HttpSystemProxy.TryCreate(out p));
                Assert.NotNull(p);

                Assert.Equal(Boolean.Parse(insecureProxy) ? new Uri(insecureProxyUri) : null, p.GetProxy(new Uri(fooHttp)));
                Assert.Equal(Boolean.Parse(secureProxy) ? new Uri(secureProxyUri) : null, p.GetProxy(new Uri(fooHttps)));
                Assert.Equal(Boolean.Parse(insecureProxy) ? new Uri(insecureProxyUri) : null, p.GetProxy(new Uri(fooWs)));
                Assert.Equal(Boolean.Parse(secureProxy) ? new Uri(secureProxyUri) : null, p.GetProxy(new Uri(fooWss)));
                return(SuccessExitCode);
            }, rawProxyString, hasInsecureProxy.ToString(), hasSecureProxy.ToString()).Dispose();
        }
Example #7
0
        public void HttpProxy_InvalidSystemProxy_Null(string rawProxyString)
        {
            RemoteInvoke((proxyString) =>
            {
                IWebProxy p;

                FakeRegistry.Reset();
                Assert.False(HttpSystemProxy.TryCreate(out p));

                FakeRegistry.WinInetProxySettings.Proxy = proxyString;
                WinInetProxyHelper proxyHelper          = new WinInetProxyHelper();

                Assert.True(HttpSystemProxy.TryCreate(out p));
                Assert.NotNull(p);

                Assert.Equal(null, p.GetProxy(new Uri(fooHttp)));
                Assert.Equal(null, p.GetProxy(new Uri(fooHttps)));
                Assert.Equal(null, p.GetProxy(new Uri(fooWs)));
                Assert.Equal(null, p.GetProxy(new Uri(fooWss)));
                return(SuccessExitCode);
            }, rawProxyString).Dispose();
        }