Add SettingsFilter to SettingsModule in tests (change in core)

Original commit: elastic/x-pack-elasticsearch@004edbcf76
This commit is contained in:
Daniel Mitterdorfer 2015-11-27 14:40:29 +01:00
parent b9b39efac8
commit 75d66dfa95
2 changed files with 9 additions and 7 deletions

View File

@ -9,6 +9,7 @@ import org.elasticsearch.Version;
import org.elasticsearch.common.inject.Guice;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.indices.breaker.CircuitBreakerModule;
import org.elasticsearch.shield.audit.logfile.LoggingAuditTrail;
@ -30,7 +31,7 @@ public class AuditTrailModuleTests extends ESTestCase {
.put("client.type", "node")
.put("shield.audit.enabled", false)
.build();
Injector injector = Guice.createInjector(new SettingsModule(settings), new AuditTrailModule(settings));
Injector injector = Guice.createInjector(new SettingsModule(settings, new SettingsFilter(settings)), new AuditTrailModule(settings));
AuditTrail auditTrail = injector.getInstance(AuditTrail.class);
assertThat(auditTrail, is(AuditTrail.NOOP));
}
@ -38,7 +39,7 @@ public class AuditTrailModuleTests extends ESTestCase {
public void testDisabledByDefault() throws Exception {
Settings settings = Settings.builder()
.put("client.type", "node").build();
Injector injector = Guice.createInjector(new SettingsModule(settings), new AuditTrailModule(settings));
Injector injector = Guice.createInjector(new SettingsModule(settings, new SettingsFilter(settings)), new AuditTrailModule(settings));
AuditTrail auditTrail = injector.getInstance(AuditTrail.class);
assertThat(auditTrail, is(AuditTrail.NOOP));
}
@ -50,7 +51,7 @@ public class AuditTrailModuleTests extends ESTestCase {
.build();
ThreadPool pool = new ThreadPool("testLogFile");
try {
Injector injector = Guice.createInjector(new SettingsModule(settings), new AuditTrailModule(settings), new TransportModule(settings), new CircuitBreakerModule(settings), new ThreadPoolModule(pool), new Version.Module(Version.CURRENT));
Injector injector = Guice.createInjector(new SettingsModule(settings, new SettingsFilter(settings)), new AuditTrailModule(settings), new TransportModule(settings), new CircuitBreakerModule(settings), new ThreadPoolModule(pool), new Version.Module(Version.CURRENT));
AuditTrail auditTrail = injector.getInstance(AuditTrail.class);
assertThat(auditTrail, instanceOf(AuditTrailService.class));
AuditTrailService service = (AuditTrailService) auditTrail;
@ -69,7 +70,7 @@ public class AuditTrailModuleTests extends ESTestCase {
.put("client.type", "node")
.build();
try {
Guice.createInjector(new SettingsModule(settings), new AuditTrailModule(settings));
Guice.createInjector(new SettingsModule(settings, new SettingsFilter(settings)), new AuditTrailModule(settings));
fail("Expect initialization to fail when an unknown audit trail output is configured");
} catch (Throwable t) {
// expected

View File

@ -9,6 +9,7 @@ import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.common.inject.Guice;
import org.elasticsearch.common.inject.Injector;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.settings.SettingsFilter;
import org.elasticsearch.common.settings.SettingsModule;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.EnvironmentModule;
@ -78,7 +79,7 @@ public class AuthenticationModuleTests extends ESTestCase {
Environment env = new Environment(settings);
ThreadPool pool = new ThreadPool(settings);
try {
Injector injector = Guice.createInjector(module, new SettingsModule(settings), new AuditTrailModule(settings), new CryptoModule(settings), new EnvironmentModule(env), new ThreadPoolModule(pool));
Injector injector = Guice.createInjector(module, new SettingsModule(settings, new SettingsFilter(settings)), new AuditTrailModule(settings), new CryptoModule(settings), new EnvironmentModule(env), new ThreadPoolModule(pool));
Realms realms = injector.getInstance(Realms.class);
Realm.Factory factory = realms.realmFactory("custom");
assertThat(factory, notNullValue());
@ -106,7 +107,7 @@ public class AuthenticationModuleTests extends ESTestCase {
ThreadPool pool = new ThreadPool(settings);
try {
Injector injector = Guice.createInjector(module, new SettingsModule(settings), new AuditTrailModule(settings), new CryptoModule(settings), new EnvironmentModule(env), new ThreadPoolModule(pool));
Injector injector = Guice.createInjector(module, new SettingsModule(settings, new SettingsFilter(settings)), new AuditTrailModule(settings), new CryptoModule(settings), new EnvironmentModule(env), new ThreadPoolModule(pool));
AuthenticationFailureHandler failureHandler = injector.getInstance(AuthenticationFailureHandler.class);
assertThat(failureHandler, notNullValue());
assertThat(failureHandler, instanceOf(DefaultAuthenticationFailureHandler.class));
@ -130,7 +131,7 @@ public class AuthenticationModuleTests extends ESTestCase {
ThreadPool pool = new ThreadPool(settings);
try {
Injector injector = Guice.createInjector(module, new SettingsModule(settings), new AuditTrailModule(settings), new CryptoModule(settings), new EnvironmentModule(env), new ThreadPoolModule(pool));
Injector injector = Guice.createInjector(module, new SettingsModule(settings, new SettingsFilter(settings)), new AuditTrailModule(settings), new CryptoModule(settings), new EnvironmentModule(env), new ThreadPoolModule(pool));
AuthenticationFailureHandler failureHandler = injector.getInstance(AuthenticationFailureHandler.class);
assertThat(failureHandler, notNullValue());
assertThat(failureHandler, instanceOf(NoOpFailureHandler.class));