Пример #1
0
        public async Task TestConnectWithCredentialsAsync()
        {
            using (var server = new HttpProxyListener()) {
                server.Start(IPAddress.Loopback, 0);

                var    credentials = new NetworkCredential("username", "password");
                var    proxy       = new HttpProxyClient(server.IPAddress.ToString(), server.Port, credentials);
                Stream stream      = null;

                try {
                    stream = await proxy.ConnectAsync("www.google.com", 80, ConnectTimeout);
                } catch (TimeoutException) {
                    Assert.Inconclusive("Timed out.");
                } catch (Exception ex) {
                    Assert.Fail(ex.Message);
                } finally {
                    stream?.Dispose();
                }
            }
        }
Пример #2
0
        public void TestConnectWithCredentials()
        {
            using (var server = new HttpProxyListener(certificate)) {
                server.Start(IPAddress.Loopback, 0);

                var credentials = new NetworkCredential("username", "password");
                var proxy       = new HttpsProxyClient(server.IPAddress.ToString(), server.Port, credentials)
                {
                    ServerCertificateValidationCallback = (s, c, ch, e) => true,
                    CheckCertificateRevocation          = false
                };
                Stream stream = null;

                try {
                    stream = proxy.Connect("www.google.com", 80, ConnectTimeout);
                } catch (TimeoutException) {
                    Assert.Inconclusive("Timed out.");
                } catch (Exception ex) {
                    Assert.Fail(ex.Message);
                } finally {
                    stream?.Dispose();
                }
            }
        }