MCPcopy Create free account
hub / github.com/brimdata/super / TestKeyID

Function TestKeyID

service/auth/validator_test.go:184–212  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

182}
183
184func 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
214func TestAudienceSlice(t *testing.T) {
215 expectedIdent := Identity{

Callers

nothing calls this directly

Calls 6

loadPrivateKeyFunction · 0.85
testValidatorFunction · 0.85
NewMethod · 0.80
AddMethod · 0.45
ValidateMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected