use of io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationOAuthBuilder in project strimzi by strimzi.
the class KafkaClusterOAuthValidationTest method testOAuthValidationIntrospectionEndpointUriWithoutClientId.
@ParallelTest
public void testOAuthValidationIntrospectionEndpointUriWithoutClientId() {
assertThrows(InvalidResourceException.class, () -> {
KafkaListenerAuthenticationOAuth auth = new KafkaListenerAuthenticationOAuthBuilder().withIntrospectionEndpointUri("http://introspection").withNewClientSecret().withSecretName("my-secret-secret").withKey("my-secret-key").endClientSecret().build();
ListenersValidator.validate(Reconciliation.DUMMY_RECONCILIATION, 3, getListeners(auth));
});
}
use of io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationOAuthBuilder in project strimzi by strimzi.
the class KafkaClusterOAuthValidationTest method testOAuthValidationWithJwksRefreshAndIntrospection.
@ParallelTest
public void testOAuthValidationWithJwksRefreshAndIntrospection() {
assertThrows(InvalidResourceException.class, () -> {
KafkaListenerAuthenticationOAuth auth = new KafkaListenerAuthenticationOAuthBuilder().withClientId("my-client-id").withValidIssuerUri("http://valid-issuer").withIntrospectionEndpointUri("http://introspection").withJwksRefreshSeconds(60).withNewClientSecret().withSecretName("my-secret-secret").withKey("my-secret-key").endClientSecret().build();
ListenersValidator.validate(Reconciliation.DUMMY_RECONCILIATION, 3, getListeners(auth));
});
}
use of io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationOAuthBuilder in project strimzi by strimzi.
the class KafkaClusterOAuthValidationTest method testOAuthValidationMissingValidIssuerUri.
@ParallelTest
public void testOAuthValidationMissingValidIssuerUri() {
assertThrows(InvalidResourceException.class, () -> {
KafkaListenerAuthenticationOAuth auth = new KafkaListenerAuthenticationOAuthBuilder().withClientId("my-client-id").withIntrospectionEndpointUri("http://introspection").withNewClientSecret().withSecretName("my-secret-secret").withKey("my-secret-key").endClientSecret().build();
ListenersValidator.validate(Reconciliation.DUMMY_RECONCILIATION, 3, getListeners(auth));
});
}
use of io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationOAuthBuilder in project strimzi by strimzi.
the class KafkaBrokerConfigurationBuilderTest method testOAuthDefaultOptions.
@ParallelTest
public void testOAuthDefaultOptions() {
KafkaListenerAuthenticationOAuth auth = new KafkaListenerAuthenticationOAuthBuilder().build();
List<String> actualOptions = KafkaBrokerConfigurationBuilder.getOAuthOptions(auth);
assertThat(actualOptions, is(equalTo(Collections.emptyList())));
}
use of io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationOAuthBuilder in project strimzi-kafka-operator by strimzi.
the class ListenersValidatorTest method testValidateTimeoutsOauth.
@ParallelTest
public void testValidateTimeoutsOauth() {
KafkaListenerAuthenticationOAuthBuilder authBuilder = new KafkaListenerAuthenticationOAuthBuilder().withConnectTimeoutSeconds(0);
GenericKafkaListenerBuilder listenerBuilder = new GenericKafkaListenerBuilder().withName("listener1").withPort(9900).withType(KafkaListenerType.INTERNAL).withAuth(authBuilder.build());
List<GenericKafkaListener> listeners = asList(listenerBuilder.withAuth(authBuilder.build()).build());
Exception exception = assertThrows(InvalidResourceException.class, () -> ListenersValidator.validate(Reconciliation.DUMMY_RECONCILIATION, 3, listeners));
assertThat(exception.getMessage(), allOf(containsString("listener listener1: 'connectTimeoutSeconds' needs to be a positive integer (set to: 0)")));
// set valid connectTimeoutSeconds
authBuilder.withConnectTimeoutSeconds(1);
List<GenericKafkaListener> listeners2 = asList(listenerBuilder.withAuth(authBuilder.build()).build());
exception = assertThrows(InvalidResourceException.class, () -> ListenersValidator.validate(Reconciliation.DUMMY_RECONCILIATION, 3, listeners2));
assertThat(exception.getMessage(), allOf(not(containsString("listener listener1: 'connectTimeoutSeconds' needs to be a positive integer"))));
//
// Repeat for readTimeoutSeconds
//
authBuilder.withConnectTimeoutSeconds(null).withReadTimeoutSeconds(0);
List<GenericKafkaListener> listeners3 = asList(listenerBuilder.withAuth(authBuilder.build()).build());
exception = assertThrows(InvalidResourceException.class, () -> ListenersValidator.validate(Reconciliation.DUMMY_RECONCILIATION, 3, listeners3));
assertThat(exception.getMessage(), allOf(containsString("listener listener1: 'readTimeoutSeconds' needs to be a positive integer (set to: 0)")));
// set valid readTimeoutSeconds
authBuilder.withReadTimeoutSeconds(1);
List<GenericKafkaListener> listeners4 = asList(listenerBuilder.withAuth(authBuilder.build()).build());
exception = assertThrows(InvalidResourceException.class, () -> ListenersValidator.validate(Reconciliation.DUMMY_RECONCILIATION, 3, listeners4));
assertThat(exception.getMessage(), allOf(not(containsString("listener listener1: 'readTimeoutSeconds' needs to be a positive integer"))));
}
Aggregations