MCPcopy Index your code
hub / github.com/smallstep/cli / createToken

Function createToken

integration/crypto_test.go:484–509  ·  view source on GitHub ↗
(t *testing.T, jwk *jose.JSONWebKey, now time.Time)

Source from the content-addressed store, hash-verified

482}
483
484func createToken(t *testing.T, jwk *jose.JSONWebKey, now time.Time) string {
485 t.Helper()
486
487 c := &jose.Claims{
488 Issuer: "TestIssuer",
489 Subject: "TestSubject",
490 Audience: jose.Audience([]string{"TestAudience"}),
491 Expiry: jose.UnixNumericDate(now.Add(1 * time.Minute).Unix()),
492 NotBefore: jose.UnixNumericDate(now.Add(-1 * time.Minute).Unix()),
493 IssuedAt: jose.UnixNumericDate(now.Unix()),
494 ID: "test-id",
495 }
496
497 so := new(jose.SignerOptions).WithType("JWT").WithHeader("kid", jwk.KeyID)
498 signer, err := jose.NewSigner(jose.SigningKey{
499 Algorithm: jose.SignatureAlgorithm(jwk.Algorithm),
500 Key: jwk.Key,
501 }, so)
502 require.NoError(t, err)
503
504 payload := make(map[string]any)
505 raw, err := jose.Signed(signer).Claims(c).Claims(payload).CompactSerialize()
506 require.NoError(t, err)
507
508 return raw
509}
510
511func readBytes(t *testing.T, file string) []byte {
512 t.Helper()

Callers 1

TestCryptoJWTCommandFunction · 0.85

Calls 2

AudienceMethod · 0.80
CompactSerializeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…