MCPcopy Create free account
hub / github.com/docker/docker-agent / TestParseAuthInfo_ValidToken

Function TestParseAuthInfo_ValidToken

cmd/root/debug_auth_test.go:23–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21}
22
23func TestParseAuthInfo_ValidToken(t *testing.T) {
24 t.Parallel()
25
26 now := time.Now()
27 exp := now.Add(time.Hour)
28 token := buildTestJWT(map[string]any{
29 "sub": "user-123",
30 "iss": "docker",
31 "iat": now.Unix(),
32 "exp": exp.Unix(),
33 })
34
35 info, err := parseAuthInfo(token)
36 require.NoError(t, err)
37 assert.Equal(t, token, info.Token)
38 assert.Equal(t, "user-123", info.Subject)
39 assert.Equal(t, "docker", info.Issuer)
40 assert.False(t, info.Expired)
41 assert.WithinDuration(t, now, info.IssuedAt, time.Second)
42 assert.WithinDuration(t, exp, info.ExpiresAt, time.Second)
43}
44
45func TestParseAuthInfo_ExpiredToken(t *testing.T) {
46 t.Parallel()

Callers

nothing calls this directly

Calls 4

buildTestJWTFunction · 0.85
parseAuthInfoFunction · 0.85
NowMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected