use of org.apache.kafka.common.security.auth.PlaintextAuthenticationContext in project apache-kafka-on-k8s by banzaicloud.
the class ChannelBuildersTest method testCreateOldPrincipalBuilder.
@Test
@SuppressWarnings("deprecation")
public void testCreateOldPrincipalBuilder() throws Exception {
TransportLayer transportLayer = EasyMock.mock(TransportLayer.class);
Authenticator authenticator = EasyMock.mock(Authenticator.class);
Map<String, Object> configs = new HashMap<>();
configs.put(BrokerSecurityConfigs.PRINCIPAL_BUILDER_CLASS_CONFIG, OldPrincipalBuilder.class);
KafkaPrincipalBuilder builder = ChannelBuilders.createPrincipalBuilder(configs, transportLayer, authenticator, null);
// test old principal builder is properly configured and delegated to
assertTrue(OldPrincipalBuilder.configured);
// test delegation
KafkaPrincipal principal = builder.build(new PlaintextAuthenticationContext(InetAddress.getLocalHost()));
assertEquals(OldPrincipalBuilder.PRINCIPAL_NAME, principal.getName());
assertEquals(KafkaPrincipal.USER_TYPE, principal.getPrincipalType());
}
Aggregations