(t *testing.T)
| 182 | } |
| 183 | |
| 184 | func TestKeyID(t *testing.T) { |
| 185 | claims := jwt.MapClaims{ |
| 186 | "aud": testAudience, |
| 187 | "exp": time.Now().Add(1 * time.Hour).Unix(), |
| 188 | "iss": "https://testdomain/", |
| 189 | TenantIDClaim: "test_tenant_id", |
| 190 | UserIDClaim: "test_user_id", |
| 191 | } |
| 192 | privateKey, err := loadPrivateKey(testKeyFile) |
| 193 | require.NoError(t, err) |
| 194 | v := testValidator(t) |
| 195 | |
| 196 | // Bad key id |
| 197 | token := jwt.New(jwt.SigningMethodRS256) |
| 198 | token.Claims = claims |
| 199 | token.Header["kid"] = "foo" |
| 200 | tokenString, err := token.SignedString(privateKey) |
| 201 | require.NoError(t, err) |
| 202 | _, err = v.Validate(tokenString) |
| 203 | require.Error(t, err) |
| 204 | |
| 205 | // No key id |
| 206 | token = jwt.New(jwt.SigningMethodRS256) |
| 207 | token.Claims = claims |
| 208 | tokenString, err = token.SignedString(privateKey) |
| 209 | require.NoError(t, err) |
| 210 | _, err = v.Validate(tokenString) |
| 211 | require.Error(t, err) |
| 212 | } |
| 213 | |
| 214 | func TestAudienceSlice(t *testing.T) { |
| 215 | expectedIdent := Identity{ |
nothing calls this directly
no test coverage detected