Remove deprecated RealmConfig constructor (#35327)
This removes an obsolete constructor that was still being called from some tests. Relates: #30241
This commit is contained in:
parent
2395e16d84
commit
b4173c8393
|
@ -23,12 +23,6 @@ public class RealmConfig {
|
||||||
private final Settings globalSettings;
|
private final Settings globalSettings;
|
||||||
private final ThreadContext threadContext;
|
private final ThreadContext threadContext;
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public RealmConfig(RealmIdentifier identifier, Settings settings, Settings globalSettings, Environment env,
|
|
||||||
ThreadContext threadContext) {
|
|
||||||
this(identifier, globalSettings, env, threadContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RealmConfig(RealmIdentifier identifier, Settings globalSettings, Environment env,
|
public RealmConfig(RealmIdentifier identifier, Settings globalSettings, Environment env,
|
||||||
ThreadContext threadContext) {
|
ThreadContext threadContext) {
|
||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.security.authc;
|
||||||
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||||
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.env.TestEnvironment;
|
import org.elasticsearch.env.TestEnvironment;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
@ -46,12 +47,13 @@ public class InternalRealmsTests extends ESTestCase {
|
||||||
verifyZeroInteractions(securityIndex);
|
verifyZeroInteractions(securityIndex);
|
||||||
|
|
||||||
Settings settings = Settings.builder().put("path.home", createTempDir()).build();
|
Settings settings = Settings.builder().put("path.home", createTempDir()).build();
|
||||||
factories.get(NativeRealmSettings.TYPE).create(new RealmConfig(new RealmConfig.RealmIdentifier(NativeRealmSettings.TYPE, "test"),
|
final RealmConfig.RealmIdentifier realmId = new RealmConfig.RealmIdentifier(NativeRealmSettings.TYPE, "test");
|
||||||
Settings.EMPTY, settings, TestEnvironment.newEnvironment(settings), new ThreadContext(settings)));
|
final Environment env = TestEnvironment.newEnvironment(settings);
|
||||||
|
final ThreadContext threadContext = new ThreadContext(settings);
|
||||||
|
factories.get(NativeRealmSettings.TYPE).create(new RealmConfig(realmId, settings, env, threadContext));
|
||||||
verify(securityIndex).addIndexStateListener(isA(BiConsumer.class));
|
verify(securityIndex).addIndexStateListener(isA(BiConsumer.class));
|
||||||
|
|
||||||
factories.get(NativeRealmSettings.TYPE).create(new RealmConfig(new RealmConfig.RealmIdentifier(NativeRealmSettings.TYPE, "test"),
|
factories.get(NativeRealmSettings.TYPE).create(new RealmConfig(realmId, settings, env, threadContext));
|
||||||
Settings.EMPTY, settings, TestEnvironment.newEnvironment(settings), new ThreadContext(settings)));
|
|
||||||
verify(securityIndex, times(2)).addIndexStateListener(isA(BiConsumer.class));
|
verify(securityIndex, times(2)).addIndexStateListener(isA(BiConsumer.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ public class NativeRealmTests extends ESTestCase {
|
||||||
final AtomicInteger numInvalidation = new AtomicInteger(0);
|
final AtomicInteger numInvalidation = new AtomicInteger(0);
|
||||||
int expectedInvalidation = 0;
|
int expectedInvalidation = 0;
|
||||||
Settings settings = Settings.builder().put("path.home", createTempDir()).build();
|
Settings settings = Settings.builder().put("path.home", createTempDir()).build();
|
||||||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("native", "native"), Settings.EMPTY,
|
RealmConfig.RealmIdentifier realmId = new RealmConfig.RealmIdentifier("native", "native");
|
||||||
settings, TestEnvironment.newEnvironment(settings), new ThreadContext(settings));
|
RealmConfig config = new RealmConfig(realmId, settings, TestEnvironment.newEnvironment(settings), new ThreadContext(settings));
|
||||||
final NativeRealm nativeRealm = new NativeRealm(config, mock(NativeUsersStore.class), threadPool) {
|
final NativeRealm nativeRealm = new NativeRealm(config, mock(NativeUsersStore.class), threadPool) {
|
||||||
@Override
|
@Override
|
||||||
void clearCache() {
|
void clearCache() {
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class FileUserPasswdStoreTests extends ESTestCase {
|
||||||
|
|
||||||
private RealmConfig getRealmConfig(Settings fileSettings) {
|
private RealmConfig getRealmConfig(Settings fileSettings) {
|
||||||
final RealmConfig.RealmIdentifier identifier = new RealmConfig.RealmIdentifier("file", "file-test");
|
final RealmConfig.RealmIdentifier identifier = new RealmConfig.RealmIdentifier("file", "file-test");
|
||||||
return new RealmConfig(identifier, fileSettings, settings, env, threadPool.getThreadContext());
|
return new RealmConfig(identifier, settings, env, threadPool.getThreadContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStore_AutoReload_WithParseFailures() throws Exception {
|
public void testStore_AutoReload_WithParseFailures() throws Exception {
|
||||||
|
|
|
@ -74,12 +74,8 @@ public class FileUserRolesStoreTests extends ESTestCase {
|
||||||
// writing in utf_16 should cause a parsing error as we try to read the file in utf_8
|
// writing in utf_16 should cause a parsing error as we try to read the file in utf_8
|
||||||
Files.write(file, lines, StandardCharsets.UTF_16);
|
Files.write(file, lines, StandardCharsets.UTF_16);
|
||||||
|
|
||||||
Settings fileSettings = randomBoolean() ? Settings.EMPTY : Settings.builder()
|
RealmConfig.RealmIdentifier realmId = new RealmConfig.RealmIdentifier("file", "file-test");
|
||||||
.put("files.users_roles", file.toAbsolutePath())
|
RealmConfig config = new RealmConfig(realmId, settings, env, new ThreadContext(Settings.EMPTY));
|
||||||
.build();
|
|
||||||
|
|
||||||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("file", "file-test"), fileSettings, settings, env,
|
|
||||||
new ThreadContext(Settings.EMPTY));
|
|
||||||
ResourceWatcherService watcherService = new ResourceWatcherService(settings, threadPool);
|
ResourceWatcherService watcherService = new ResourceWatcherService(settings, threadPool);
|
||||||
FileUserRolesStore store = new FileUserRolesStore(config, watcherService);
|
FileUserRolesStore store = new FileUserRolesStore(config, watcherService);
|
||||||
assertThat(store.entriesCount(), is(0));
|
assertThat(store.entriesCount(), is(0));
|
||||||
|
@ -90,12 +86,9 @@ public class FileUserRolesStoreTests extends ESTestCase {
|
||||||
Path tmp = getUsersRolesPath();
|
Path tmp = getUsersRolesPath();
|
||||||
Files.copy(users, tmp, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(users, tmp, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
Settings fileSettings = randomBoolean() ? Settings.EMPTY : Settings.builder()
|
|
||||||
.put("files.users_roles", tmp.toAbsolutePath())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("file", "file-test"), fileSettings, settings, env,
|
final RealmConfig.RealmIdentifier realmId = new RealmConfig.RealmIdentifier("file", "file-test");
|
||||||
new ThreadContext(Settings.EMPTY));
|
RealmConfig config = new RealmConfig(realmId, settings, env, new ThreadContext(Settings.EMPTY));
|
||||||
ResourceWatcherService watcherService = new ResourceWatcherService(settings, threadPool);
|
ResourceWatcherService watcherService = new ResourceWatcherService(settings, threadPool);
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
|
@ -129,12 +122,8 @@ public class FileUserRolesStoreTests extends ESTestCase {
|
||||||
Path tmp = getUsersRolesPath();
|
Path tmp = getUsersRolesPath();
|
||||||
Files.copy(users, tmp, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(users, tmp, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
Settings fileSettings = randomBoolean() ? Settings.EMPTY : Settings.builder()
|
final RealmConfig.RealmIdentifier realmId = new RealmConfig.RealmIdentifier("file", "file-test");
|
||||||
.put("files.users_roles", tmp.toAbsolutePath())
|
RealmConfig config = new RealmConfig(realmId, settings, env, new ThreadContext(Settings.EMPTY));
|
||||||
.build();
|
|
||||||
|
|
||||||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("file", "file-test"), fileSettings, settings, env,
|
|
||||||
new ThreadContext(Settings.EMPTY));
|
|
||||||
ResourceWatcherService watcherService = new ResourceWatcherService(settings, threadPool);
|
ResourceWatcherService watcherService = new ResourceWatcherService(settings, threadPool);
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
|
@ -222,13 +211,9 @@ public class FileUserRolesStoreTests extends ESTestCase {
|
||||||
.put("path.home", createTempDir())
|
.put("path.home", createTempDir())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Settings fileSettings = randomBoolean() ? Settings.EMPTY : Settings.builder()
|
|
||||||
.put("files.users_roles", usersRoles.toAbsolutePath())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Environment env = TestEnvironment.newEnvironment(settings);
|
Environment env = TestEnvironment.newEnvironment(settings);
|
||||||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("file", "file-test"), fileSettings, settings, env,
|
final RealmConfig.RealmIdentifier realmId = new RealmConfig.RealmIdentifier("file", "file-test");
|
||||||
new ThreadContext(Settings.EMPTY));
|
RealmConfig config = new RealmConfig(realmId, settings, env, new ThreadContext(Settings.EMPTY));
|
||||||
ResourceWatcherService watcherService = new ResourceWatcherService(settings, threadPool);
|
ResourceWatcherService watcherService = new ResourceWatcherService(settings, threadPool);
|
||||||
FileUserRolesStore store = new FileUserRolesStore(config, watcherService);
|
FileUserRolesStore store = new FileUserRolesStore(config, watcherService);
|
||||||
assertThat(store.roles("user"), equalTo(Strings.EMPTY_ARRAY));
|
assertThat(store.roles("user"), equalTo(Strings.EMPTY_ARRAY));
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class KerberosRealmAuthenticateFailedTests extends KerberosRealmTestCase
|
||||||
public void testDelegatedAuthorizationFailedToResolve() throws Exception {
|
public void testDelegatedAuthorizationFailedToResolve() throws Exception {
|
||||||
final String username = randomPrincipalName();
|
final String username = randomPrincipalName();
|
||||||
final MockLookupRealm otherRealm = new MockLookupRealm(new RealmConfig(new RealmConfig.RealmIdentifier("mock", "other_realm"),
|
final MockLookupRealm otherRealm = new MockLookupRealm(new RealmConfig(new RealmConfig.RealmIdentifier("mock", "other_realm"),
|
||||||
Settings.EMPTY, globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)));
|
globalSettings, TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings)));
|
||||||
final User lookupUser = new User(randomAlphaOfLength(5));
|
final User lookupUser = new User(randomAlphaOfLength(5));
|
||||||
otherRealm.registerUser(lookupUser);
|
otherRealm.registerUser(lookupUser);
|
||||||
|
|
||||||
|
|
|
@ -324,13 +324,13 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAuthenticateContract() throws Exception {
|
public void testAuthenticateContract() throws Exception {
|
||||||
Realm realm = new FailingAuthenticationRealm(Settings.EMPTY, globalSettings, threadPool);
|
Realm realm = new FailingAuthenticationRealm(globalSettings, threadPool);
|
||||||
PlainActionFuture<AuthenticationResult> future = new PlainActionFuture<>();
|
PlainActionFuture<AuthenticationResult> future = new PlainActionFuture<>();
|
||||||
realm.authenticate(new UsernamePasswordToken("user", new SecureString("pass")), future);
|
realm.authenticate(new UsernamePasswordToken("user", new SecureString("pass")), future);
|
||||||
User user = future.actionGet().getUser();
|
User user = future.actionGet().getUser();
|
||||||
assertThat(user, nullValue());
|
assertThat(user, nullValue());
|
||||||
|
|
||||||
realm = new ThrowingAuthenticationRealm(Settings.EMPTY, globalSettings, threadPool);
|
realm = new ThrowingAuthenticationRealm(globalSettings, threadPool);
|
||||||
future = new PlainActionFuture<>();
|
future = new PlainActionFuture<>();
|
||||||
realm.authenticate(new UsernamePasswordToken("user", new SecureString("pass")), future);
|
realm.authenticate(new UsernamePasswordToken("user", new SecureString("pass")), future);
|
||||||
RuntimeException e = expectThrows(RuntimeException.class, future::actionGet);
|
RuntimeException e = expectThrows(RuntimeException.class, future::actionGet);
|
||||||
|
@ -338,13 +338,13 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLookupContract() throws Exception {
|
public void testLookupContract() throws Exception {
|
||||||
Realm realm = new FailingAuthenticationRealm(Settings.EMPTY, globalSettings, threadPool);
|
Realm realm = new FailingAuthenticationRealm(globalSettings, threadPool);
|
||||||
PlainActionFuture<User> future = new PlainActionFuture<>();
|
PlainActionFuture<User> future = new PlainActionFuture<>();
|
||||||
realm.lookupUser("user", future);
|
realm.lookupUser("user", future);
|
||||||
User user = future.actionGet();
|
User user = future.actionGet();
|
||||||
assertThat(user, nullValue());
|
assertThat(user, nullValue());
|
||||||
|
|
||||||
realm = new ThrowingAuthenticationRealm(Settings.EMPTY, globalSettings, threadPool);
|
realm = new ThrowingAuthenticationRealm(globalSettings, threadPool);
|
||||||
future = new PlainActionFuture<>();
|
future = new PlainActionFuture<>();
|
||||||
realm.lookupUser("user", future);
|
realm.lookupUser("user", future);
|
||||||
RuntimeException e = expectThrows(RuntimeException.class, future::actionGet);
|
RuntimeException e = expectThrows(RuntimeException.class, future::actionGet);
|
||||||
|
@ -384,7 +384,7 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase {
|
||||||
final AtomicInteger authCounter = new AtomicInteger(0);
|
final AtomicInteger authCounter = new AtomicInteger(0);
|
||||||
final Hasher pwdHasher = Hasher.resolve(randomFrom("pbkdf2", "pbkdf2_1000", "bcrypt", "bcrypt9"));
|
final Hasher pwdHasher = Hasher.resolve(randomFrom("pbkdf2", "pbkdf2_1000", "bcrypt", "bcrypt9"));
|
||||||
final String passwordHash = new String(pwdHasher.hash(password));
|
final String passwordHash = new String(pwdHasher.hash(password));
|
||||||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("caching", "test_realm"), Settings.EMPTY, globalSettings,
|
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("caching", "test_realm"), globalSettings,
|
||||||
TestEnvironment.newEnvironment(globalSettings), new ThreadContext(Settings.EMPTY));
|
TestEnvironment.newEnvironment(globalSettings), new ThreadContext(Settings.EMPTY));
|
||||||
final CachingUsernamePasswordRealm realm = new CachingUsernamePasswordRealm(config, threadPool) {
|
final CachingUsernamePasswordRealm realm = new CachingUsernamePasswordRealm(config, threadPool) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -450,7 +450,7 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase {
|
||||||
final SecureString randomPassword = new SecureString(randomAlphaOfLength(password.length()).toCharArray());
|
final SecureString randomPassword = new SecureString(randomAlphaOfLength(password.length()).toCharArray());
|
||||||
final Hasher localHasher = Hasher.resolve(randomFrom("pbkdf2", "pbkdf2_1000", "bcrypt", "bcrypt9"));
|
final Hasher localHasher = Hasher.resolve(randomFrom("pbkdf2", "pbkdf2_1000", "bcrypt", "bcrypt9"));
|
||||||
final String passwordHash = new String(localHasher.hash(password));
|
final String passwordHash = new String(localHasher.hash(password));
|
||||||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("caching", "test_realm"), Settings.EMPTY, globalSettings,
|
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("caching", "test_realm"), globalSettings,
|
||||||
TestEnvironment.newEnvironment(globalSettings), new ThreadContext(Settings.EMPTY));
|
TestEnvironment.newEnvironment(globalSettings), new ThreadContext(Settings.EMPTY));
|
||||||
final CachingUsernamePasswordRealm realm = new CachingUsernamePasswordRealm(config, threadPool) {
|
final CachingUsernamePasswordRealm realm = new CachingUsernamePasswordRealm(config, threadPool) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -518,7 +518,7 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase {
|
||||||
final String username = "username";
|
final String username = "username";
|
||||||
final AtomicInteger lookupCounter = new AtomicInteger(0);
|
final AtomicInteger lookupCounter = new AtomicInteger(0);
|
||||||
|
|
||||||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("caching", "test_realm"), Settings.EMPTY, globalSettings,
|
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("caching", "test_realm"), globalSettings,
|
||||||
TestEnvironment.newEnvironment(globalSettings), new ThreadContext(Settings.EMPTY));
|
TestEnvironment.newEnvironment(globalSettings), new ThreadContext(Settings.EMPTY));
|
||||||
final CachingUsernamePasswordRealm realm = new CachingUsernamePasswordRealm(config, threadPool) {
|
final CachingUsernamePasswordRealm realm = new CachingUsernamePasswordRealm(config, threadPool) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -605,8 +605,8 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase {
|
||||||
|
|
||||||
static class FailingAuthenticationRealm extends CachingUsernamePasswordRealm {
|
static class FailingAuthenticationRealm extends CachingUsernamePasswordRealm {
|
||||||
|
|
||||||
FailingAuthenticationRealm(Settings settings, Settings global, ThreadPool threadPool) {
|
FailingAuthenticationRealm(Settings global, ThreadPool threadPool) {
|
||||||
super(new RealmConfig(new RealmConfig.RealmIdentifier("caching", "failing-test"), settings, global,
|
super(new RealmConfig(new RealmConfig.RealmIdentifier("caching", "failing-test"), global,
|
||||||
TestEnvironment.newEnvironment(global),
|
TestEnvironment.newEnvironment(global),
|
||||||
threadPool.getThreadContext()), threadPool);
|
threadPool.getThreadContext()), threadPool);
|
||||||
}
|
}
|
||||||
|
@ -624,8 +624,8 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase {
|
||||||
|
|
||||||
static class ThrowingAuthenticationRealm extends CachingUsernamePasswordRealm {
|
static class ThrowingAuthenticationRealm extends CachingUsernamePasswordRealm {
|
||||||
|
|
||||||
ThrowingAuthenticationRealm(Settings settings, Settings globalSettings, ThreadPool threadPool) {
|
ThrowingAuthenticationRealm(Settings globalSettings, ThreadPool threadPool) {
|
||||||
super(new RealmConfig(new RealmConfig.RealmIdentifier("caching", "throwing-test"), settings, globalSettings,
|
super(new RealmConfig(new RealmConfig.RealmIdentifier("caching", "throwing-test"), globalSettings,
|
||||||
TestEnvironment.newEnvironment(globalSettings),
|
TestEnvironment.newEnvironment(globalSettings),
|
||||||
threadPool.getThreadContext()), threadPool);
|
threadPool.getThreadContext()), threadPool);
|
||||||
}
|
}
|
||||||
|
@ -649,7 +649,7 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase {
|
||||||
private boolean usersEnabled = true;
|
private boolean usersEnabled = true;
|
||||||
|
|
||||||
AlwaysAuthenticateCachingRealm(Settings globalSettings, ThreadPool threadPool) {
|
AlwaysAuthenticateCachingRealm(Settings globalSettings, ThreadPool threadPool) {
|
||||||
this(new RealmConfig(new RealmConfig.RealmIdentifier("caching", "always-test"), Settings.EMPTY, globalSettings,
|
this(new RealmConfig(new RealmConfig.RealmIdentifier("caching", "always-test"), globalSettings,
|
||||||
TestEnvironment.newEnvironment(globalSettings),
|
TestEnvironment.newEnvironment(globalSettings),
|
||||||
threadPool.getThreadContext()), threadPool);
|
threadPool.getThreadContext()), threadPool);
|
||||||
}
|
}
|
||||||
|
@ -682,7 +682,7 @@ public class CachingUsernamePasswordRealmTests extends ESTestCase {
|
||||||
public final AtomicInteger lookupInvocationCounter = new AtomicInteger(0);
|
public final AtomicInteger lookupInvocationCounter = new AtomicInteger(0);
|
||||||
|
|
||||||
LookupNotSupportedRealm(Settings globalSettings, ThreadPool threadPool) {
|
LookupNotSupportedRealm(Settings globalSettings, ThreadPool threadPool) {
|
||||||
super(new RealmConfig(new RealmConfig.RealmIdentifier("caching", "lookup-notsupported-test"), Settings.EMPTY, globalSettings,
|
super(new RealmConfig(new RealmConfig.RealmIdentifier("caching", "lookup-notsupported-test"), globalSettings,
|
||||||
TestEnvironment.newEnvironment(globalSettings), threadPool.getThreadContext()), threadPool);
|
TestEnvironment.newEnvironment(globalSettings), threadPool.getThreadContext()), threadPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class ExpressionRoleMappingTests extends ESTestCase {
|
||||||
@Before
|
@Before
|
||||||
public void setupMapping() throws Exception {
|
public void setupMapping() throws Exception {
|
||||||
realm = new RealmConfig(new RealmConfig.RealmIdentifier("ldap", "ldap1"),
|
realm = new RealmConfig(new RealmConfig.RealmIdentifier("ldap", "ldap1"),
|
||||||
Settings.EMPTY, Settings.EMPTY, Mockito.mock(Environment.class), new ThreadContext(Settings.EMPTY));
|
Settings.EMPTY, Mockito.mock(Environment.class), new ThreadContext(Settings.EMPTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testParseValidJson() throws Exception {
|
public void testParseValidJson() throws Exception {
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class NativeRoleMappingStoreTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final RealmConfig realm = new RealmConfig(new RealmConfig.RealmIdentifier("ldap", "ldap1"), Settings.EMPTY, Settings.EMPTY,
|
final RealmConfig realm = new RealmConfig(new RealmConfig.RealmIdentifier("ldap", "ldap1"), Settings.EMPTY,
|
||||||
mock(Environment.class), new ThreadContext(Settings.EMPTY));
|
mock(Environment.class), new ThreadContext(Settings.EMPTY));
|
||||||
|
|
||||||
final PlainActionFuture<Set<String>> future = new PlainActionFuture<>();
|
final PlainActionFuture<Set<String>> future = new PlainActionFuture<>();
|
||||||
|
@ -197,7 +197,7 @@ public class NativeRoleMappingStoreTests extends ESTestCase {
|
||||||
}).when(client).execute(eq(ClearRealmCacheAction.INSTANCE), any(ClearRealmCacheRequest.class), any(ActionListener.class));
|
}).when(client).execute(eq(ClearRealmCacheAction.INSTANCE), any(ClearRealmCacheRequest.class), any(ActionListener.class));
|
||||||
|
|
||||||
final Environment env = TestEnvironment.newEnvironment(settings);
|
final Environment env = TestEnvironment.newEnvironment(settings);
|
||||||
final RealmConfig realmConfig = new RealmConfig(new RealmConfig.RealmIdentifier("ldap", getTestName()), Settings.EMPTY,
|
final RealmConfig realmConfig = new RealmConfig(new RealmConfig.RealmIdentifier("ldap", getTestName()),
|
||||||
settings, env, threadContext);
|
settings, env, threadContext);
|
||||||
final CachingUsernamePasswordRealm mockRealm = new CachingUsernamePasswordRealm(realmConfig, threadPool) {
|
final CachingUsernamePasswordRealm mockRealm = new CachingUsernamePasswordRealm(realmConfig, threadPool) {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class ADLdapUserSearchSessionFactoryTests extends AbstractActiveDirectory
|
||||||
});
|
});
|
||||||
Settings fullSettings = builder.build();
|
Settings fullSettings = builder.build();
|
||||||
sslService = new SSLService(fullSettings, TestEnvironment.newEnvironment(fullSettings));
|
sslService = new SSLService(fullSettings, TestEnvironment.newEnvironment(fullSettings));
|
||||||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("ad", "ad-as-ldap-test"), settings, globalSettings,
|
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("ad", "ad-as-ldap-test"), globalSettings,
|
||||||
TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings));
|
TestEnvironment.newEnvironment(globalSettings), new ThreadContext(globalSettings));
|
||||||
LdapUserSearchSessionFactory sessionFactory = getLdapUserSearchSessionFactory(config, sslService, threadPool);
|
LdapUserSearchSessionFactory sessionFactory = getLdapUserSearchSessionFactory(config, sslService, threadPool);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ package org.elasticsearch.xpack.security.authc.ldap;
|
||||||
|
|
||||||
import com.unboundid.ldap.sdk.LDAPException;
|
import com.unboundid.ldap.sdk.LDAPException;
|
||||||
import com.unboundid.ldap.sdk.ResultCode;
|
import com.unboundid.ldap.sdk.ResultCode;
|
||||||
|
|
||||||
import org.elasticsearch.action.support.PlainActionFuture;
|
import org.elasticsearch.action.support.PlainActionFuture;
|
||||||
import org.elasticsearch.common.settings.SecureString;
|
import org.elasticsearch.common.settings.SecureString;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -18,6 +17,7 @@ import org.elasticsearch.env.TestEnvironment;
|
||||||
import org.elasticsearch.threadpool.TestThreadPool;
|
import org.elasticsearch.threadpool.TestThreadPool;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.xpack.core.security.authc.RealmConfig;
|
import org.elasticsearch.xpack.core.security.authc.RealmConfig;
|
||||||
|
import org.elasticsearch.xpack.core.security.authc.RealmSettings;
|
||||||
import org.elasticsearch.xpack.core.security.authc.ldap.ActiveDirectorySessionFactorySettings;
|
import org.elasticsearch.xpack.core.security.authc.ldap.ActiveDirectorySessionFactorySettings;
|
||||||
import org.elasticsearch.xpack.core.security.authc.ldap.LdapRealmSettings;
|
import org.elasticsearch.xpack.core.security.authc.ldap.LdapRealmSettings;
|
||||||
import org.elasticsearch.xpack.core.security.authc.ldap.support.LdapSearchScope;
|
import org.elasticsearch.xpack.core.security.authc.ldap.support.LdapSearchScope;
|
||||||
|
@ -314,21 +314,21 @@ public class ActiveDirectorySessionFactoryTests extends AbstractActiveDirectoryT
|
||||||
String groupSearchBase = "DC=ad,DC=test,DC=elasticsearch,DC=com";
|
String groupSearchBase = "DC=ad,DC=test,DC=elasticsearch,DC=com";
|
||||||
String userTemplate = "CN={0},CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com";
|
String userTemplate = "CN={0},CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com";
|
||||||
final boolean ignoreReferralErrors = false;
|
final boolean ignoreReferralErrors = false;
|
||||||
Settings settings = LdapTestCase.buildLdapSettings(
|
final RealmConfig.RealmIdentifier realmId = new RealmConfig.RealmIdentifier("ad", "ad-as-ldap-test");
|
||||||
new String[]{AD_LDAP_URL},
|
Settings settings = LdapTestCase.buildLdapSettings(realmId,
|
||||||
new String[]{userTemplate},
|
new String[]{AD_LDAP_URL},
|
||||||
groupSearchBase,
|
new String[]{userTemplate},
|
||||||
LdapSearchScope.SUB_TREE,
|
groupSearchBase,
|
||||||
null,
|
LdapSearchScope.SUB_TREE,
|
||||||
ignoreReferralErrors);
|
null,
|
||||||
|
ignoreReferralErrors);
|
||||||
|
final Settings.Builder builder = Settings.builder().put(settings).put(globalSettings);
|
||||||
if (useGlobalSSL == false) {
|
if (useGlobalSSL == false) {
|
||||||
settings = Settings.builder()
|
builder.putList(RealmSettings.realmSslPrefix(realmId) + "certificate_authorities", certificatePaths);
|
||||||
.put(settings)
|
|
||||||
.putList("ssl.certificate_authorities", certificatePaths)
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
RealmConfig config = new RealmConfig(new RealmConfig.RealmIdentifier("ad", "ad-as-ldap-test"),
|
settings = builder.build();
|
||||||
settings, globalSettings, TestEnvironment.newEnvironment(globalSettings),
|
RealmConfig config = new RealmConfig(realmId,
|
||||||
|
settings, TestEnvironment.newEnvironment(globalSettings),
|
||||||
new ThreadContext(globalSettings));
|
new ThreadContext(globalSettings));
|
||||||
LdapSessionFactory sessionFactory = new LdapSessionFactory(config, sslService, threadPool);
|
LdapSessionFactory sessionFactory = new LdapSessionFactory(config, sslService, threadPool);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue