NewCustomTransport creates a new custom transport to be used for testing
(statusCode int)
| 19 | |
| 20 | // NewCustomTransport creates a new custom transport to be used for testing |
| 21 | func 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 |
| 38 | func NewCustomBearerToken(token string) runtime.ClientAuthInfoWriter { |