Filter out assertion transport interceptors in tests that expect an XPack request handler

in core we wrap request handlers with an asserting one to ensure we can serialize messages
with different versions. Yet, xpack uses the same functionality to add security aspects to
the network layer. These tests assert that the right handlers are in-place.

Original commit: elastic/x-pack-elasticsearch@e39c8995ae
This commit is contained in:
Simon Willnauer 2016-10-07 15:44:48 +02:00
parent 4c349a76fb
commit c226dfddc0
2 changed files with 19 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import org.elasticsearch.action.Action;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.license.Licensing;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.xpack.security.action.SecurityActionModule;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.SecurityIntegTestCase;
@ -36,6 +37,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static java.util.Collections.unmodifiableSet;
import static org.hamcrest.CoreMatchers.hasItems;
@ -48,6 +50,13 @@ public class KnownActionsTests extends SecurityIntegTestCase {
private static Set<String> knownHandlers;
private static Set<String> codeActions;
@Override
protected Collection<Class<? extends Plugin>> getMockPlugins() {
Collection<Class<? extends Plugin>> mockPlugins = super.getMockPlugins();
// no handler wrapping here we check the requestHandlers below and this plugin wraps it
return mockPlugins.stream().filter(p -> p != AssertingTransportInterceptor.TestPlugin.class).collect(Collectors.toList());
}
@BeforeClass
public static void init() throws Exception {
knownActions = loadKnownActions();

View File

@ -5,9 +5,12 @@
*/
package org.elasticsearch.transport;
import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.xpack.XPackSettings;
import org.elasticsearch.xpack.security.transport.SecurityServerTransportInterceptor;
@ -25,6 +28,13 @@ public class SecurityServerTransportServiceTests extends SecurityIntegTestCase {
.build();
}
@Override
protected Collection<Class<? extends Plugin>> getMockPlugins() {
Collection<Class<? extends Plugin>> mockPlugins = super.getMockPlugins();
// no handler wrapping here we check the requestHandlers below and this plugin wraps it
return mockPlugins.stream().filter(p -> p != AssertingTransportInterceptor.TestPlugin.class).collect(Collectors.toList());
}
public void testSecurityServerTransportServiceWrapsAllHandlers() {
for (TransportService transportService : internalCluster().getInstances(TransportService.class)) {
for (Map.Entry<String, RequestHandlerRegistry> entry : transportService.requestHandlers.entrySet()) {