Skip to content

Commit 57aeb5f

Browse files
authored
Merge pull request #68 from thiagodasilva/new_identity_tests
Added Identity Probe and GetPluginCapabilities tests
2 parents 134de10 + 4842570 commit 57aeb5f

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

pkg/sanity/identity.go

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,70 @@ limitations under the License.
1717
package sanity
1818

1919
import (
20+
"fmt"
2021
"regexp"
2122

23+
"google.golang.org/grpc/codes"
24+
"google.golang.org/grpc/status"
25+
2226
csi "github.com/container-storage-interface/spec/lib/go/csi/v0"
2327
context "golang.org/x/net/context"
2428

2529
. "github.com/onsi/ginkgo"
2630
. "github.com/onsi/gomega"
2731
)
2832

29-
// TODO: Tests for GetPluginCapabilities
33+
var _ = Describe("GetPluginCapabilities [Identity Service]", func() {
34+
var (
35+
c csi.IdentityClient
36+
)
37+
38+
BeforeEach(func() {
39+
c = csi.NewIdentityClient(conn)
40+
})
41+
42+
It("should return appropriate capabilities", func() {
43+
req := &csi.GetPluginCapabilitiesRequest{}
44+
res, err := c.GetPluginCapabilities(context.Background(), req)
45+
Expect(err).NotTo(HaveOccurred())
46+
Expect(res).NotTo(BeNil())
47+
48+
By("checking successful response")
49+
Expect(res.GetCapabilities()).NotTo(BeNil())
50+
for _, cap := range res.GetCapabilities() {
51+
switch cap.GetService().GetType() {
52+
case csi.PluginCapability_Service_CONTROLLER_SERVICE:
53+
default:
54+
Fail(fmt.Sprintf("Unknown capability: %v\n", cap.GetService().GetType()))
55+
}
56+
}
57+
58+
})
59+
60+
})
61+
62+
var _ = Describe("Probe [Identity Service]", func() {
63+
var (
64+
c csi.IdentityClient
65+
)
3066

31-
// TODO: Tests for Probe
67+
BeforeEach(func() {
68+
c = csi.NewIdentityClient(conn)
69+
})
70+
71+
It("should return appropriate information", func() {
72+
req := &csi.ProbeRequest{}
73+
res, err := c.Probe(context.Background(), req)
74+
Expect(err).NotTo(HaveOccurred())
75+
Expect(res).NotTo(BeNil())
76+
77+
By("verifying return status")
78+
serverError, ok := status.FromError(err)
79+
Expect(ok).To(BeTrue())
80+
Expect(serverError.Code() == codes.FailedPrecondition ||
81+
serverError.Code() == codes.OK).To(BeTrue())
82+
})
83+
})
3284

3385
var _ = Describe("GetPluginInfo [Identity Server]", func() {
3486
var (

0 commit comments

Comments
 (0)