compareRequest compares the http.Request received in the test with the expected requestParameters specified in wantReqParams.
(gotRequest *http.Request, wantReqParams *requestParameters)
| 191 | // compareRequest compares the http.Request received in the test with the |
| 192 | // expected requestParameters specified in wantReqParams. |
| 193 | func compareRequest(gotRequest *http.Request, wantReqParams *requestParameters) error { |
| 194 | jsonBody, err := json.Marshal(wantReqParams) |
| 195 | if err != nil { |
| 196 | return err |
| 197 | } |
| 198 | wantReq, err := http.NewRequest("POST", serviceURI, bytes.NewBuffer(jsonBody)) |
| 199 | if err != nil { |
| 200 | return fmt.Errorf("failed to create http request: %v", err) |
| 201 | } |
| 202 | wantReq.Header.Set("Content-Type", "application/json") |
| 203 | |
| 204 | wantR, err := httputil.DumpRequestOut(wantReq, true) |
| 205 | if err != nil { |
| 206 | return err |
| 207 | } |
| 208 | gotR, err := httputil.DumpRequestOut(gotRequest, true) |
| 209 | if err != nil { |
| 210 | return err |
| 211 | } |
| 212 | if diff := cmp.Diff(string(wantR), string(gotR)); diff != "" { |
| 213 | return fmt.Errorf("sts request diff (-want +got):\n%s", diff) |
| 214 | } |
| 215 | return nil |
| 216 | } |
| 217 | |
| 218 | // receiveAndCompareRequest waits for a request to be sent out by the |
| 219 | // credentials implementation using the fakeHTTPClient and compares it to an |
no test coverage detected