use of org.janusgraph.graphdb.tinkerpop.gremlin.server.auth.HMACAuthenticator in project janusgraph by JanusGraph.
the class SaslAndHMACAuthenticationHandlerTest method testHttpChannelReadWhenAuthenticatorHasBeenAdded.
@Test
public void testHttpChannelReadWhenAuthenticatorHasBeenAdded() throws Exception {
final SaslAndHMACAuthenticator authenticator = createMock(SaslAndHMACAuthenticator.class);
final HMACAuthenticator hmacAuth = createMock(HMACAuthenticator.class);
final ChannelHandlerContext ctx = createMock(ChannelHandlerContext.class);
final ChannelHandler mockHandler = createMock(ChannelHandler.class);
final ChannelPipeline pipeline = createMock(ChannelPipeline.class);
final HttpMessage msg = createMock(HttpMessage.class);
final HttpHeaders headers = createMock(HttpHeaders.class);
expect(authenticator.getHMACAuthenticator()).andReturn(hmacAuth);
expect(authenticator.getSimpleAuthenticator()).andReturn(createMock(JanusGraphSimpleAuthenticator.class));
expect(ctx.pipeline()).andReturn(pipeline);
expect(pipeline.get("hmac_authenticator")).andReturn(mockHandler);
expect(msg.headers()).andReturn(headers).times(2);
expect(headers.get(isA(String.class))).andReturn(null).times(2);
expect(ctx.fireChannelRead(eq(msg))).andReturn(ctx);
replayAll();
final SaslAndHMACAuthenticationHandler handler = new SaslAndHMACAuthenticationHandler(authenticator, null);
handler.channelRead(ctx, msg);
}
use of org.janusgraph.graphdb.tinkerpop.gremlin.server.auth.HMACAuthenticator in project janusgraph by JanusGraph.
the class SaslAndHMACAuthenticationHandlerTest method testHttpChannelReadWhenAuthenticatorHasNotBeenAdded.
@Test
public void testHttpChannelReadWhenAuthenticatorHasNotBeenAdded() throws Exception {
final HMACAuthenticator hmacAuth = createMock(HMACAuthenticator.class);
final SaslAndHMACAuthenticator authenticator = createMock(SaslAndHMACAuthenticator.class);
final ChannelHandlerContext ctx = createMock(ChannelHandlerContext.class);
final ChannelPipeline pipeline = createMock(ChannelPipeline.class);
final HttpMessage msg = createMock(HttpMessage.class);
final HttpHeaders headers = createMock(HttpHeaders.class);
expect(authenticator.getHMACAuthenticator()).andReturn(hmacAuth);
expect(authenticator.getSimpleAuthenticator()).andReturn(createMock(JanusGraphSimpleAuthenticator.class));
expect(ctx.pipeline()).andReturn(pipeline).times(2);
expect(pipeline.get("hmac_authenticator")).andReturn(null);
expect(pipeline.addAfter(eq(PIPELINE_AUTHENTICATOR), eq("hmac_authenticator"), isA(ChannelHandler.class))).andReturn(null);
expect(msg.headers()).andReturn(headers).times(2);
expect(headers.get(isA(String.class))).andReturn(null).times(2);
expect(ctx.fireChannelRead(eq(msg))).andReturn(ctx);
replayAll();
final SaslAndHMACAuthenticationHandler handler = new SaslAndHMACAuthenticationHandler(authenticator, null);
handler.channelRead(ctx, msg);
}
Aggregations