| 609 | } |
| 610 | |
| 611 | func (f *FakeIDP) AttemptLogin(t testing.TB, client *codersdk.Client, idTokenClaims jwt.MapClaims, opts ...func(r *http.Request)) (*codersdk.Client, *http.Response) { |
| 612 | t.Helper() |
| 613 | var err error |
| 614 | |
| 615 | cli := f.HTTPClient(client.HTTPClient) |
| 616 | shallowCpyCli := *cli |
| 617 | |
| 618 | if shallowCpyCli.Jar == nil { |
| 619 | shallowCpyCli.Jar, err = cookiejar.New(nil) |
| 620 | require.NoError(t, err, "failed to create cookie jar") |
| 621 | } |
| 622 | |
| 623 | unauthenticated := codersdk.New(client.URL) |
| 624 | unauthenticated.HTTPClient = &shallowCpyCli |
| 625 | |
| 626 | return f.LoginWithClient(t, unauthenticated, idTokenClaims, opts...) |
| 627 | } |
| 628 | |
| 629 | // LoginWithClient reuses the context of the passed in client. This means the same |
| 630 | // cookies will be used. This should be an unauthenticated client in most cases. |