Skip to content

Commit

Permalink
Fix Bug with Install demo configuration running in cluster mode with …
Browse files Browse the repository at this point in the history
…-y (#3935)


Previous behavior prior to 2.11 would be that init security and cluster
mode would only be set if they were explicitly passed in. There is a
small bug that is setting them to be true if -y is passed in. This is
causing a few failures with duplicate keys in integration tests when -y
is passed in.

https://github.com/opensearch-project/security/blob/2.11/tools/install_demo_configuration.sh#L73-L98

---------

Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho authored Jan 10, 2024
1 parent 649a2fc commit f217fa8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,6 @@ void gatherUserInputs() {
cluster_mode = confirmAction(scanner, "Enable cluster mode?");
}
}
} else {
initsecurity = true;
cluster_mode = true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ public void testGatherInputs_withAssumeYes() {

installer.gatherUserInputs();

assertThat(installer.initsecurity, is(true));
assertThat(installer.cluster_mode, is(true));
assertThat(installer.initsecurity, is(false));
assertThat(installer.cluster_mode, is(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ public void testIsStringAlreadyPresentInFile_isPresent() throws IOException {
assertThat(isKeyPresentInYMLFile(installer.OPENSEARCH_CONF_FILE, str2), is(equalTo(false)));
}

@Test
public void testAssumeYesDoesNotInitializeClusterMode() throws IOException {
String nodeName = "node.name"; // cluster_mode
String securityIndex = "plugins.security.allow_default_init_securityindex"; // init_security

installer.assumeyes = true;
securitySettingsConfigurer.writeSecurityConfigToOpenSearchYML();

assertThat(isKeyPresentInYMLFile(installer.OPENSEARCH_CONF_FILE, nodeName), is(false));
assertThat(isKeyPresentInYMLFile(installer.OPENSEARCH_CONF_FILE, securityIndex), is(false));
}

@Test
public void testCreateSecurityAdminDemoScriptAndGetSecurityAdminCommands() throws IOException {
String demoPath = installer.OPENSEARCH_CONF_DIR + "securityadmin_demo" + installer.FILE_EXTENSION;
Expand Down

0 comments on commit f217fa8

Please sign in to comment.