Skip to content

Commit

Permalink
Fix variables serialization bug in TestProxyRecordPolicy (#37075)
Browse files Browse the repository at this point in the history
  • Loading branch information
alzimmermsft authored Oct 6, 2023
1 parent ef953f7 commit 6208c0d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,21 @@ private void setDefaultRecordingOptions() {
/**
* Stops recording of test traffic.
* @param variables A list of random variables generated during the test which is saved in the recording.
* @throws RuntimeException If the test proxy returns an error while stopping recording.
*/
public void stopRecording(Queue<String> variables) {
HttpRequest request = new HttpRequest(HttpMethod.POST, proxyUrl + "/record/stop")
.setHeader(HttpHeaderName.CONTENT_TYPE, "application/json")
.setHeader(X_RECORDING_ID, xRecordingId)
.setBody(serializeVariables(variables));
client.sendSync(request, Context.NONE).close();

try (HttpResponse response = client.sendSync(request, Context.NONE)) {
checkForTestProxyErrors(response);

if (response.getStatusCode() == 400) {
throw new RuntimeException(response.getBodyAsBinaryData().toString());
}
}
}

/**
Expand Down Expand Up @@ -138,7 +146,7 @@ private String serializeVariables(Queue<String> variables) {
if (variable == null) {
builder.append("null");
} else {
builder.append('"').append(variable).append('"');
builder.append(variable).append('"');
}
}

Expand Down

0 comments on commit 6208c0d

Please sign in to comment.