コード例 #1
0
        private void AssertProperRequestSubTypeSet(ActionExecutingContext executingContext, string methodName, string requestSubType, AuditLoggingFilterAttribute filter)
        {
            executingContext.ActionDescriptor = new ControllerActionDescriptor();
            var descriptor = executingContext.ActionDescriptor as ControllerActionDescriptor;

            descriptor.MethodInfo = typeof(FhirController).GetMethod(methodName);
            filter.OnActionExecuting(executingContext);
            Assert.Equal(_fhirRequestContextAccessor.FhirRequestContext.RequestSubType.Code, requestSubType);
            Assert.Equal(_fhirRequestContextAccessor.FhirRequestContext.RequestSubType.System, AuditEventSubType.System);
        }
コード例 #2
0
        public void GivenAFhirRequest_WhenExecutingAnAnonymousAction_ThenLogAuditMustNotBeCalled()
        {
            var executingContext = new ActionExecutingContext(
                new ActionContext(new DefaultHttpContext(), new RouteData(), new ControllerActionDescriptor()
            {
                DisplayName = "Executing Context Test Descriptor"
            }),
                new List <IFilterMetadata>(),
                _actionArguments,
                FilterTestsHelper.CreateMockFhirController());

            var descriptor = executingContext.ActionDescriptor as ControllerActionDescriptor;

            descriptor.MethodInfo = typeof(FilterTestsHelper).GetMethod("MethodWithAnonymousAttribute");
            _filter.OnActionExecuting(executingContext);
            _auditLogger.DidNotReceiveWithAnyArgs().LogAudit(Arg.Any <AuditAction>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Uri>(), Arg.Any <HttpStatusCode?>(), Arg.Any <string>(), Arg.Any <IReadOnlyCollection <KeyValuePair <string, string> > >());
            _executedContext.ActionDescriptor = executingContext.ActionDescriptor;
            _filter.OnResultExecuted(_executedContext);
            _auditLogger.DidNotReceiveWithAnyArgs().LogAudit(Arg.Any <AuditAction>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <Uri>(), Arg.Any <HttpStatusCode?>(), Arg.Any <string>(), Arg.Any <IReadOnlyCollection <KeyValuePair <string, string> > >());
        }
コード例 #3
0
        public void GivenAController_WhenExecutingAction_ThenAuditLogShouldBeLogged()
        {
            var actionExecutingContext = new ActionExecutingContext(
                new ActionContext(_httpContext, new RouteData(), new ControllerActionDescriptor()
            {
                DisplayName = "Executing Context Test Descriptor"
            }),
                new List <IFilterMetadata>(),
                new Dictionary <string, object>(),
                FilterTestsHelper.CreateMockFhirController());

            _filter.OnActionExecuting(actionExecutingContext);

            _auditHelper.Received(1).LogExecuting(_httpContext, _claimsExtractor);
        }