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

registerAPI always return 200 #1146

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Covid19Radar.Api.Tests/RegisterApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void CreateMethod()
}

[TestMethod]
public async Task RunAsyncMethod()
public void RunAsyncMethod()
{
// preparation
var userRepo = new Mock<IUserRepository>();
Expand All @@ -48,12 +48,12 @@ public async Task RunAsyncMethod()
config.Setup(_ => _["AzureFrontDoorId"]).Returns("3a1f9e76-f8c9-4000-b4e0-9bb08abe9fe5");

// action
await registerApi.RunAsync(context.Object.Request);
registerApi.RunAsync(context.Object.Request);
// assert
}

[TestMethod]
public async Task RunAsyncMethodOnErrorValidationServer()
public void RunAsyncMethodOnErrorValidationServer()
{
// preparation
var userRepo = new Mock<IUserRepository>();
Expand All @@ -66,7 +66,7 @@ public async Task RunAsyncMethodOnErrorValidationServer()
var context = new Mock<HttpContext>();

// action
var result = await registerApi.RunAsync(context.Object.Request);
var result = registerApi.RunAsync(context.Object.Request);
// assert
Assert.AreEqual(IValidationServerService.ValidateResult.Error.ErrorActionResult, result);
}
Expand Down
9 changes: 2 additions & 7 deletions src/Covid19Radar.Api/RegisterApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public RegisterApi(
}

[FunctionName(nameof(RegisterApi))]
public async Task<IActionResult> RunAsync(
public IActionResult RunAsync(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "register")] HttpRequest req)
{
Logger.LogInformation("C# HTTP trigger function processed a request.");
Expand All @@ -50,12 +50,7 @@ public async Task<IActionResult> RunAsync(
return validateResult.ErrorActionResult;
}

// UserUuid
var userUuid = Guid.NewGuid().ToString("N")
+ DateTime.UtcNow.Ticks.ToString();

// save to DB
return await Register(userUuid);
return new OkResult();
}

private async Task<IActionResult> Register(string userUuid)
Expand Down