use of org.apache.kafka.connect.connector.policy.PrincipalConnectorClientConfigOverridePolicy in project kafka by apache.
the class AbstractHerderTest method testConfigValidationPrincipalOnlyOverride.
@Test()
public void testConfigValidationPrincipalOnlyOverride() {
AbstractHerder herder = createConfigValidationHerder(TestSourceConnector.class, new PrincipalConnectorClientConfigOverridePolicy());
replayAll();
Map<String, String> config = new HashMap<>();
config.put(ConnectorConfig.CONNECTOR_CLASS_CONFIG, TestSourceConnector.class.getName());
config.put(ConnectorConfig.NAME_CONFIG, "connector-name");
// connector required config
config.put("required", "value");
String ackConfigKey = producerOverrideKey(ProducerConfig.ACKS_CONFIG);
String saslConfigKey = producerOverrideKey(SaslConfigs.SASL_JAAS_CONFIG);
config.put(ackConfigKey, "none");
config.put(saslConfigKey, "jaas_config");
ConfigInfos result = herder.validateConnectorConfig(config, false);
assertEquals(herder.connectorTypeForClass(config.get(ConnectorConfig.CONNECTOR_CLASS_CONFIG)), ConnectorType.SOURCE);
// We expect there to be errors due to now allowed override policy for ACKS.... Note that these assertions depend heavily on
// the config fields for SourceConnectorConfig, but we expect these to change rarely.
assertEquals(TestSourceConnector.class.getName(), result.name());
// Each transform also gets its own group
List<String> expectedGroups = Arrays.asList(ConnectorConfig.COMMON_GROUP, ConnectorConfig.TRANSFORMS_GROUP, ConnectorConfig.PREDICATES_GROUP, ConnectorConfig.ERROR_GROUP, SourceConnectorConfig.TOPIC_CREATION_GROUP);
assertEquals(expectedGroups, result.groups());
assertEquals(1, result.errorCount());
// Base connector config has 14 fields, connector's configs add 2, and 2 producer overrides
assertEquals(19, result.values().size());
assertTrue(result.values().stream().anyMatch(configInfo -> ackConfigKey.equals(configInfo.configValue().name()) && !configInfo.configValue().errors().isEmpty()));
assertTrue(result.values().stream().anyMatch(configInfo -> saslConfigKey.equals(configInfo.configValue().name()) && configInfo.configValue().errors().isEmpty()));
verifyAll();
}
Aggregations