MCPcopy Index your code
hub / github.com/cloudfoundry/multiapps-cli-plugin / NewCustomTransport

Function NewCustomTransport

testutil/transport.go:21–35  ·  view source on GitHub ↗

NewCustomTransport creates a new custom transport to be used for testing

(statusCode int)

Source from the content-addressed store, hash-verified

19
20// NewCustomTransport creates a new custom transport to be used for testing
21func NewCustomTransport(statusCode int) *csrf.Transport {
22 transport := roundTripperFunc(func(req *http.Request) (*http.Response, error) {
23 var resp http.Response
24 resp.StatusCode = statusCode
25 resp.Header = make(http.Header)
26 buf := bytes.NewBuffer(nil)
27 resp.Body = io.NopCloser(buf)
28 return &resp, nil
29 })
30
31 // Wrap with User-Agent transport for testing consistency
32 userAgentTransport := baseclient.NewUserAgentTransport(transport)
33
34 return &csrf.Transport{Delegate: userAgentTransport, Csrf: &csrf.CsrfTokenHelper{}}
35}
36
37// NewCustomBearerToken creates a new bearer token to be used for testing
38func NewCustomBearerToken(token string) runtime.ClientAuthInfoWriter {

Calls 2

NewUserAgentTransportFunction · 0.92
roundTripperFuncFuncType · 0.85

Tested by 2

newRetryableRestClientFunction · 0.74
newRestClientFunction · 0.74