Add helper methods to TransportActionProxy to identify proxy actions and requests (#25124)
Downstream users of out network intercept infrastructure need this information which is hidden due to member and class visibility.
This commit is contained in:
parent
d187fa78fd
commit
ce24331d1f
|
@ -158,4 +158,18 @@ public final class TransportActionProxy {
|
||||||
}
|
}
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <code>true</code> iff the given action is a proxy action
|
||||||
|
*/
|
||||||
|
public static boolean isProxyAction(String action) {
|
||||||
|
return action.startsWith(PROXY_ACTION_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <code>true</code> iff the given request is a proxy request
|
||||||
|
*/
|
||||||
|
public static boolean isProxyRequest(TransportRequest request) {
|
||||||
|
return request instanceof ProxyRequest;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,4 +258,16 @@ public class TransportActionProxyTests extends ESTestCase {
|
||||||
assertTrue(transportRequest instanceof TransportActionProxy.ProxyRequest);
|
assertTrue(transportRequest instanceof TransportActionProxy.ProxyRequest);
|
||||||
assertSame(TransportService.HandshakeRequest.INSTANCE, TransportActionProxy.unwrapRequest(transportRequest));
|
assertSame(TransportService.HandshakeRequest.INSTANCE, TransportActionProxy.unwrapRequest(transportRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testIsProxyAction() {
|
||||||
|
String action = "foo/bar";
|
||||||
|
String proxyAction = TransportActionProxy.getProxyAction(action);
|
||||||
|
assertTrue(TransportActionProxy.isProxyAction(proxyAction));
|
||||||
|
assertFalse(TransportActionProxy.isProxyAction(action));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testIsProxyRequest() {
|
||||||
|
assertTrue(TransportActionProxy.isProxyRequest(new TransportActionProxy.ProxyRequest<>(() -> null)));
|
||||||
|
assertFalse(TransportActionProxy.isProxyRequest(TransportRequest.Empty.INSTANCE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue