-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-1789757 Support GCP region specific endpoint
- Loading branch information
1 parent
d212fc7
commit 7ae1104
Showing
4 changed files
with
147 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using Snowflake.Data.Core; | ||
using Snowflake.Data.Core.FileTransfer; | ||
|
||
namespace Snowflake.Data.Tests.UnitTests | ||
{ | ||
[TestFixture] | ||
public class PutGetStageInfoTest | ||
{ | ||
[Test] | ||
[TestCaseSource(nameof(TestCases))] | ||
public void TestGcmRegionalUrl(string region, bool useRegionalUrl, string endPoint, string expectedGcmEndpoint) | ||
{ | ||
// arrange | ||
var stageInfo = CreateGCSStageInfo(region, useRegionalUrl, endPoint); | ||
|
||
// act | ||
var gcsCustomEndpoint = stageInfo.GcsCustomEndpoint(); | ||
|
||
// assert | ||
Assert.AreEqual(expectedGcmEndpoint, gcsCustomEndpoint); | ||
} | ||
|
||
internal static IEnumerable<object[]> TestCases() | ||
{ | ||
yield return new object[] { "US-CENTRAL1", false, null, null }; | ||
yield return new object[] { "US-CENTRAL1", false, "", null }; | ||
yield return new object[] { "US-CENTRAL1", false, "null", null }; | ||
yield return new object[] { "US-CENTRAL1", false, " ", null }; | ||
yield return new object[] { "US-CENTRAL1", false, "example.com", "example.com" }; | ||
yield return new object[] { "ME-CENTRAL2", false, null, "storage.me-central2.rep.googleapis.com" }; | ||
yield return new object[] { "ME-CENTRAL2", true, null, "storage.me-central2.rep.googleapis.com" }; | ||
yield return new object[] { "ME-CENTRAL2", true, "", "storage.me-central2.rep.googleapis.com" }; | ||
yield return new object[] { "ME-CENTRAL2", true, " ", "storage.me-central2.rep.googleapis.com" }; | ||
yield return new object[] { "ME-CENTRAL2", true, "example.com", "example.com" }; | ||
yield return new object[] { "US-CENTRAL1", true, null, "storage.us-central1.rep.googleapis.com" }; | ||
yield return new object[] { "US-CENTRAL1", true, "", "storage.us-central1.rep.googleapis.com" }; | ||
yield return new object[] { "US-CENTRAL1", true, " ", "storage.us-central1.rep.googleapis.com" }; | ||
yield return new object[] { "US-CENTRAL1", true, "null", "storage.us-central1.rep.googleapis.com" }; | ||
yield return new object[] { "US-CENTRAL1", true, "example.com", "example.com" }; | ||
} | ||
|
||
private PutGetStageInfo CreateGCSStageInfo(string region, bool useRegionalUrl, string endPoint) => | ||
new PutGetStageInfo | ||
{ | ||
locationType = SFRemoteStorageUtil.GCS_FS, | ||
location = "some location", | ||
path = "some path", | ||
region = region, | ||
storageAccount = "some storage account", | ||
isClientSideEncrypted = true, | ||
stageCredentials = new Dictionary<string, string>(), | ||
presignedUrl = "some pre-signed url", | ||
endPoint = endPoint, | ||
useRegionalUrl = useRegionalUrl | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters