-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andy Lin
committed
May 21, 2021
1 parent
19302eb
commit e6da580
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/test/java/org/opensearch/security/SecuritySettingsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
package org.opensearch.security; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.security.support.LegacyOpenDistroSecuritySettings; | ||
import org.opensearch.security.support.SecuritySettings; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class SecuritySettingsTests { | ||
|
||
@Test | ||
public void testLegacyOpenDistroSettingsFallback() { | ||
Assert.assertEquals( | ||
SecuritySettings.SECURITY_ADVANCED_MODULES_ENABLED.get(Settings.EMPTY), | ||
LegacyOpenDistroSecuritySettings.SECURITY_ADVANCED_MODULES_ENABLED.get(Settings.EMPTY) | ||
); | ||
} | ||
|
||
@Test | ||
public void testSettingsGetValue() { | ||
Settings settings = Settings.builder().put("plugins.security.disabled", false).build(); | ||
Assert.assertEquals(SecuritySettings.SECURITY_DISABLED.get(settings), false); | ||
Assert.assertEquals(LegacyOpenDistroSecuritySettings.SECURITY_DISABLED.get(settings), false); | ||
} | ||
|
||
@Test | ||
public void testSettingsGetValueWithLegacyFallback() { | ||
Settings settings = Settings.builder() | ||
.put("opendistro_security.disabled", false) | ||
.put("opendistro_security.config_index_name", "test") | ||
.build(); | ||
|
||
Assert.assertEquals(SecuritySettings.SECURITY_DISABLED.get(settings), false); | ||
Assert.assertEquals(SecuritySettings.SECURITY_CONFIG_INDEX_NAME.get(settings), "test"); | ||
|
||
} | ||
} |