Skip to content

Commit

Permalink
Bring default for IsBypassed inline with actual implementation (#88)
Browse files Browse the repository at this point in the history
* Bring default for IsBypassed inline with actual implementation

* make proxy setting conditional
  • Loading branch information
Mpdreamz authored Jul 11, 2023
1 parent c54ded8 commit 04320b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ internal class WebProxy : IWebProxy

public Uri GetProxy(Uri destination) => _uri;

public bool IsBypassed(Uri host) => host.IsLoopback;
public bool IsBypassed(Uri host) => false;
}
#endif
24 changes: 15 additions & 9 deletions tests/Elastic.Elasticsearch.IntegrationTests/DefaultCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information

using Elastic.Elasticsearch.Ephemeral;
using Elastic.Elasticsearch.Managed;
using Elastic.Elasticsearch.Xunit;
using Elastic.Transport;
using Elastic.Transport.Products.Elasticsearch;
Expand All @@ -18,24 +19,24 @@ namespace Elastic.Elasticsearch.IntegrationTests;
public class DefaultCluster : XunitClusterBase
{
protected static string Version = "8.7.0";
public DefaultCluster() : this(new XunitClusterConfiguration(Version) { StartingPortNumber = 9202 }) { }

public DefaultCluster() : this(new XunitClusterConfiguration(Version) { StartingPortNumber = 9202, AutoWireKnownProxies = true }) { }

public DefaultCluster(XunitClusterConfiguration xunitClusterConfiguration) : base(xunitClusterConfiguration) { }

public DefaultHttpTransport CreateClient(ITestOutputHelper output) =>
this.GetOrAddClient(_ =>
this.GetOrAddClient(cluster =>
{
var hostName = (System.Diagnostics.Process.GetProcessesByName("mitmproxy").Any()
? "ipv4.fiddler"
: "localhost");
var nodes = NodesUris(hostName);
var nodes = NodesUris();
var connectionPool = new StaticNodePool(nodes);
var settings = new TransportConfiguration(connectionPool, productRegistration: ElasticsearchProductRegistration.Default)
.Proxy(new Uri("http://ipv4.fiddler:8080"), null!, null!)
.RequestTimeout(TimeSpan.FromSeconds(5))
.ServerCertificateValidationCallback(CertificateValidations.AllowAll)
.OnRequestCompleted(d =>
{
try { output.WriteLine(d.DebugInformation);}
try
{
output.WriteLine(d.DebugInformation);
}
catch
{
// ignored
Expand All @@ -44,6 +45,11 @@ public DefaultHttpTransport CreateClient(ITestOutputHelper output) =>
.EnableDebugMode();
if (ClusterConfiguration.Features.HasFlag(ClusterFeatures.Security))
settings = settings.Authentication(new BasicAuthentication(Admin.Username, Admin.Password));
if (cluster.DetectedProxy != DetectedProxySoftware.None)
settings = settings.Proxy(new Uri("http://localhost:8080"));
if (ClusterConfiguration.Features.HasFlag(ClusterFeatures.SSL))
settings = settings.ServerCertificateValidationCallback(CertificateValidations.AllowAll);
return new DefaultHttpTransport(settings);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Elastic.Elasticsearch.Xunit" Version="0.4.1" />
<PackageReference Include="Elastic.Elasticsearch.Xunit" Version="0.4.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down

0 comments on commit 04320b1

Please sign in to comment.