11#! /usr/bin/env bash
22# Usage: test_client_auth_tls.sh namespace
33
4- NAMESPACE=$1
5-
64# to be safe
75unset TOPIC
86unset BAD_TOPIC
97
10- SERVER= " test-kafka-broker-default-0.test-kafka-broker-default. ${NAMESPACE} .svc.cluster.local:9093 "
8+ echo " Connecting to boostrap address $KAFKA "
119
1210echo " Start client auth TLS testing..."
1311# ###########################################################################
@@ -20,15 +18,15 @@ BAD_TOPIC=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20 ; echo '')
2018# write client config
2119echo $' security.protocol=SSL\n ssl.keystore.location=/stackable/tls_keystore_server/keystore.p12\n ssl.keystore.password=\n ssl.truststore.location=/stackable/tls_keystore_server/truststore.p12\n ssl.truststore.password=' > /tmp/client.config
2220
23- if /stackable/kafka/bin/kafka-topics.sh --create --topic " $TOPIC " --bootstrap-server " $SERVER " --command-config /tmp/client.config
21+ if /stackable/kafka/bin/kafka-topics.sh --create --topic " $TOPIC " --bootstrap-server " $KAFKA " --command-config /tmp/client.config
2422then
2523 echo " [SUCCESS] Secure client topic created!"
2624else
2725 echo " [ERROR] Secure client topic creation failed!"
2826 exit 1
2927fi
3028
31- if /stackable/kafka/bin/kafka-topics.sh --list --topic " $TOPIC " --bootstrap-server " $SERVER " --command-config /tmp/client.config | grep " $TOPIC "
29+ if /stackable/kafka/bin/kafka-topics.sh --list --topic " $TOPIC " --bootstrap-server " $KAFKA " --command-config /tmp/client.config | grep " $TOPIC "
3230then
3331 echo " [SUCCESS] Secure client topic read!"
3432else
3937# ###########################################################################
4038# Test the connection without certificates
4139# ###########################################################################
42- if /stackable/kafka/bin/kafka-topics.sh --create --topic " $BAD_TOPIC " --bootstrap-server " $SERVER " & > /dev/null
40+ if /stackable/kafka/bin/kafka-topics.sh --create --topic " $BAD_TOPIC " --bootstrap-server " $KAFKA " & > /dev/null
4341then
4442 echo " [ERROR] Secure client topic created without certificates!"
4543 exit 1
6260# Test the connection with bad certificate
6361# ###########################################################################
6462echo $' security.protocol=SSL\n ssl.keystore.location=/tmp/wrong_keystore.p12\n ssl.keystore.password=changeit\n ssl.truststore.location=/tmp/wrong_truststore.p12\n ssl.truststore.password=changeit' > /tmp/client.config
65- if /stackable/kafka/bin/kafka-topics.sh --create --topic " $BAD_TOPIC " --bootstrap-server " $SERVER " --command-config /tmp/client.config & > /dev/null
63+ if /stackable/kafka/bin/kafka-topics.sh --create --topic " $BAD_TOPIC " --bootstrap-server " $KAFKA " --command-config /tmp/client.config & > /dev/null
6664then
6765 echo " [ERROR] Secure client topic created with wrong certificate!"
6866 exit 1
0 commit comments