(t *testing.T)
| 21 | } |
| 22 | |
| 23 | func 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 | |
| 45 | func TestParseAuthInfo_ExpiredToken(t *testing.T) { |
| 46 | t.Parallel() |
nothing calls this directly
no test coverage detected