Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring default for IsBypassed inline with actual implementation #88

Merged
merged 3 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading