-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make order setting required for Realm config (#51195)
The order config must be explicitly specified for each realm. It must also be unique for each realm. This is a breaking change and will begin to take effect in 8.0 Resolves: #37614
- Loading branch information
Showing
55 changed files
with
444 additions
and
157 deletions.
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
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
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
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
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
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
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
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
51 changes: 51 additions & 0 deletions
51
...ugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/RealmConfigTests.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,51 @@ | ||
/* | ||
* | ||
* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* * or more contributor license agreements. Licensed under the Elastic License; | ||
* * you may not use this file except in compliance with the Elastic License. | ||
* | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.security.authc; | ||
|
||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.util.concurrent.ThreadContext; | ||
import org.elasticsearch.env.Environment; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.junit.Before; | ||
import org.mockito.Mockito; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
|
||
public class RealmConfigTests extends ESTestCase { | ||
|
||
private RealmConfig.RealmIdentifier realmIdentifier; | ||
private Settings globalSettings; | ||
private Environment environment; | ||
private ThreadContext threadContext; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
realmIdentifier = new RealmConfig.RealmIdentifier(randomAlphaOfLengthBetween(4, 12), randomAlphaOfLengthBetween(4,12)); | ||
environment = Mockito.mock(Environment.class); | ||
globalSettings = Settings.builder().put("path.home", createTempDir()).build(); | ||
threadContext = new ThreadContext(globalSettings); | ||
super.setUp(); | ||
} | ||
|
||
public void testWillPassWhenOrderSettingIsConfigured() { | ||
Settings settings = Settings.builder() | ||
.put(globalSettings) | ||
.put(RealmSettings.realmSettingPrefix(realmIdentifier) + "order", 0) | ||
.build(); | ||
|
||
RealmConfig realmConfig = new RealmConfig(realmIdentifier, settings, environment, threadContext); | ||
assertEquals(0, realmConfig.order); | ||
} | ||
|
||
public void testWillFailWhenOrderSettingIsMissing() { | ||
Settings settings = Settings.builder().put(globalSettings).build(); | ||
var e = expectThrows(IllegalArgumentException.class, () -> new RealmConfig(realmIdentifier, settings, environment, threadContext)); | ||
assertThat(e.getMessage(), containsString("'order' is a mandatory parameter for realm config")); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.