Skip to content

Commit

Permalink
Fix broken local audit test. (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonpollett authored May 13, 2019
1 parent 8583c70 commit 868d1c5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Microsoft.Health.Fhir.Api.Features.ActionResults
{
public abstract class BaseActionResult<TResult> : ActionResult
public abstract class BaseActionResult<TResult> : ActionResult, IBaseActionResult
{
protected BaseActionResult()
{
Expand Down Expand Up @@ -73,5 +73,10 @@ public override Task ExecuteResultAsync(ActionContext context)

return result.ExecuteResultAsync(context);
}

public string GetResultTypeName()
{
return Result?.GetType().Name;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// -------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// -------------------------------------------------------------------------------------------------

namespace Microsoft.Health.Fhir.Api.Features.ActionResults
{
public interface IBaseActionResult
{
string GetResultTypeName();
}
}
4 changes: 2 additions & 2 deletions src/Microsoft.Health.Fhir.Api/Features/Audit/AuditHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public void LogExecuting(string controllerName, string actionName)
}

/// <inheritdoc />
public void LogExecuted(string controllerName, string actionName, HttpStatusCode statusCode, string resourceType)
public void LogExecuted(string controllerName, string actionName, HttpStatusCode statusCode, string responseResultType)
{
Log(AuditAction.Executed, controllerName, actionName, statusCode, resourceType);
Log(AuditAction.Executed, controllerName, actionName, statusCode, responseResultType);
}

void IStartable.Start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ public override void OnResultExecuted(ResultExecutedContext context)

Debug.Assert(actionDescriptor != null, "The ActionDescriptor must be ControllerActionDescriptor.");

var fhirResult = context.Result as FhirResult;
// The result can either be a FhirResult or an OperationOutcomeResult which both extend BaseActionResult.
var result = context.Result as IBaseActionResult;

_auditHelper.LogExecuted(
actionDescriptor.ControllerName,
actionDescriptor.ActionName,
(HttpStatusCode)context.HttpContext.Response.StatusCode,
fhirResult?.Result?.TypeName);
result?.GetResultTypeName());

base.OnResultExecuted(context);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Health.Fhir.Api/Features/Audit/IAuditHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface IAuditHelper
/// <param name="controllerName">The controller name.</param>
/// <param name="actionName">The action name.</param>
/// <param name="statusCode">The HTTP status code.</param>
/// <param name="resourceType">The optional resource type.</param>
void LogExecuted(string controllerName, string actionName, HttpStatusCode statusCode, string resourceType);
/// <param name="responseResultType">The optional response result type.</param>
void LogExecuted(string controllerName, string actionName, HttpStatusCode statusCode, string responseResultType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ void Advance()
// Consent, should only be done if we can find the button
try
{
// Sleep in case a light box is shown.
Thread.Sleep(TimeSpan.FromMilliseconds(1000));
var button = driver.FindElementById("idSIButton9");
Advance();
}
Expand Down

0 comments on commit 868d1c5

Please sign in to comment.