Search in sources :

Example 1 with KafkaAuthorizationOpaBuilder

use of io.strimzi.api.kafka.model.KafkaAuthorizationOpaBuilder in project strimzi by strimzi.

the class KafkaBrokerConfigurationBuilderTest method testOpaAuthorization.

@ParallelTest
public void testOpaAuthorization() {
    KafkaAuthorization auth = new KafkaAuthorizationOpaBuilder().withUrl("http://opa:8181/v1/data/kafka/allow").withAllowOnError(true).withInitialCacheCapacity(1000).withMaximumCacheSize(10000).withExpireAfterMs(60000).addToSuperUsers("jack", "CN=conor").build();
    String configuration = new KafkaBrokerConfigurationBuilder(Reconciliation.DUMMY_RECONCILIATION).withAuthorization("my-cluster", auth).build();
    assertThat(configuration, isEquivalent("authorizer.class.name=org.openpolicyagent.kafka.OpaAuthorizer\n" + "opa.authorizer.url=http://opa:8181/v1/data/kafka/allow\n" + "opa.authorizer.allow.on.error=true\n" + "opa.authorizer.metrics.enabled=false\n" + "opa.authorizer.cache.initial.capacity=1000\n" + "opa.authorizer.cache.maximum.size=10000\n" + "opa.authorizer.cache.expire.after.seconds=60\n" + "super.users=User:CN=my-cluster-kafka,O=io.strimzi;User:CN=my-cluster-entity-topic-operator,O=io.strimzi;User:CN=my-cluster-entity-user-operator,O=io.strimzi;User:CN=my-cluster-kafka-exporter,O=io.strimzi;User:CN=my-cluster-cruise-control,O=io.strimzi;User:CN=cluster-operator,O=io.strimzi;User:jack;User:CN=conor"));
}
Also used : KafkaAuthorization(io.strimzi.api.kafka.model.KafkaAuthorization) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) KafkaAuthorizationOpaBuilder(io.strimzi.api.kafka.model.KafkaAuthorizationOpaBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 2 with KafkaAuthorizationOpaBuilder

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

the class KafkaBrokerConfigurationBuilderTest method testOpaAuthorization.

@ParallelTest
public void testOpaAuthorization() {
    KafkaAuthorization auth = new KafkaAuthorizationOpaBuilder().withUrl("http://opa:8181/v1/data/kafka/allow").withAllowOnError(true).withInitialCacheCapacity(1000).withMaximumCacheSize(10000).withExpireAfterMs(60000).addToSuperUsers("jack", "CN=conor").build();
    String configuration = new KafkaBrokerConfigurationBuilder(Reconciliation.DUMMY_RECONCILIATION).withAuthorization("my-cluster", auth).build();
    assertThat(configuration, isEquivalent("authorizer.class.name=org.openpolicyagent.kafka.OpaAuthorizer\n" + "opa.authorizer.url=http://opa:8181/v1/data/kafka/allow\n" + "opa.authorizer.allow.on.error=true\n" + "opa.authorizer.metrics.enabled=false\n" + "opa.authorizer.cache.initial.capacity=1000\n" + "opa.authorizer.cache.maximum.size=10000\n" + "opa.authorizer.cache.expire.after.seconds=60\n" + "super.users=User:CN=my-cluster-kafka,O=io.strimzi;User:CN=my-cluster-entity-topic-operator,O=io.strimzi;User:CN=my-cluster-entity-user-operator,O=io.strimzi;User:CN=my-cluster-kafka-exporter,O=io.strimzi;User:CN=my-cluster-cruise-control,O=io.strimzi;User:CN=cluster-operator,O=io.strimzi;User:jack;User:CN=conor"));
}
Also used : KafkaAuthorization(io.strimzi.api.kafka.model.KafkaAuthorization) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) KafkaAuthorizationOpaBuilder(io.strimzi.api.kafka.model.KafkaAuthorizationOpaBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 3 with KafkaAuthorizationOpaBuilder

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

the class KafkaBrokerConfigurationBuilderTest method testOpaAuthorizationWithDefaults.

@ParallelTest
public void testOpaAuthorizationWithDefaults() {
    KafkaAuthorization auth = new KafkaAuthorizationOpaBuilder().withUrl("http://opa:8181/v1/data/kafka/allow").build();
    String configuration = new KafkaBrokerConfigurationBuilder(Reconciliation.DUMMY_RECONCILIATION).withAuthorization("my-cluster", auth).build();
    assertThat(configuration, isEquivalent("authorizer.class.name=org.openpolicyagent.kafka.OpaAuthorizer\n" + "opa.authorizer.url=http://opa:8181/v1/data/kafka/allow\n" + "opa.authorizer.allow.on.error=false\n" + "opa.authorizer.metrics.enabled=false\n" + "opa.authorizer.cache.initial.capacity=5000\n" + "opa.authorizer.cache.maximum.size=50000\n" + "opa.authorizer.cache.expire.after.seconds=3600\n" + "super.users=User:CN=my-cluster-kafka,O=io.strimzi;User:CN=my-cluster-entity-topic-operator,O=io.strimzi;User:CN=my-cluster-entity-user-operator,O=io.strimzi;User:CN=my-cluster-kafka-exporter,O=io.strimzi;User:CN=my-cluster-cruise-control,O=io.strimzi;User:CN=cluster-operator,O=io.strimzi"));
}
Also used : KafkaAuthorization(io.strimzi.api.kafka.model.KafkaAuthorization) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) KafkaAuthorizationOpaBuilder(io.strimzi.api.kafka.model.KafkaAuthorizationOpaBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 4 with KafkaAuthorizationOpaBuilder

use of io.strimzi.api.kafka.model.KafkaAuthorizationOpaBuilder in project strimzi by strimzi.

the class KafkaBrokerConfigurationBuilderTest method testOpaAuthorizationWithDefaults.

@ParallelTest
public void testOpaAuthorizationWithDefaults() {
    KafkaAuthorization auth = new KafkaAuthorizationOpaBuilder().withUrl("http://opa:8181/v1/data/kafka/allow").build();
    String configuration = new KafkaBrokerConfigurationBuilder(Reconciliation.DUMMY_RECONCILIATION).withAuthorization("my-cluster", auth).build();
    assertThat(configuration, isEquivalent("authorizer.class.name=org.openpolicyagent.kafka.OpaAuthorizer\n" + "opa.authorizer.url=http://opa:8181/v1/data/kafka/allow\n" + "opa.authorizer.allow.on.error=false\n" + "opa.authorizer.metrics.enabled=false\n" + "opa.authorizer.cache.initial.capacity=5000\n" + "opa.authorizer.cache.maximum.size=50000\n" + "opa.authorizer.cache.expire.after.seconds=3600\n" + "super.users=User:CN=my-cluster-kafka,O=io.strimzi;User:CN=my-cluster-entity-topic-operator,O=io.strimzi;User:CN=my-cluster-entity-user-operator,O=io.strimzi;User:CN=my-cluster-kafka-exporter,O=io.strimzi;User:CN=my-cluster-cruise-control,O=io.strimzi;User:CN=cluster-operator,O=io.strimzi"));
}
Also used : KafkaAuthorization(io.strimzi.api.kafka.model.KafkaAuthorization) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) KafkaAuthorizationOpaBuilder(io.strimzi.api.kafka.model.KafkaAuthorizationOpaBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

KafkaAuthorization (io.strimzi.api.kafka.model.KafkaAuthorization)4 KafkaAuthorizationOpaBuilder (io.strimzi.api.kafka.model.KafkaAuthorizationOpaBuilder)4 ParallelTest (io.strimzi.test.annotations.ParallelTest)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4