Skip to content

Commit

Permalink
Fix automatic addition of protocol in discovery endpoint (#11612)
Browse files Browse the repository at this point in the history
* Fix #11609

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

* Fix #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 Dec 18, 2023
1 parent 51cab98 commit 2b1c9ae
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 2b1c9ae

Please sign in to comment.