public async Task it_should_do_nothing_if_no_origin_provided_in_request() { var response = this.CreateResponse(); await _postRequestHandler.Process(response); response.Headers.AccessControlAllowOrigin.Should().BeNullOrEmpty(); }
/// <inheritdoc /> public async Task <ResponseInfo> HandleRequestAsync(RequestInfo request) { ResponseInfo response; try { var requestMapping = _handlerMapper.MapRequest(request); if (requestMapping == null) { throw new NoMatchingRouteFoundException(String.Format("No API resource handles requested url '{0}'.", request.Url)); } await ProcessAuthenticationProviders(request); ValidateSecurityRequirements(requestMapping.Operation, request.Identity); response = new StringResponseInfo(null, request); requestMapping.Target.Response = response; var arguments = _argumentBinder.BindArguments(request, requestMapping); ValidateArguments(requestMapping.Operation.UnderlyingMethod.GetParameters(), arguments); await ProcessPreRequestHandlers(request); object output = await ProcessResult(requestMapping.Invoke(arguments)); output = await ProcessModelTransformers(requestMapping, request, output, arguments); response = _responseComposer.ComposeResponse(requestMapping, output, arguments); await ProcessPostRequestHandlers(response); return(response); } catch (UnauthenticatedAccessException exception) { if (_defaultAuthenticationScheme == null) { throw new InvalidOperationException("Cannot perform authentication without default authentication scheme set for challenge."); } response = new ExceptionResponseInfo(request, exception); } catch (Exception exception) { response = new ExceptionResponseInfo(request, exception); } await ProcessPostRequestHandlers(response); if (((ExceptionResponseInfo)response).Value is UnauthenticatedAccessException) { await _defaultAuthenticationScheme.Process(response); } return(response); }