MCPcopy
hub / github.com/grpc/grpc-go / TestCheckSecurityLevel

Method TestCheckSecurityLevel

credentials/credentials_test.go:59–100  ·  credentials/credentials_test.go::s.TestCheckSecurityLevel
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func (s) TestCheckSecurityLevel(t *testing.T) {
60 testCases := []struct {
61 authLevel SecurityLevel
62 testLevel SecurityLevel
63 want bool
64 }{
65 {
66 authLevel: PrivacyAndIntegrity,
67 testLevel: PrivacyAndIntegrity,
68 want: true,
69 },
70 {
71 authLevel: IntegrityOnly,
72 testLevel: PrivacyAndIntegrity,
73 want: false,
74 },
75 {
76 authLevel: IntegrityOnly,
77 testLevel: NoSecurity,
78 want: true,
79 },
80 {
81 authLevel: InvalidSecurityLevel,
82 testLevel: IntegrityOnly,
83 want: true,
84 },
85 {
86 authLevel: InvalidSecurityLevel,
87 testLevel: PrivacyAndIntegrity,
88 want: true,
89 },
90 }
91 for _, tc := range testCases {
92 err := CheckSecurityLevel(testAuthInfo{CommonAuthInfo: CommonAuthInfo{SecurityLevel: tc.authLevel}}, tc.testLevel)
93 if tc.want && (err != nil) {
94 t.Fatalf("CheckSeurityLevel(%s, %s) returned failure but want success", tc.authLevel.String(), tc.testLevel.String())
95 } else if !tc.want && (err == nil) {
96 t.Fatalf("CheckSeurityLevel(%s, %s) returned success but want failure", tc.authLevel.String(), tc.testLevel.String())
97
98 }
99 }
100}
101
102func (s) TestCheckSecurityLevelNoGetCommonAuthInfoMethod(t *testing.T) {
103 if err := CheckSecurityLevel(testAuthInfoNoGetCommonAuthInfoMethod{}, PrivacyAndIntegrity); err != nil {

Callers

nothing calls this directly

Calls 3

CheckSecurityLevelFunction · 0.85
FatalfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected