| 153 | } |
| 154 | |
| 155 | func NewHTTPClientWithArbitrarySessionCookie(ctx context.Context, t *testing.T, reg *driver.RegistryDefault) *http.Client { |
| 156 | req := NewTestHTTPRequest(t, "GET", "/sessions/whoami", nil) |
| 157 | req = req.WithContext(contextx.WithConfigValue(ctx, "session.lifespan", time.Hour)) |
| 158 | id := x.NewUUID() |
| 159 | s, err := NewActiveSession(req, reg, |
| 160 | &identity.Identity{ID: id, State: identity.StateActive, Traits: []byte("{}"), Credentials: map[identity.CredentialsType]identity.Credentials{ |
| 161 | identity.CredentialsTypePassword: {Type: "password", Identifiers: []string{id.String()}, Config: []byte(`{"hashed_password":"$2a$04$zvZz1zV"}`)}, |
| 162 | }}, |
| 163 | time.Now(), |
| 164 | identity.CredentialsTypePassword, |
| 165 | identity.AuthenticatorAssuranceLevel1, |
| 166 | ) |
| 167 | require.NoError(t, err, "Could not initialize session from identity.") |
| 168 | |
| 169 | return NewHTTPClientWithSessionCookie(ctx, t, reg, s) |
| 170 | } |
| 171 | |
| 172 | func NewNoRedirectHTTPClientWithArbitrarySessionCookie(ctx context.Context, t *testing.T, reg *driver.RegistryDefault) *http.Client { |
| 173 | req := NewTestHTTPRequest(t, "GET", "/sessions/whoami", nil) |