1
1
#! /usr/bin/env bash
2
2
# Usage: test_client_auth_tls.sh namespace
3
3
4
- NAMESPACE=$1
5
-
6
4
# to be safe
7
5
unset TOPIC
8
6
unset BAD_TOPIC
9
7
10
- SERVER= " test-kafka-broker-default-0.test-kafka-broker-default. ${NAMESPACE} .svc.cluster.local:9093 "
8
+ echo " Connecting to boostrap address $KAFKA "
11
9
12
10
echo " Start client auth TLS testing..."
13
11
# ###########################################################################
@@ -20,15 +18,15 @@ BAD_TOPIC=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20 ; echo '')
20
18
# write client config
21
19
echo $' 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
22
20
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
24
22
then
25
23
echo " [SUCCESS] Secure client topic created!"
26
24
else
27
25
echo " [ERROR] Secure client topic creation failed!"
28
26
exit 1
29
27
fi
30
28
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 "
32
30
then
33
31
echo " [SUCCESS] Secure client topic read!"
34
32
else
39
37
# ###########################################################################
40
38
# Test the connection without certificates
41
39
# ###########################################################################
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
43
41
then
44
42
echo " [ERROR] Secure client topic created without certificates!"
45
43
exit 1
62
60
# Test the connection with bad certificate
63
61
# ###########################################################################
64
62
echo $' 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
66
64
then
67
65
echo " [ERROR] Secure client topic created with wrong certificate!"
68
66
exit 1
0 commit comments