Search in sources :

Example 1 with KafkaListenerAuthenticationScramSha512Builder

use of io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationScramSha512Builder in project strimzi-kafka-operator by strimzi.

the class KafkaClusterOAuthValidationTest method testOAuthAuthzWithoutAuthn.

@ParallelTest
public void testOAuthAuthzWithoutAuthn() {
    assertThrows(InvalidResourceException.class, () -> {
        List<GenericKafkaListener> listeners = asList(new GenericKafkaListenerBuilder().withName("listener1").withPort(9900).withType(KafkaListenerType.INTERNAL).withAuth(new KafkaListenerAuthenticationScramSha512Builder().build()).build());
        Kafka kafkaAssembly = new KafkaBuilder().withNewMetadata().withName("my-cluster").withNamespace("my-namespace").endMetadata().withNewSpec().withNewKafka().withReplicas(3).withStorage(new EphemeralStorage()).withListeners(listeners).withAuthorization(new KafkaAuthorizationKeycloakBuilder().withTokenEndpointUri("http://token-endpoint").withClientId("my-client-id").withDelegateToKafkaAcls(true).withGrantsRefreshPeriodSeconds(60).withGrantsRefreshPoolSize(5).withSuperUsers("alice", "CN=alice").build()).endKafka().withNewZookeeper().withReplicas(3).withStorage(new EphemeralStorage()).endZookeeper().endSpec().build();
        KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS);
    });
}
Also used : GenericKafkaListener(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) KafkaAuthorizationKeycloakBuilder(io.strimzi.api.kafka.model.KafkaAuthorizationKeycloakBuilder) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage) KafkaListenerAuthenticationScramSha512Builder(io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationScramSha512Builder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 2 with KafkaListenerAuthenticationScramSha512Builder

use of io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationScramSha512Builder in project strimzi by strimzi.

the class KafkaClusterOAuthValidationTest method testOAuthAuthzWithoutAuthn.

@ParallelTest
public void testOAuthAuthzWithoutAuthn() {
    assertThrows(InvalidResourceException.class, () -> {
        List<GenericKafkaListener> listeners = asList(new GenericKafkaListenerBuilder().withName("listener1").withPort(9900).withType(KafkaListenerType.INTERNAL).withAuth(new KafkaListenerAuthenticationScramSha512Builder().build()).build());
        Kafka kafkaAssembly = new KafkaBuilder().withNewMetadata().withName("my-cluster").withNamespace("my-namespace").endMetadata().withNewSpec().withNewKafka().withReplicas(3).withStorage(new EphemeralStorage()).withListeners(listeners).withAuthorization(new KafkaAuthorizationKeycloakBuilder().withTokenEndpointUri("http://token-endpoint").withClientId("my-client-id").withDelegateToKafkaAcls(true).withGrantsRefreshPeriodSeconds(60).withGrantsRefreshPoolSize(5).withSuperUsers("alice", "CN=alice").build()).endKafka().withNewZookeeper().withReplicas(3).withStorage(new EphemeralStorage()).endZookeeper().endSpec().build();
        KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS);
    });
}
Also used : GenericKafkaListener(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) KafkaAuthorizationKeycloakBuilder(io.strimzi.api.kafka.model.KafkaAuthorizationKeycloakBuilder) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage) KafkaListenerAuthenticationScramSha512Builder(io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationScramSha512Builder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

Kafka (io.strimzi.api.kafka.model.Kafka)2 KafkaAuthorizationKeycloakBuilder (io.strimzi.api.kafka.model.KafkaAuthorizationKeycloakBuilder)2 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)2 KafkaListenerAuthenticationScramSha512Builder (io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationScramSha512Builder)2 GenericKafkaListener (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener)2 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)2 EphemeralStorage (io.strimzi.api.kafka.model.storage.EphemeralStorage)2 ParallelTest (io.strimzi.test.annotations.ParallelTest)2