Skip to content

Commit

Permalink
Fix automatic addition of protocol in discovery endpoint (opensearch-…
Browse files Browse the repository at this point in the history
…project#11612)

* Fix opensearch-project#11609

Signed-off-by: Yanlong He <[email protected]>

* Fix opensearch-project#11609

Signed-off-by: heyanlong <[email protected]>

* Update AwsEc2ServiceImplTests.java

Signed-off-by: 何延龙 <[email protected]>

* spotless

Signed-off-by: heyanlong <[email protected]>

---------

Signed-off-by: Yanlong He <[email protected]>
Signed-off-by: heyanlong <[email protected]>
Signed-off-by: 何延龙 <[email protected]>
  • Loading branch information
heyanlong authored and rayshrey committed Mar 18, 2024
1 parent 74e6520 commit 5726449
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix remote shards balancer and remove unused variables ([#11167](https://github.com/opensearch-project/OpenSearch/pull/11167))
- Fix bug where replication lag grows post primary relocation ([#11238](https://github.com/opensearch-project/OpenSearch/pull/11238))
- Fix template setting override for replication type ([#11417](https://github.com/opensearch-project/OpenSearch/pull/11417))
- Fix Automatic addition of protocol broken in #11512 ([#11609](https://github.com/opensearch-project/OpenSearch/pull/11609))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected String getFullEndpoint(String endpoint) {
if (!Strings.hasText(endpoint)) {
return null;
}
if (endpoint.startsWith("http")) {
if (endpoint.startsWith("http://") || endpoint.startsWith("https://")) {
return endpoint;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ public void testGetFullEndpointWithScheme() {

String endpoint = awsEc2ServiceImpl.getFullEndpoint(clientSettings.endpoint);
assertEquals("http://ec2.us-west-2.amazonaws.com", endpoint);

assertEquals("http://httpserver.example.com", awsEc2ServiceImpl.getFullEndpoint("http://httpserver.example.com"));

assertEquals("https://httpserver.example.com", awsEc2ServiceImpl.getFullEndpoint("https://httpserver.example.com"));
}

public void testGetFullEndpointWithoutScheme() {
Expand All @@ -222,6 +226,8 @@ public void testGetFullEndpointWithoutScheme() {
String endpoint = awsEc2ServiceImpl.getFullEndpoint(clientSettings.endpoint);
assertEquals("https://ec2.us-west-2.amazonaws.com", endpoint);

assertEquals("https://httpserver.example.com", awsEc2ServiceImpl.getFullEndpoint("httpserver.example.com"));

assertNull(awsEc2ServiceImpl.getFullEndpoint(""));
}
}

0 comments on commit 5726449

Please sign in to comment.