use of org.bf2.admin.kafka.systemtest.Environment.CONFIG in project kafka-admin-api by bf2fc6cc711aee1a0c2a.
the class AdminClientFactory method createProducer.
public Producer<String, String> createProducer() {
Map<String, Object> props = config.getProducerConfig();
if (config.isOauthEnabled()) {
if (token.isResolvable()) {
final String accessToken = token.get().getRawToken();
props.put(SaslConfigs.SASL_JAAS_CONFIG, String.format(SASL_OAUTH_CONFIG_TEMPLATE, accessToken));
} else {
log.warn("OAuth is enabled, but there is no JWT principal");
}
} else if (config.isBasicEnabled()) {
extractCredentials(Optional.ofNullable(headers.get().getHeaderString(HttpHeaders.AUTHORIZATION))).ifPresentOrElse(credentials -> props.put(SaslConfigs.SASL_JAAS_CONFIG, credentials), () -> {
throw new NotAuthorizedException("Invalid or missing credentials", Response.status(Status.UNAUTHORIZED).build());
});
} else {
log.debug("OAuth is disabled - no attempt to set access token in Admin Client config");
}
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
props.put(ProducerConfig.ACKS_CONFIG, "all");
return new KafkaProducer<>(props);
}
use of org.bf2.admin.kafka.systemtest.Environment.CONFIG in project kafka-admin-api by bf2fc6cc711aee1a0c2a.
the class DeploymentManager method deployKafka.
private KafkaContainer<?> deployKafka() {
LOGGER.info("Deploying Kafka container");
Map<String, String> env = new HashMap<>();
try (InputStream stream = getClass().getResourceAsStream("/kafka-oauth/env.properties")) {
Properties envProps = new Properties();
envProps.load(stream);
envProps.keySet().stream().map(Object::toString).forEach(key -> env.put(key, envProps.getProperty(key)));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
String imageTag = System.getProperty("strimzi-kafka.tag");
var container = new KeycloakSecuredKafkaContainer(imageTag).withLabels(Collections.singletonMap("test-ident", Environment.TEST_CONTAINER_LABEL)).withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("systemtests.oauth-kafka"), true)).withCreateContainerCmdModifier(cmd -> cmd.withName(name("oauth-kafka"))).withEnv(env).withNetwork(testNetwork).withClasspathResourceMapping("/certs/cluster.keystore.p12", "/opt/kafka/certs/cluster.keystore.p12", BindMode.READ_ONLY).withClasspathResourceMapping("/certs/cluster.truststore.p12", "/opt/kafka/certs/cluster.truststore.p12", BindMode.READ_ONLY).withClasspathResourceMapping("/kafka-oauth/config/", "/opt/kafka/config/strimzi/", BindMode.READ_ONLY).withCopyFileToContainer(MountableFile.forClasspathResource("/kafka-oauth/scripts/functions.sh"), "/opt/kafka/functions.sh").withCopyFileToContainer(MountableFile.forClasspathResource("/kafka-oauth/scripts/simple_kafka_config.sh", 0755), "/opt/kafka/simple_kafka_config.sh").withCopyFileToContainer(MountableFile.forClasspathResource("/kafka-oauth/scripts/start.sh", 0755), "/opt/kafka/start.sh").withCommand("/opt/kafka/start.sh");
container.start();
return container;
}
use of org.bf2.admin.kafka.systemtest.Environment.CONFIG in project kafka-admin-api by bf2fc6cc711aee1a0c2a.
the class ConsumerGroupsOAuthTestIT method setup.
@BeforeEach
void setup() {
String token = tokenUtils.getToken(UserType.OWNER.getUsername());
topicUtils = new TopicUtils(config, token);
topicUtils.deleteAllTopics();
groupUtils = new ConsumerUtils(config, token);
batchId = UUID.randomUUID().toString();
}
use of org.bf2.admin.kafka.systemtest.Environment.CONFIG in project kafka-admin-api by bf2fc6cc711aee1a0c2a.
the class RecordEndpointOAuthTestIT method setup.
@BeforeEach
void setup() {
String token = tokenUtils.getToken(UserType.OWNER.getUsername());
topicUtils = new TopicUtils(config, token);
topicUtils.deleteAllTopics();
recordUtils = new RecordUtils(config, token);
metricsUtils = new MetricsUtils(metricsUrl);
}
use of org.bf2.admin.kafka.systemtest.Environment.CONFIG in project kafka-admin-api by bf2fc6cc711aee1a0c2a.
the class RestOAuthTestIT method setup.
@BeforeEach
void setup() {
String token = tokenUtils.getToken(UserType.OWNER.getUsername());
topicUtils = new TopicUtils(config, token);
topicUtils.deleteAllTopics();
this.metricsUtils = new MetricsUtils(metricsUrl);
}
Aggregations