Skip to content

Commit 9761bb9

Browse files
committed
identity: Verify name
1 parent 1314615 commit 9761bb9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkg/sanity/identity.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package sanity
1818

1919
import (
20+
"regexp"
21+
2022
"google.golang.org/grpc/codes"
2123
"google.golang.org/grpc/status"
2224

@@ -107,8 +109,11 @@ var _ = Describe("GetPluginInfo [Identity Server]", func() {
107109
Expect(err).NotTo(HaveOccurred())
108110
Expect(res).NotTo(BeNil())
109111

110-
By("Verifying name size and characters")
112+
By("verifying name size and characters")
111113
Expect(res.GetName()).ToNot(HaveLen(0))
112114
Expect(len(res.GetName())).To(BeNumerically("<=", 63))
115+
Expect(regexp.
116+
MustCompile("^[a-zA-Z][A-Za-z0-9-\\.\\_]{1,61}[a-zA-Z]$").
117+
MatchString(res.GetName())).To(BeTrue())
113118
})
114119
})

pkg/sanity/sanity_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestSanity(t *testing.T) {
6363
d.EXPECT().
6464
GetPluginInfo(gomock.Any(), pluginInforeq).
6565
Return(&csi.GetPluginInfoResponse{
66-
Name: "mock",
66+
Name: "org._csi-test_.mock",
6767
}, nil).
6868
AnyTimes()
6969

0 commit comments

Comments
 (0)