Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chkeita committed May 24, 2023
1 parent 45bb13a commit 67ecfa0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ApiService/ApiService/Functions/ReproVmss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ private async Async.Task<HttpResponseData> Post(HttpRequestData req) {
"repro_vm create");
}

// we’d like to track the usage of this feature;
var auth = await _context.SecretsOperations.GetSecretValue<Authentication>(vm.OkV.Auth!);
if (auth is null) {
return await _context.RequestHandling.NotOk(
req,
Error.Create(ErrorCode.INVALID_REQUEST, "unable to find auth"),
"repro_vm create");
}

// we’d like to track the usage of this feature;
// anonymize the user ID so we can distinguish multiple requests
{
var data = userInfo.OkV.UserInfo.ToString(); // rely on record ToString
Expand All @@ -92,7 +100,8 @@ private async Async.Task<HttpResponseData> Post(HttpRequestData req) {
}

var response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteAsJsonAsync(vm.OkV);

await response.WriteAsJsonAsync(ReproCreateResponse.FromRepro(vm.OkV, auth));
return response;
}

Expand Down
30 changes: 30 additions & 0 deletions src/ApiService/ApiService/OneFuzzTypes/Responses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,33 @@ public record NotificationTestResponse(
bool Success,
string? Error = null
) : BaseResponse();


public record ReproCreateResponse(
Guid VmId,
Guid TaskId,
ReproConfig Config,
Authentication Auth,
Os Os,
VmState State = VmState.Init,
Error? Error = null,
string? Ip = null,
DateTimeOffset? EndTime = null,
UserInfo? UserInfo = null
) : BaseResponse() {

public static ReproCreateResponse FromRepro(Repro repro, Authentication auth) {
return new ReproCreateResponse(
VmId: repro.VmId,
TaskId: repro.TaskId,
Config: repro.Config,
Auth: auth,
Os: repro.Os,
State: repro.State,
Error: repro.Error,
Ip: repro.Ip,
EndTime: repro.EndTime,
UserInfo: repro.UserInfo
);
}
}

0 comments on commit 67ecfa0

Please sign in to comment.