Skip to content

Commit 0b7322b

Browse files
test(kerberos): Test successful login to the HBase rest server with Kerberos (#711)
1 parent a36862b commit 0b7322b

File tree

3 files changed

+82
-30
lines changed

3 files changed

+82
-30
lines changed

tests/templates/kuttl/kerberos/30-install-hbase.yaml.j2

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,17 @@ commands:
6565
roleGroups:
6666
default:
6767
replicas: 1
68+
configOverrides:
69+
hbase-site.xml:
70+
# Allow Kerberos authentication at the hbase-restserver-default-headless service
71+
hbase.rest.authentication.kerberos.principal: HTTP/hbase-restserver-default-headless.$NAMESPACE.svc.cluster.local@\${env:KERBEROS_REALM}
72+
podOverrides:
73+
spec:
74+
volumes:
75+
- name: kerberos
76+
ephemeral:
77+
volumeClaimTemplate:
78+
metadata:
79+
annotations:
80+
secrets.stackable.tech/scope: service=hbase,service=hbase-restserver-default-headless
6881
EOF

tests/templates/kuttl/kerberos/42-test-rest-server.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestStep
4+
commands:
5+
- script: |
6+
kubectl apply -n $NAMESPACE -f - <<EOF
7+
---
8+
apiVersion: batch/v1
9+
kind: Job
10+
metadata:
11+
name: test-rest-server
12+
spec:
13+
template:
14+
spec:
15+
serviceAccountName: test-sa
16+
containers:
17+
- name: test-rest-server
18+
image: oci.stackable.tech/sdp/testing-tools:0.2.0-stackable0.0.0-dev
19+
command:
20+
- /bin/bash
21+
- -c
22+
- |
23+
status_code=\$(curl --write-out '%{http_code}' --silent --insecure --output /dev/null "https://hbase-restserver-default-headless:8080")
24+
25+
if [[ "\$status_code" -eq 401 ]] ; then
26+
echo "[PASS] Successfully got 401 as we did not authenticate"
27+
else
28+
echo "[FAIL] Expected the restserver to return a 401 as we did not authenticate"
29+
exit 1
30+
fi
31+
32+
kinit -kt /stackable/kerberos/keytab testuser/test-rest-server.$NAMESPACE.svc.cluster.local@{{ test_scenario['values']['kerberos-realm'] }}
33+
34+
status_code=\$(curl --write-out '%{http_code}' --silent --insecure --output /dev/null --negotiate --user : "https://hbase-restserver-default-headless:8080")
35+
36+
if [[ "\$status_code" -eq 200 ]] ; then
37+
echo "[PASS] Successfully got 200 as we did authenticate"
38+
else
39+
echo "[FAIL] Expected the restserver to return a 200 as we did authenticate"
40+
exit 1
41+
fi
42+
env:
43+
- name: KRB5_CONFIG
44+
value: /stackable/kerberos/krb5.conf
45+
volumeMounts:
46+
- name: kerberos
47+
mountPath: /stackable/kerberos
48+
volumes:
49+
- name: kerberos
50+
ephemeral:
51+
volumeClaimTemplate:
52+
metadata:
53+
annotations:
54+
secrets.stackable.tech/class: kerberos-$NAMESPACE
55+
secrets.stackable.tech/scope: service=test-rest-server
56+
secrets.stackable.tech/kerberos.service.names: testuser
57+
spec:
58+
storageClassName: secrets.stackable.tech
59+
accessModes:
60+
- ReadWriteOnce
61+
resources:
62+
requests:
63+
storage: "1"
64+
securityContext:
65+
fsGroup: 1000
66+
runAsGroup: 1000
67+
runAsUser: 1000
68+
restartPolicy: OnFailure
69+
EOF

0 commit comments

Comments
 (0)