Skip to content

Commit c466707

Browse files
test: add tests for mounting shares with kerberos auth
1 parent c377d73 commit c466707

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

test/e2e/dynamic_provisioning_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,29 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
5252
})
5353

5454
testDriver = driver.InitNFSDriver()
55+
ginkgo.It("should create a volume with kerberos auth", func(ctx ginkgo.SpecContext) {
56+
pods := []testsuites.PodDetails{
57+
{
58+
Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data",
59+
Volumes: []testsuites.VolumeDetails{
60+
{
61+
ClaimSize: "1Gi",
62+
VolumeMount: testsuites.VolumeMountDetails{
63+
NameGenerate: "test-volume-",
64+
MountPathGenerate: "/mnt/test-",
65+
},
66+
MountOptions: []string{"sec=krb5", "noresvport", "nfsvers=4"},
67+
},
68+
},
69+
},
70+
}
71+
test := testsuites.DynamicallyProvisionedVolumeWithKerberosAuth{
72+
Pods: pods,
73+
StorageClassParameters: krbStorageClassParameters,
74+
Driver: testDriver,
75+
}
76+
test.Run(ctx, cs, ns)
77+
})
5578
ginkgo.It("should create a volume on demand with mount options", func(ctx ginkgo.SpecContext) {
5679
pods := []testsuites.PodDetails{
5780
{

test/e2e/e2e_suite_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ var (
9292
"mountPermissions": "0755",
9393
"onDelete": "archive",
9494
}
95+
krbStorageClassParameters = map[string]string{
96+
"server": "nfs-krb-server.default.svc.cluster.local",
97+
"share": "/srv/shared",
98+
"csi.storage.k8s.io/provisioner-secret-namespace": "default",
99+
"csi.storage.k8s.io/provisioner-secret-name": "mount-options",
100+
"mountPermissions": "0755",
101+
"authPasswordSecret": "krb-pwd",
102+
"authPrincipal": "nfs/nfs-krb-server.default.svc.cluster.local@NFS-KRB-SERVER.DEFAULT.SVC.CLUSTER.LOCAL",
103+
}
104+
95105
controllerServer *nfs.ControllerServer
96106
)
97107

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package testsuites
18+
19+
import (
20+
"context"
21+
22+
"github.com/kubernetes-csi/csi-driver-nfs/test/e2e/driver"
23+
"github.com/onsi/ginkgo/v2"
24+
v1 "k8s.io/api/core/v1"
25+
clientset "k8s.io/client-go/kubernetes"
26+
)
27+
28+
type DynamicallyProvisionedVolumeWithKerberosAuth struct {
29+
Driver driver.DynamicPVTestDriver
30+
Pods []PodDetails
31+
StorageClassParameters map[string]string
32+
}
33+
34+
func (t *DynamicallyProvisionedVolumeWithKerberosAuth) Run(ctx context.Context, client clientset.Interface, namespace *v1.Namespace) {
35+
for _, pod := range t.Pods {
36+
tpod, cleanup := pod.SetupWithDynamicVolumes(ctx, client, namespace, t.Driver, t.StorageClassParameters)
37+
for i := range cleanup {
38+
defer cleanup[i](ctx)
39+
}
40+
ginkgo.By("deploying the pod")
41+
tpod.Create(ctx)
42+
defer tpod.Cleanup(ctx)
43+
ginkgo.By("checking that the pods command exits with no error")
44+
tpod.WaitForSuccess(ctx)
45+
}
46+
}

0 commit comments

Comments
 (0)