MCPcopy
hub / github.com/grpc/grpc-go / makeGoodResponse

Function makeGoodResponse

credentials/sts/sts_test.go:118–131  ·  view source on GitHub ↗

We need a function to construct the response instead of simply declaring it as a variable since the response body will be consumed by the credentials, and therefore we will need a new one everytime.

()

Source from the content-addressed store, hash-verified

116// as a variable since the response body will be consumed by the
117// credentials, and therefore we will need a new one everytime.
118func makeGoodResponse() *http.Response {
119 respJSON, _ := json.Marshal(responseParameters{
120 AccessToken: accessTokenContents,
121 IssuedTokenType: "urn:ietf:params:oauth:token-type:access_token",
122 TokenType: "Bearer",
123 ExpiresIn: 3600,
124 })
125 respBody := io.NopCloser(bytes.NewReader(respJSON))
126 return &http.Response{
127 Status: "200 OK",
128 StatusCode: http.StatusOK,
129 Body: respBody,
130 }
131}
132
133// Overrides the http.Client with a fakeClient which sends a good response.
134func overrideHTTPClientGood() (*testutils.FakeHTTPClient, func()) {

Callers 2

overrideHTTPClientGoodFunction · 0.85
TestSendRequestMethod · 0.85

Calls 1

MarshalMethod · 0.65

Tested by

no test coverage detected