use of io.airlift.tracetoken.TraceTokenManager in project airlift by airlift.
the class TestHttpServerCipher method createServer.
private static HttpServer createServer(HttpServlet servlet, NodeInfo nodeInfo, HttpServerInfo httpServerInfo, HttpServerConfig config) {
HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), new RequestStats(), new NullEventClient());
serverProvider.setTheAdminServlet(new DummyServlet());
serverProvider.setLoginService(loginServiceProvider.get());
serverProvider.setTokenManager(new TraceTokenManager());
return serverProvider.get();
}
use of io.airlift.tracetoken.TraceTokenManager in project airlift by airlift.
the class TestHttpServerProvider method createServer.
private void createServer(HttpServlet servlet) {
HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, optionalHttpsConfig(), servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), clientCertificate, new RequestStats(), new NullEventClient(), Optional.empty());
serverProvider.setTheAdminServlet(new DummyServlet());
serverProvider.setLoginService(loginServiceProvider.get());
serverProvider.setTokenManager(new TraceTokenManager());
server = serverProvider.get();
}
use of io.airlift.tracetoken.TraceTokenManager in project airlift by airlift.
the class TestDelimitedRequestLog method testTraceTokenHeader.
@Test
public void testTraceTokenHeader() throws Exception {
Request request = mock(Request.class);
Response response = mock(Response.class);
TraceTokenManager tokenManager = new TraceTokenManager();
InMemoryEventClient eventClient = new InMemoryEventClient();
DelimitedRequestLog logger = new DelimitedRequestLog(file.getAbsolutePath(), 1, 256, Long.MAX_VALUE, tokenManager, eventClient, new SystemCurrentTimeMillisProvider(), false);
String token = "test-trace-token";
when(request.getHttpVersion()).thenReturn(HTTP_2);
when(request.getHeader(TRACETOKEN_HEADER)).thenReturn(token);
// log a request without a token set by tokenManager
logger.log(request, response, 0, 0, 0, new DoubleSummaryStats(new DoubleSummaryStatistics()));
// create and set a new token with tokenManager
tokenManager.createAndRegisterNewRequestToken();
logger.log(request, response, 0, 0, 0, new DoubleSummaryStats(new DoubleSummaryStatistics()));
// clear the token HTTP header
when(request.getHeader(TRACETOKEN_HEADER)).thenReturn(null);
logger.log(request, response, 0, 0, 0, new DoubleSummaryStats(new DoubleSummaryStatistics()));
logger.stop();
List<Object> events = eventClient.getEvents();
assertEquals(events.size(), 3);
// first two events should have the token set from the header
for (int i = 0; i < 2; i++) {
assertEquals(((HttpRequestEvent) events.get(i)).getTraceToken(), token);
}
// last event should have the token set by the tokenManager
assertEquals(((HttpRequestEvent) events.get(2)).getTraceToken(), tokenManager.getCurrentRequestToken());
}
use of io.airlift.tracetoken.TraceTokenManager in project airlift by airlift.
the class TestHttpServerCipher method createServer.
private static HttpServer createServer(HttpServlet servlet, NodeInfo nodeInfo, HttpServerInfo httpServerInfo, HttpServerConfig config, HttpsConfig httpsConfig) {
HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, Optional.of(httpsConfig), servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), ClientCertificate.NONE, new RequestStats(), new NullEventClient(), Optional.empty());
serverProvider.setTheAdminServlet(new DummyServlet());
serverProvider.setLoginService(loginServiceProvider.get());
serverProvider.setTokenManager(new TraceTokenManager());
return serverProvider.get();
}
use of io.airlift.tracetoken.TraceTokenManager in project airlift by airlift.
the class TestTraceTokenRequestFilter method testSameRequestReturnedWhenTraceTokenNotSet.
@Test
public void testSameRequestReturnedWhenTraceTokenNotSet() {
TraceTokenManager manager = new TraceTokenManager();
TraceTokenRequestFilter filter = new TraceTokenRequestFilter(manager);
Request original = prepareGet().setUri(URI.create("http://example.com")).build();
Request request = filter.filterRequest(original);
assertSame(request, original);
}
Aggregations