MCPcopy Index your code
hub / github.com/coder/coder / HTTPClient

Method HTTPClient

coderd/coderdtest/oidctest/idp.go:1451–1483  ·  view source on GitHub ↗

HTTPClient does nothing if IsServing is used. If IsServing is not used, then it will return a client that will make requests to the IDP all in memory. If a request is not to the IDP, then the passed in client will be used. If no client is passed in, then any regular network requests will fail.

(rest *http.Client)

Source from the content-addressed store, hash-verified

1449// client will be used. If no client is passed in, then any regular network
1450// requests will fail.
1451func (f *FakeIDP) HTTPClient(rest *http.Client) *http.Client {
1452 if f.serve {
1453 if rest == nil {
1454 return &http.Client{}
1455 }
1456 return rest
1457 }
1458
1459 var jar http.CookieJar
1460 if rest != nil {
1461 jar = rest.Jar
1462 }
1463 return &http.Client{
1464 Jar: jar,
1465 Transport: fakeRoundTripper{
1466 roundTrip: func(req *http.Request) (*http.Response, error) {
1467 u, _ := url.Parse(f.locked.Issuer())
1468 if req.URL.Host != u.Host {
1469 if fakeCoderd := f.locked.FakeCoderd(); fakeCoderd != nil {
1470 return fakeCoderd(req)
1471 }
1472 if rest == nil || rest.Transport == nil {
1473 return nil, xerrors.Errorf("unexpected network request to %q", req.URL.Host)
1474 }
1475 return rest.Transport.RoundTrip(req)
1476 }
1477 resp := httptest.NewRecorder()
1478 f.locked.Handler().ServeHTTP(resp, req)
1479 return resp.Result(), nil
1480 },
1481 },
1482 }
1483}
1484
1485// RefreshUsed returns if the refresh token has been used. All refresh tokens
1486// can only be used once, then they are deleted.

Callers 13

AttemptLoginMethod · 0.95
LoginWithClientMethod · 0.95
ExternalLoginMethod · 0.95
OIDCCallbackMethod · 0.95
internalOIDCConfigMethod · 0.95
TestFakeIDPBasicFlowFunction · 0.95
TestIDPIssuerMismatchFunction · 0.95
TestGithubRateLimitsFunction · 0.95
TestRefreshTokenFunction · 0.80
TestRevokeTokenFunction · 0.80
FetchPullRequestDiffMethod · 0.80

Calls 8

IssuerMethod · 0.80
FakeCoderdMethod · 0.80
ParseMethod · 0.65
ErrorfMethod · 0.45
RoundTripMethod · 0.45
ServeHTTPMethod · 0.45
HandlerMethod · 0.45
ResultMethod · 0.45

Tested by 5

TestFakeIDPBasicFlowFunction · 0.76
TestIDPIssuerMismatchFunction · 0.76
TestGithubRateLimitsFunction · 0.76
TestRefreshTokenFunction · 0.64
TestRevokeTokenFunction · 0.64