Skip to content

Commit

Permalink
Merge pull request kubernetes-csi#9 from lpabon/idregexp
Browse files Browse the repository at this point in the history
identity: Verify name
  • Loading branch information
lpabon committed Jan 3, 2018
2 parents a0057c8 + d60cc8d commit 11dacf9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/sanity/identity.go
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package sanity

import (
"regexp"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

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

By("Verifying name size and characters")
By("verifying name size and characters")
Expect(res.GetName()).ToNot(HaveLen(0))
Expect(len(res.GetName())).To(BeNumerically("<=", 63))
Expect(regexp.
MustCompile("^[a-zA-Z][A-Za-z0-9-\\.\\_]{0,61}[a-zA-Z]$").
MatchString(res.GetName())).To(BeTrue())
})
})
2 changes: 1 addition & 1 deletion pkg/sanity/sanity_test.go
Expand Up @@ -63,7 +63,7 @@ func TestSanity(t *testing.T) {
d.EXPECT().
GetPluginInfo(gomock.Any(), pluginInforeq).
Return(&csi.GetPluginInfoResponse{
Name: "mock",
Name: "org._csi-test_.mock",
}, nil).
AnyTimes()

Expand Down

0 comments on commit 11dacf9

Please sign in to comment.