Exemple #1
0
        public static async Task <IActionResult> RunAsync(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req)
        {
            IActionResult _ActionResult = new BadRequestObjectResult(INVALID_REQUEST_MESSAGE);;

            ScanRequest _RequestModel = await GetModelFromRequestBodyAsync(req.Body);

            if (!string.IsNullOrEmpty(_RequestModel.Base64EncodedBytes))
            {
                _ActionResult = new UnprocessableEntityResult();

                ClamScanResult _Result = await new FileScanManager(new ClamClient(Environment.GetEnvironmentVariable("CLAM_AV_SERVER"))).Scan(_RequestModel.Base64EncodedBytes);

                if (_Result != null)
                {
                    ScanResponse _Respone = new ScanResponse()
                    {
                        Result = Enum.GetName(typeof(ClamScanResults), _Result.Result),
                        Threat = _Result.InfectedFiles?.First().VirusName ?? string.Empty
                    };

                    _ActionResult = new JsonResult(_Respone);
                }
            }

            return(_ActionResult);
        }
Exemple #2
0
        /// <summary>
        /// Creates an <see cref="HomeCloud.Api.Http.UnprocessableEntityResult" /> object that produces an Microsoft.AspNetCore.Http.StatusCodes.Status422UnprocessableEntity response.
        /// </summary>
        /// <param name="value">The <see cref="ErrorViewModel" /> value to format in the entity body.</param>
        /// <returns>
        /// The created <see cref="HomeCloud.Api.Http.UnprocessableEntityResult" /> for the response.
        /// </returns>
        public virtual UnprocessableEntityResult UnprocessableEntity(ErrorViewModel value)
        {
            UnprocessableEntityResult result = new UnprocessableEntityResult(value);

            value.StatusCode = result.StatusCode.GetValueOrDefault();

            return(result);
        }
    public void UnprocessableEntityResult_InitializesStatusCode()
    {
        // Arrange & act
        var result = new UnprocessableEntityResult();

        // Assert
        Assert.Equal(StatusCodes.Status422UnprocessableEntity, result.StatusCode);
    }
Exemple #4
0
        public void ImplicitOperatorTests()
        {
            // Arrange
            var result = new OperationResult <Value>();

            // Act
            OperationResult <Value> fromBadRequest          = new BadRequestResult();
            OperationResult <Value> fromConflict            = new ConflictResult();
            OperationResult <Value> fromNoContent           = new NoContentResult();
            OperationResult <Value> fromNotFound            = new NotFoundResult();
            OperationResult <Value> fromOk                  = new OkResult();
            OperationResult <Value> fromUnauthorized        = new UnauthorizedResult();
            OperationResult <Value> fromUnprocessableEntity = new UnprocessableEntityResult();
            OperationResult <Value> unsupportedMediaType    = new UnprocessableEntityResult();

            Assert.NotNull(fromBadRequest);
            Assert.NotNull(fromConflict);
            Assert.NotNull(fromNoContent);
            Assert.NotNull(fromNotFound);
            Assert.NotNull(fromOk);
            Assert.NotNull(fromUnauthorized);
            Assert.NotNull(fromUnprocessableEntity);
            Assert.NotNull(unsupportedMediaType);
        }
Exemple #5
0
 public TestUnprocessableEntityResult(UnprocessableEntityResult innerResult)
     : base(innerResult)
 {
 }