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(); } } }
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(); } } }