use of org.apache.kafka.common.config.ConfigDef in project apache-kafka-on-k8s by banzaicloud.
the class ConnectorPluginsResourceTest method testValidateConfigWithSingleErrorDueToMissingConnectorClassname.
@Test
public void testValidateConfigWithSingleErrorDueToMissingConnectorClassname() throws Throwable {
herder.validateConnectorConfig(EasyMock.eq(partialProps));
PowerMock.expectLastCall().andAnswer(new IAnswer<ConfigInfos>() {
@Override
public ConfigInfos answer() {
ConfigDef connectorConfigDef = ConnectorConfig.configDef();
List<ConfigValue> connectorConfigValues = connectorConfigDef.validate(partialProps);
Connector connector = new ConnectorPluginsResourceTestConnector();
Config config = connector.validate(partialProps);
ConfigDef configDef = connector.config();
Map<String, ConfigDef.ConfigKey> configKeys = configDef.configKeys();
List<ConfigValue> configValues = config.configValues();
Map<String, ConfigDef.ConfigKey> resultConfigKeys = new HashMap<>(configKeys);
resultConfigKeys.putAll(connectorConfigDef.configKeys());
configValues.addAll(connectorConfigValues);
return AbstractHerder.generateResult(ConnectorPluginsResourceTestConnector.class.getName(), resultConfigKeys, configValues, Collections.singletonList("Test"));
}
});
PowerMock.replayAll();
// This call to validateConfigs does not throw a BadRequestException because we've mocked
// validateConnectorConfig.
ConfigInfos configInfos = connectorPluginsResource.validateConfigs(ConnectorPluginsResourceTestConnector.class.getSimpleName(), partialProps);
assertEquals(PARTIAL_CONFIG_INFOS.name(), configInfos.name());
assertEquals(PARTIAL_CONFIG_INFOS.errorCount(), configInfos.errorCount());
assertEquals(PARTIAL_CONFIG_INFOS.groups(), configInfos.groups());
assertEquals(new HashSet<>(PARTIAL_CONFIG_INFOS.values()), new HashSet<>(configInfos.values()));
PowerMock.verifyAll();
}
use of org.apache.kafka.common.config.ConfigDef in project kafka by apache.
the class SaslChannelBuilderTest method testClientChannelBuilderWithBrokerConfigs.
/**
* Verify that unparsed broker configs don't break clients. This is to ensure that clients
* created by brokers are not broken if broker configs are passed to clients.
*/
@Test
public void testClientChannelBuilderWithBrokerConfigs() throws Exception {
Map<String, Object> configs = new HashMap<>();
CertStores certStores = new CertStores(false, "client", "localhost");
configs.putAll(certStores.getTrustingConfig(certStores));
configs.put(SaslConfigs.SASL_KERBEROS_SERVICE_NAME, "kafka");
configs.putAll(new ConfigDef().withClientSaslSupport().parse(configs));
for (Field field : BrokerSecurityConfigs.class.getFields()) {
if (field.getName().endsWith("_CONFIG"))
configs.put(field.get(BrokerSecurityConfigs.class).toString(), "somevalue");
}
SaslChannelBuilder plainBuilder = createChannelBuilder(SecurityProtocol.SASL_PLAINTEXT, "PLAIN");
plainBuilder.configure(configs);
SaslChannelBuilder gssapiBuilder = createChannelBuilder(SecurityProtocol.SASL_PLAINTEXT, "GSSAPI");
gssapiBuilder.configure(configs);
SaslChannelBuilder oauthBearerBuilder = createChannelBuilder(SecurityProtocol.SASL_PLAINTEXT, "OAUTHBEARER");
oauthBearerBuilder.configure(configs);
SaslChannelBuilder scramBuilder = createChannelBuilder(SecurityProtocol.SASL_PLAINTEXT, "SCRAM-SHA-256");
scramBuilder.configure(configs);
SaslChannelBuilder saslSslBuilder = createChannelBuilder(SecurityProtocol.SASL_SSL, "PLAIN");
saslSslBuilder.configure(configs);
}
use of org.apache.kafka.common.config.ConfigDef in project kafka by apache.
the class ConfigurationControlManager method getConfigValueDefault.
String getConfigValueDefault(ConfigResource.Type type, String key) {
ConfigDef configDef = configDefs.get(type);
if (configDef == null) {
return null;
}
ConfigKey configKey = configDef.configKeys().get(key);
if (configKey == null || !configKey.hasDefault()) {
return null;
}
return ConfigDef.convertToString(configKey.defaultValue, configKey.type);
}
use of org.apache.kafka.common.config.ConfigDef in project kafka by apache.
the class ConnectorConfigTest method testEnrichedConfigDef.
@Test
public void testEnrichedConfigDef() {
String alias = "hdt";
String prefix = ConnectorConfig.TRANSFORMS_CONFIG + "." + alias + ".";
Map<String, String> props = new HashMap<>();
props.put(ConnectorConfig.TRANSFORMS_CONFIG, alias);
props.put(prefix + "type", HasDuplicateConfigTransformation.class.getName());
ConfigDef def = ConnectorConfig.enrich(MOCK_PLUGINS, new ConfigDef(), props, false);
assertEnrichedConfigDef(def, prefix, HasDuplicateConfigTransformation.MUST_EXIST_KEY, ConfigDef.Type.BOOLEAN);
assertEnrichedConfigDef(def, prefix, PredicatedTransformation.PREDICATE_CONFIG, ConfigDef.Type.STRING);
assertEnrichedConfigDef(def, prefix, PredicatedTransformation.NEGATE_CONFIG, ConfigDef.Type.BOOLEAN);
}
use of org.apache.kafka.common.config.ConfigDef in project kafka by apache.
the class JaasOptionsUtils method getSslClientConfig.
public Map<String, ?> getSslClientConfig() {
ConfigDef sslConfigDef = new ConfigDef();
sslConfigDef.withClientSslSupport();
AbstractConfig sslClientConfig = new AbstractConfig(sslConfigDef, options);
return sslClientConfig.values();
}
Aggregations