Skip to content

Commit 4b6f02f

Browse files
committed
Bump SMB api from v1beta2 to v1
1 parent 437487c commit 4b6f02f

File tree

13 files changed

+1538
-0
lines changed

13 files changed

+1538
-0
lines changed

client/api/smb/v1/api.pb.go

Lines changed: 510 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/api/smb/v1/api.proto

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
syntax = "proto3";
2+
3+
package v1;
4+
5+
option go_package = "github.com/kubernetes-csi/csi-proxy/client/api/smb/v1";
6+
7+
service Smb {
8+
// NewSmbGlobalMapping creates an SMB mapping on the SMB client to an SMB share.
9+
rpc NewSmbGlobalMapping(NewSmbGlobalMappingRequest) returns (NewSmbGlobalMappingResponse) {}
10+
11+
// RemoveSmbGlobalMapping removes the SMB mapping to an SMB share.
12+
rpc RemoveSmbGlobalMapping(RemoveSmbGlobalMappingRequest) returns (RemoveSmbGlobalMappingResponse) {}
13+
}
14+
15+
16+
message NewSmbGlobalMappingRequest {
17+
// A remote SMB share to mount
18+
// All unicode characters allowed in SMB server name specifications are
19+
// permitted except for restrictions below
20+
//
21+
// Restrictions:
22+
// SMB remote path specified in the format: \\server-name\sharename, \\server.fqdn\sharename or \\a.b.c.d\sharename
23+
// If not an IP address, share name has to be a valid DNS name.
24+
// UNC specifications to local paths or prefix: \\?\ is not allowed.
25+
// Characters: + [ ] " / : ; | < > , ? * = $ are not allowed.
26+
string remote_path = 1;
27+
// Optional local path to mount the smb on
28+
string local_path = 2;
29+
30+
// Username credential associated with the share
31+
string username = 3;
32+
33+
// Password credential associated with the share
34+
string password = 4;
35+
}
36+
37+
message NewSmbGlobalMappingResponse {
38+
// Intentionally empty.
39+
}
40+
41+
42+
message RemoveSmbGlobalMappingRequest {
43+
// A remote SMB share mapping to remove
44+
// All unicode characters allowed in SMB server name specifications are
45+
// permitted except for restrictions below
46+
//
47+
// Restrictions:
48+
// SMB share specified in the format: \\server-name\sharename, \\server.fqdn\sharename or \\a.b.c.d\sharename
49+
// If not an IP address, share name has to be a valid DNS name.
50+
// UNC specifications to local paths or prefix: \\?\ is not allowed.
51+
// Characters: + [ ] " / : ; | < > , ? * = $ are not allowed.
52+
string remote_path = 1;
53+
}
54+
55+
message RemoveSmbGlobalMappingResponse {
56+
// Intentionally empty.
57+
}

client/groups/smb/v1/client_generated.go

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integrationtests/smb_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,7 @@ func TestSmbAPIGroup(t *testing.T) {
132132
t.Run("v1beta2SmbTests", func(t *testing.T) {
133133
v1beta2SmbTests(t)
134134
})
135+
t.Run("v1SmbTests", func(t *testing.T) {
136+
v1SmbTests(t)
137+
})
135138
}

integrationtests/smb_v1_test.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package integrationtests
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"os"
7+
"testing"
8+
9+
"github.com/kubernetes-csi/csi-proxy/client/api/smb/v1"
10+
client "github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1"
11+
12+
"github.com/stretchr/testify/assert"
13+
)
14+
15+
func v1SmbTests(t *testing.T) {
16+
client, err := client.NewClient()
17+
if err != nil {
18+
t.Fatalf("Fail to get smb API group client %v", err)
19+
}
20+
defer client.Close()
21+
22+
username := randomString(5)
23+
password := randomString(10) + "!"
24+
sharePath := fmt.Sprintf("C:\\smbshare%s", randomString(5))
25+
smbShare := randomString(6)
26+
27+
localPath := fmt.Sprintf("C:\\localpath%s", randomString(5))
28+
29+
if err = setupUser(username, password); err != nil {
30+
t.Fatalf("TestSmbAPIGroup %v", err)
31+
}
32+
defer removeUser(t, username)
33+
34+
if err = setupSmbShare(smbShare, sharePath, username); err != nil {
35+
t.Fatalf("TestSmbAPIGroup %v", err)
36+
}
37+
defer removeSmbShare(t, smbShare)
38+
39+
hostname, err := os.Hostname()
40+
assert.Nil(t, err)
41+
42+
username = "domain\\" + username
43+
remotePath := "\\\\" + hostname + "\\" + smbShare
44+
// simulate Mount SMB operations around staging a volume on a node
45+
mountSmbShareReq := &v1.NewSmbGlobalMappingRequest{
46+
RemotePath: remotePath,
47+
Username: username,
48+
Password: password,
49+
}
50+
_, err = client.NewSmbGlobalMapping(context.Background(), mountSmbShareReq)
51+
if err != nil {
52+
t.Fatalf("TestSmbAPIGroup %v", err)
53+
}
54+
55+
err = getSmbGlobalMapping(remotePath)
56+
assert.Nil(t, err)
57+
58+
err = writeReadFile(remotePath)
59+
assert.Nil(t, err)
60+
61+
unmountSmbShareReq := &v1.RemoveSmbGlobalMappingRequest{
62+
RemotePath: remotePath,
63+
}
64+
_, err = client.RemoveSmbGlobalMapping(context.Background(), unmountSmbShareReq)
65+
if err != nil {
66+
t.Fatalf("TestSmbAPIGroup %v", err)
67+
}
68+
err = getSmbGlobalMapping(remotePath)
69+
assert.NotNil(t, err)
70+
err = writeReadFile(localPath)
71+
assert.NotNil(t, err)
72+
73+
}

pkg/server/smb/api_group_generated.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package v1
2+
3+
// Add manual conversion functions here to override automatic conversion functions

pkg/server/smb/impl/v1/conversion_generated.go

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)