Skip to content

Commit fc5beb8

Browse files
Merge branch 'main' into depr-constants
2 parents e6a56ec + 01dd98c commit fc5beb8

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/main/java/org/opensearch/security/rest/DashboardsInfoAction.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@
5151
import static org.opensearch.rest.RestRequest.Method.GET;
5252
import static org.opensearch.rest.RestRequest.Method.POST;
5353
import static org.opensearch.security.dlic.rest.support.Utils.LEGACY_PLUGIN_ROUTE_PREFIX;
54-
import static org.opensearch.security.dlic.rest.support.Utils.OPENDISTRO_API_DEPRECATION_MESSAGE;
5554
import static org.opensearch.security.dlic.rest.support.Utils.PLUGIN_ROUTE_PREFIX;
5655
import static org.opensearch.security.dlic.rest.support.Utils.addDeprecatedRoutesPrefix;
5756
import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix;
5857

5958
public class DashboardsInfoAction extends BaseRestHandler {
6059

60+
private static final String KIBANAINFO_ROUTE_DEPRECATION_MESSAGE =
61+
"[_opendistro/_security/kibanainfo] is a deprecated endpoint path. Please use _plugins/_security/dashboardsinfo instead.";;
62+
6163
private static final List<Route> routes = ImmutableList.<Route>builder()
6264
.addAll(
6365
addRoutesPrefix(ImmutableList.of(new Route(GET, "/dashboardsinfo"), new Route(POST, "/dashboardsinfo")), PLUGIN_ROUTE_PREFIX)
@@ -68,8 +70,8 @@ public class DashboardsInfoAction extends BaseRestHandler {
6870
.addAll(
6971
addDeprecatedRoutesPrefix(
7072
ImmutableList.of(
71-
new DeprecatedRoute(GET, "/kibanainfo", OPENDISTRO_API_DEPRECATION_MESSAGE),
72-
new DeprecatedRoute(POST, "/kibanainfo", OPENDISTRO_API_DEPRECATION_MESSAGE)
73+
new DeprecatedRoute(GET, "/kibanainfo", KIBANAINFO_ROUTE_DEPRECATION_MESSAGE),
74+
new DeprecatedRoute(POST, "/kibanainfo", KIBANAINFO_ROUTE_DEPRECATION_MESSAGE)
7375
),
7476
LEGACY_PLUGIN_ROUTE_PREFIX
7577
)

src/main/java/org/opensearch/security/tools/democonfig/Installer.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -330,19 +330,21 @@ void setSecurityVariables() {
330330

331331
// Extract OpenSearch version and Security version
332332
File[] opensearchLibFiles = new File(OPENSEARCH_LIB_PATH).listFiles(
333-
pathname -> pathname.getName().matches("opensearch-core-(.*).jar")
333+
pathname -> pathname.getName().matches("opensearch-core-(\\d+(\\.\\d+)*(-[a-zA-Z0-9]+)?(-SNAPSHOT)?).jar")
334334
);
335335

336336
if (opensearchLibFiles != null && opensearchLibFiles.length > 0) {
337-
OPENSEARCH_VERSION = opensearchLibFiles[0].getName().replaceAll("opensearch-core-(.*).jar", "$1");
337+
OPENSEARCH_VERSION = opensearchLibFiles[0].getName()
338+
.replaceAll("opensearch-core-(\\d+(\\.\\d+)*(-[a-zA-Z0-9]+)?(-SNAPSHOT)?).jar", "$1");
338339
}
339340

340341
File[] securityFiles = new File(OPENSEARCH_PLUGINS_DIR + "opensearch-security").listFiles(
341-
pathname -> pathname.getName().startsWith("opensearch-security-") && pathname.getName().endsWith(".jar")
342+
pathname -> pathname.getName().matches("opensearch-security-\\d+(\\.\\d+)*(-[a-zA-Z0-9]+)?(-SNAPSHOT)?.jar")
342343
);
343344

344345
if (securityFiles != null && securityFiles.length > 0) {
345-
SECURITY_VERSION = securityFiles[0].getName().replaceAll("opensearch-security-(.*).jar", "$1");
346+
SECURITY_VERSION = securityFiles[0].getName()
347+
.replaceAll("opensearch-security-(\\d+(\\.\\d+)*(-[a-zA-Z0-9]+)?(-SNAPSHOT)?).jar", "$1");
346348
}
347349
}
348350

src/test/java/org/opensearch/security/tools/democonfig/InstallerTests.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void testGatherUserInputs_withoutAssumeYes() {
118118

119119
// set initsecurity and cluster_mode to no
120120
readInputStream("y" + System.lineSeparator() + "n" + System.lineSeparator() + "n" + System.lineSeparator()); // pass all 3 inputs as
121-
// y
121+
// y
122122
installer.gatherUserInputs();
123123

124124
verifyStdOutContainsString("Install demo certificates?");
@@ -134,7 +134,7 @@ public void testGatherUserInputs_withoutAssumeYes() {
134134

135135
// set initsecurity and cluster_mode to no
136136
readInputStream("y" + System.lineSeparator() + "y" + System.lineSeparator() + "y" + System.lineSeparator()); // pass all 3 inputs as
137-
// y
137+
// y
138138
installer.gatherUserInputs();
139139

140140
verifyStdOutContainsString("Install demo certificates?");
@@ -175,7 +175,7 @@ public void testGatherUserInputs_withoutAssumeYes() {
175175
assertThat(installer.cluster_mode, is(true));
176176

177177
readInputStream("y" + System.lineSeparator() + "y" + System.lineSeparator() + "y" + System.lineSeparator()); // pass all 3 inputs as
178-
// y
178+
// y
179179
installer.gatherUserInputs();
180180

181181
verifyStdOutContainsString("Install demo certificates?");
@@ -307,8 +307,8 @@ public void testSetSecurityVariables() {
307307
setUpSecurityDirectories();
308308
installer.setSecurityVariables();
309309

310-
assertThat(installer.OPENSEARCH_VERSION, is(equalTo("osVersion")));
311-
assertThat(installer.SECURITY_VERSION, is(equalTo("version")));
310+
assertThat(installer.OPENSEARCH_VERSION, is(equalTo("3.0.0-Version")));
311+
assertThat(installer.SECURITY_VERSION, is(equalTo("3.0.0.0-version")));
312312
tearDownSecurityDirectories();
313313
}
314314

@@ -481,8 +481,11 @@ public void setUpSecurityDirectories() {
481481
createDirectory(installer.OPENSEARCH_LIB_PATH);
482482
createDirectory(installer.OPENSEARCH_CONF_DIR);
483483
createDirectory(installer.OPENSEARCH_PLUGINS_DIR + "opensearch-security");
484-
createFile(installer.OPENSEARCH_LIB_PATH + "opensearch-core-osVersion.jar");
485-
createFile(installer.OPENSEARCH_PLUGINS_DIR + "opensearch-security" + File.separator + "opensearch-security-version.jar");
484+
createFile(installer.OPENSEARCH_LIB_PATH + "opensearch-core-3.0.0-Version.jar");
485+
createFile(
486+
installer.OPENSEARCH_PLUGINS_DIR + "opensearch-security" + File.separator + "opensearch-security-common-3.0.0.0-version.jar"
487+
);
488+
createFile(installer.OPENSEARCH_PLUGINS_DIR + "opensearch-security" + File.separator + "opensearch-security-3.0.0.0-version.jar");
486489
createFile(installer.OPENSEARCH_CONF_DIR + File.separator + "securityadmin_demo.sh");
487490
}
488491

0 commit comments

Comments
 (0)