(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func (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 | |
| 102 | func (s) TestCheckSecurityLevelNoGetCommonAuthInfoMethod(t *testing.T) { |
| 103 | if err := CheckSecurityLevel(testAuthInfoNoGetCommonAuthInfoMethod{}, PrivacyAndIntegrity); err != nil { |
nothing calls this directly
no test coverage detected