Skip to content
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
33 changes: 33 additions & 0 deletions Snowflake.Data.Tests/UnitTests/SFS3ClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,39 @@ public void TestAppendHttpsToEndpointWithBrackets()
Assert.That(amazonS3Client.ServiceURL, Is.EqualTo(expectedEndpoint));
}

[Test]
public void TestServiceUrlIsSetWhenEndpointAndRegionAreProvided()
{
// Arrange
var amazonS3Client = new AmazonS3Config();
var endpoint = "endpointWithNoHttps.com";
var expectedEndpoint = "https://endpointWithNoHttps.com";
var mockRegion = "fakeRegion";

// ACT
SFS3Client.SetCommonClientConfig(amazonS3Client, mockRegion, endpoint, 1, 0);

// Assert
Assert.That(amazonS3Client.ServiceURL, Is.EqualTo(expectedEndpoint));
Assert.IsNull(amazonS3Client.RegionEndpoint);
}

[Test]
public void TestRegionEndpointIsSetWhenOnlyRegionIsProvided()
{
// Arrange
var amazonS3Client = new AmazonS3Config();
var expectedRegionEndpoint = RegionEndpoint.USEast2;
var region = expectedRegionEndpoint.SystemName;

// ACT
SFS3Client.SetCommonClientConfig(amazonS3Client, region, string.Empty, 1, 0);

// Assert
Assert.That(amazonS3Client.RegionEndpoint, Is.EqualTo(expectedRegionEndpoint));
Assert.IsNull(amazonS3Client.ServiceURL);
}

[Test]
[TestCase(MockS3Client.AwsStatusOk, ResultStatus.UPLOADED)]
[TestCase(SFS3Client.EXPIRED_TOKEN, ResultStatus.RENEW_TOKEN)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,10 @@ internal static void SetCommonClientConfig(

clientConfig.ServiceURL = endpoint;
}

// The region information used to determine the endpoint for the service.
// RegionEndpoint and ServiceURL are mutually exclusive properties.
// If both stageInfo.endPoint and stageInfo.region have a value, stageInfo.region takes
// precedence and ServiceUrl will be reset to null.
if ((null != region) && (0 != region.Length))
// If both stageInfo.endPoint and stageInfo.region have a value, the endPoint takes precedence
else if ((null != region) && (0 != region.Length))
{
RegionEndpoint regionEndpoint = RegionEndpoint.GetBySystemName(region);
clientConfig.RegionEndpoint = regionEndpoint;
Expand Down