use of io.strimzi.test.mockkube.MockKube in project strimzi by strimzi.
the class ConfigTest method testTlsEnabledConfig.
@Test
public void testTlsEnabledConfig() {
Map<String, String> map = new HashMap<>(MANDATORY);
map.put(Config.TLS_ENABLED.key, "true");
MockKube mockKube = new MockKube();
KubernetesClient kubeClient = mockKube.build();
Config config = new Config(map);
Session session = new Session(kubeClient, config);
Properties adminClientProps = session.adminClientProperties();
assertThat(adminClientProps.getProperty(SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG), is("HTTPS"));
assertThat(adminClientProps.getProperty(AdminClientConfig.SECURITY_PROTOCOL_CONFIG), is("SSL"));
}
use of io.strimzi.test.mockkube.MockKube in project strimzi by strimzi.
the class ConfigTest method testInvalidKeystoreConfig.
@Test
public void testInvalidKeystoreConfig() {
Map<String, String> map = new HashMap<>(MANDATORY);
map.put(Config.TLS_ENABLED.key, "true");
map.put(Config.TLS_TRUSTSTORE_PASSWORD.key, "password");
MockKube mockKube = new MockKube();
KubernetesClient kubeClient = mockKube.build();
Config config = new Config(map);
Session session = new Session(kubeClient, config);
assertThrows(InvalidConfigurationException.class, () -> session.adminClientProperties());
}
use of io.strimzi.test.mockkube.MockKube in project strimzi by strimzi.
the class ConfigTest method testScramSaslConfig.
@Test
public void testScramSaslConfig() {
Map<String, String> map = new HashMap<>(MANDATORY);
map.put(Config.SASL_ENABLED.key, "true");
String username = "admin";
String password = "password";
map.put(Config.SASL_USERNAME.key, username);
map.put(Config.SASL_PASSWORD.key, password);
String scramJaasConfig = "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"" + username + "\" password=\"" + password + "\";";
String plainJaasConfig = "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"" + username + "\" password=\"" + password + "\";";
MockKube mockKube = new MockKube();
KubernetesClient kubeClient = mockKube.build();
map.put(Config.SASL_MECHANISM.key, "scram-sha-256");
Config configSHA256 = new Config(map);
Session sessionSHA256 = new Session(kubeClient, configSHA256);
Properties adminClientPropsSHA256 = sessionSHA256.adminClientProperties();
assertThat(adminClientPropsSHA256.getProperty(SaslConfigs.SASL_MECHANISM), is("SCRAM-SHA-256"));
assertThat(adminClientPropsSHA256.getProperty(SaslConfigs.SASL_JAAS_CONFIG), is(scramJaasConfig));
map.put(Config.SASL_MECHANISM.key, "scram-sha-512");
Config configSHA512 = new Config(map);
Session sessionSHA512 = new Session(kubeClient, configSHA512);
Properties adminClientPropsSHA512 = sessionSHA512.adminClientProperties();
assertThat(adminClientPropsSHA512.getProperty(SaslConfigs.SASL_MECHANISM), is("SCRAM-SHA-512"));
assertThat(adminClientPropsSHA512.getProperty(SaslConfigs.SASL_JAAS_CONFIG), is(scramJaasConfig));
map.put(Config.SASL_MECHANISM.key, "plain");
Config configPlain = new Config(map);
Session sessionPlain = new Session(kubeClient, configPlain);
Properties adminClientPropsPlain = sessionPlain.adminClientProperties();
assertThat(adminClientPropsPlain.getProperty(SaslConfigs.SASL_MECHANISM), is("PLAIN"));
assertThat(adminClientPropsPlain.getProperty(SaslConfigs.SASL_JAAS_CONFIG), is(plainJaasConfig));
}
use of io.strimzi.test.mockkube.MockKube in project strimzi by strimzi.
the class ConfigTest method testSecurityProtocolConfig.
@Test
public void testSecurityProtocolConfig() {
Map<String, String> map = new HashMap<>(MANDATORY);
map.put(Config.SECURITY_PROTOCOL.key, "SSL");
MockKube mockKube = new MockKube();
KubernetesClient kubeClient = mockKube.build();
Config config = new Config(map);
Session session = new Session(kubeClient, config);
Properties adminClientProps = session.adminClientProperties();
assertThat(adminClientProps.getProperty(SslConfigs.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG), is("HTTPS"));
assertThat(adminClientProps.getProperty(AdminClientConfig.SECURITY_PROTOCOL_CONFIG), is("SSL"));
}
use of io.strimzi.test.mockkube.MockKube in project strimzi by strimzi.
the class KafkaAssemblyOperatorMockTest method init.
/*
* init is equivalent to a @BeforeEach method
* since this is a parameterized set, the tests params are only available at test start
* This must be called before each test
*/
private void init(Params params) {
setFields(params);
cluster = new KafkaBuilder().withNewMetadata().withName(CLUSTER_NAME).withNamespace(NAMESPACE).withLabels(singletonMap("foo", "bar")).endMetadata().withNewSpec().withNewKafka().withReplicas(kafkaReplicas).withStorage(kafkaStorage).withListeners(new GenericKafkaListenerBuilder().withName("plain").withPort(9092).withType(KafkaListenerType.INTERNAL).withTls(false).build(), new GenericKafkaListenerBuilder().withName("tls").withPort(9093).withType(KafkaListenerType.INTERNAL).withTls(true).build()).withResources(resources).endKafka().withNewZookeeper().withReplicas(zkReplicas).withStorage(zkStorage).endZookeeper().withNewEntityOperator().withNewTopicOperator().endTopicOperator().withNewUserOperator().endUserOperator().endEntityOperator().endSpec().build();
CustomResourceDefinition kafkaAssemblyCrd = Crds.kafka();
client = new MockKube().withCustomResourceDefinition(kafkaAssemblyCrd, Kafka.class, KafkaList.class).withInitialInstances(Collections.singleton(cluster)).end().withCustomResourceDefinition(Crds.strimziPodSet(), StrimziPodSet.class, StrimziPodSetList.class).end().build();
PlatformFeaturesAvailability pfa = new PlatformFeaturesAvailability(true, kubernetesVersion);
ResourceOperatorSupplier supplier = supplierWithMocks();
ClusterOperatorConfig config = ResourceUtils.dummyClusterOperatorConfig(VERSIONS);
operator = new KafkaAssemblyOperator(vertx, pfa, new MockCertManager(), new PasswordGenerator(10, "a", "a"), supplier, config);
}
Aggregations