Skip to content

Commit

Permalink
Applying PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jmartinezramirez committed Apr 3, 2024
1 parent 613710e commit 1b2204b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@ Examples:
- `*.myserver.com | *testaccount*` (You can specify multiple regex for the property divided by `|`)


> Note: If you only specify the hostname in the property if will not be bypass because should match the full url including the http or https section.

- `myaccount.snowflakecomputing.com` (This will not be bypassed).
> Note: The nonproxyhost value should match the full url including the http or https section. The '*' wilcard could be added to bypass the hostname successfully.

- `myaccount.snowflakecomputing.com` (Not bypassed).
- `*myaccount.snowflakecomputing.com` (Bypassed).


## Using Connection Pools
Expand Down
28 changes: 17 additions & 11 deletions Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,16 +1549,21 @@ public void TestInvalidProxySettingFromConnectionString()
[TestCase("^nonmatch*{0}$|*")]
[TestCase("*a*", "a")]
[TestCase("*la*", "la")]
public void TestNonProxyHostShouldBypassProxyServer(string regexHost, string proxyHost = null)
public void TestNonProxyHostShouldBypassProxyServer(string regexHost, string proxyHost = "proxyserverhost")
{
using (var conn = new SnowflakeDbConnection())
{
// Arrange
var host = ResolveHostToUseFromTestConfig(ConnectionString);

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Linux (net6.0, AZURE)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Linux (net6.0, AZURE)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Linux (net6.0, GCP)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Linux (net6.0, GCP)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Linux (net6.0, AWS)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Linux (net6.0, AWS)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net472, AZURE)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net472, AZURE)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net471, AWS)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net471, AWS)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net472, AWS)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net472, AWS)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net6.0, GCP)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net6.0, GCP)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net472, GCP)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net471, GCP)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net472, GCP)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net471, GCP)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net471, AZURE)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net471, AZURE)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net6.0, AWS)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net6.0, AWS)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net6.0, AZURE)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on Windows (net6.0, AZURE)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on MAC (net6.0, AZURE)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on MAC (net6.0, AZURE)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on MAC (net6.0, GCP)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on MAC (net6.0, GCP)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on MAC (net6.0, AWS)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments

Check failure on line 1557 in Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs

View workflow job for this annotation

GitHub Actions / Tests on MAC (net6.0, AWS)

No overload for method 'ResolveHostToUseFromTestConfig' takes 1 arguments
var nonProxyHosts = string.Format(regexHost, $"{host}");
var proxyHostForConnection = proxyHost ?? "proxyserverhost";
conn.ConnectionString =
$"{ConnectionString}USEPROXY=true;PROXYHOST={proxyHostForConnection};NONPROXYHOSTS={nonProxyHosts};PROXYPORT=3128;";
$"{ConnectionString}USEPROXY=true;PROXYHOST={proxyHost};NONPROXYHOSTS={nonProxyHosts};PROXYPORT=3128;";

// Act
conn.Open();

// Assert
// If the connection is open, it indicates that the server proxy was bypassed.
Assert.AreEqual(ConnectionState.Open, conn.State);
}
}
Expand All @@ -1570,15 +1575,21 @@ public void TestNonProxyHostShouldBypassProxyServer(string regexHost, string pro
[TestCase("*a.b")]
[TestCase("a", "a")]
[TestCase("la", "la")]
public void TestNonProxyHostShouldNotBypassProxyServer(string regexHost, string proxyHost = null)
public void TestNonProxyHostShouldNotBypassProxyServer(string regexHost, string proxyHost = "proxyserverhost")
{
using (var conn = new SnowflakeDbConnection())
{
// Arrange
var nonProxyHosts = string.Format(regexHost, $"{testConfig.host}");
var proxyHostForConnection = proxyHost ?? "proxyserverhost";
conn.ConnectionString =
$"{ConnectionString}connection_timeout=5;USEPROXY=true;PROXYHOST={proxyHostForConnection};NONPROXYHOSTS={nonProxyHosts};PROXYPORT=3128;";
$"{ConnectionString}connection_timeout=5;USEPROXY=true;PROXYHOST={proxyHost};NONPROXYHOSTS={nonProxyHosts};PROXYPORT=3128;";

// Act/Assert
// If the nonproxyhosts property fails to bypass the server, the proxy will be use but it will return a exception
// because is not configure in the testing environment so the exception is used to verify that was not bypass.
var exception = Assert.Throws<SnowflakeDbException>(() => conn.Open());

// Assert
s_logger.Debug("Failed opening connection ", exception);
Assert.AreEqual(270001, exception.ErrorCode);
AssertIsConnectionFailure(exception);
Expand Down Expand Up @@ -1835,11 +1846,6 @@ public void TestKeepAlive()
Assert.Fail();
}
}

private string ResolveHostToUseFromTestConfig(string connectionString)
{
return testConfig.host ?? $"{testConfig.account}.snowflakecomputing.com";
}
}

[TestFixture]
Expand Down
5 changes: 5 additions & 0 deletions Snowflake.Data.Tests/SFBaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ public SFBaseTestAsync()
testConfig.password);

protected TestConfig testConfig { get; }

protected string ResolveHostToUseFromTestConfig()
{
return testConfig.host ?? $"{testConfig.account}.snowflakecomputing.com";
}
}

[SetUpFixture]
Expand Down
3 changes: 0 additions & 3 deletions Snowflake.Data/Core/HttpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
using System.Collections.Specialized;
using System.Web;
using System.Security.Authentication;
using System.Runtime.InteropServices;
using System.Linq;
using Snowflake.Data.Core.Authenticator;

namespace Snowflake.Data.Core
{
using System.Text.RegularExpressions;

public class HttpClientConfig
{
public HttpClientConfig(
Expand Down

0 comments on commit 1b2204b

Please sign in to comment.