[DataRow(null, null, null, null)] // 全てのプロパティがNullの場合 public void IsBadRequestParameterInvalidParamInnerList(int?arg1, int?arg2, string arg3, string arg4) { InnerListClass param = new InnerListClass() { InnerClasses = new List <FlatPropertiesClass>() { new FlatPropertiesClass() { ReqParam = 100, NotReqParam = 200, Max10LenReqParam = "123", Max10Min3LenParam = "500" }, new FlatPropertiesClass() { ReqParam = arg1, NotReqParam = arg2, Max10LenReqParam = arg3, Max10Min3LenParam = arg4 }, } }; bool result = RequestValidator.IsBadRequestParameter(param, out string message); // BadRequestあり Assert.IsTrue(result); // messageには何か入っていること Assert.IsNotNull(message); }
public void IsBadRequestParameterNullParamTest() { FlatPropertiesClass param = null; bool result = RequestValidator.IsBadRequestParameter(param, out string message); Assert.IsTrue(result); // messageには何か入っていること Assert.IsNotNull(message); }
[DataRow("!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", false)] // 半角英数字記号すべて public void AsciiRegularExpressionTest(string paramater, bool expectedAssert) { ASCII param = new ASCII() { RequiredAscii = paramater }; bool isBadReq = RequestValidator.IsBadRequestParameter(param, out string message); // BadRequestあり Assert.AreEqual(expectedAssert, isBadReq); // messageには何か入っていること Assert.IsNotNull(message); }
public void IsBadRequestParameterNullParamTestNestedClass() { NestedClassWithRequired param = new NestedClassWithRequired { Inner = null, DoNotAllNull = "doNotAllNull" }; bool result = RequestValidator.IsBadRequestParameter(param, out string message); Assert.IsFalse(result); // messageには何か入っていること Assert.IsNotNull(message); }
public IActionResult PutDevice( [RequestBodyType(typeof(DeviceUpdateRequestDto), "デバイス更新リクエスト")] [HttpTrigger(AuthorizationLevel.Function, "put", Route = "devices/{deviceId}")] DeviceUpdateRequestDto request, long deviceId, ILogger log) { log.EnterJson("DeviceUpdateRequestDto: {0}", request); ActionResult response = null; try { // リクエストパラメータチェック string message = string.Empty; if (RequestValidator.IsBadRequestParameter(request, out message)) { log.Error(nameof(Resources.CO_API_DVU_002), new object[] { message }); return(new BadRequestObjectResult(string.Empty)); } // DTOを設置設定インスタンスに変換する var baseConfig = request.ConvertDtoToInstallBaseConfig(); // DTOをUtility型に変換する(SIDも含める) var utilParam = request.ConvertDtoToUtility(); utilParam.Sid = deviceId; // 更新実行 var resultParam = _deviceService.Update(utilParam, baseConfig); // Resultから返却ステータスを作成 return(SqlResultConverter.ConvertToActionResult( resultParam.ResultCode, resultParam.Message, resultParam.Entity.ConvertUtilityToResponseDto())); } catch (Exception e) { log.Error(e, nameof(Resources.CO_API_DVU_001)); response = new StatusCodeResult(StatusCodes.Status500InternalServerError); } finally { log.Leave($"Response Status: {response}"); } return(response); }
[DataRow(null, null, null, null)] // 全てのプロパティがNullの場合 public void IsBadRequestParameterInvalidParam(int?arg1, int?arg2, string arg3, string arg4) { FlatPropertiesClass param = new FlatPropertiesClass() { ReqParam = arg1, NotReqParam = arg2, Max10LenReqParam = arg3, Max10Min3LenParam = arg4 }; bool result = RequestValidator.IsBadRequestParameter(param, out string message); // BadRequestあり Assert.IsTrue(result); // messageには何か入っていること Assert.IsNotNull(message); }
public void IsBadRequestParameterValidParamNestedClass(int?arg1, int?arg2, string arg3, string arg4) { NestedClass param = new NestedClass() { Inner = new FlatPropertiesClass() { ReqParam = arg1, NotReqParam = arg2, Max10LenReqParam = arg3, Max10Min3LenParam = arg4 } }; bool result = RequestValidator.IsBadRequestParameter(param, out string message); // BadRequestなし Assert.IsFalse(result); // messageには何か入っていること Assert.IsNotNull(message); }
public IActionResult PutDeliveryFile( [RequestBodyType(typeof(DeliveryFileUpdateRequestDto), "配信ファイル更新リクエスト")] [HttpTrigger(AuthorizationLevel.Function, "put", Route = "deliveryfiles/{deliveryFileId}")] DeliveryFileUpdateRequestDto request, long deliveryFileId, ILogger log) { log.EnterJson($"{nameof(deliveryFileId)}: {deliveryFileId}, {typeof(DeliveryFileUpdateRequestDto)}: {{0}}", request); ActionResult response = null; try { DeliveryFileUpdateRequestDto requestByType = RequestConverter.Convert(request); // リクエストオブジェクトがnullの場合にはnullが返る // リクエストパラメータチェック if (RequestValidator.IsBadRequestParameter(request, out string message)) { log.Error(nameof(Resources.CO_API_DFU_002), new object[] { message }); return(new BadRequestObjectResult(string.Empty)); } var utilParam = requestByType.ConvertDtoToUtility(deliveryFileId); var resultParam = _service.Update(utilParam); // Resultから返却ステータスを作成 response = SqlResultConverter.ConvertToActionResult( resultParam.ResultCode, resultParam.Message, resultParam.Entity.ConvertUtilityToResponseDto()); } catch (Exception e) { log.Error(e, nameof(Resources.CO_API_DFU_001)); response = new StatusCodeResult(StatusCodes.Status500InternalServerError); } finally { log.LeaveJson("Response: {0}", response); } return(response); }
public IActionResult PostDeliveryGroup( [RequestBodyType(typeof(DeliveryGroupAddRequestDto), "配信グループ作成リクエスト")] [HttpTrigger(AuthorizationLevel.Function, "post", Route = "deliverygroups")] DeliveryGroupAddRequestDto request, ILogger log) { log.EnterJson("DeliveryGroupAddRequestDto: {0}", request); ActionResult response = null; try { // リクエストパラメータチェック if (RequestValidator.IsBadRequestParameter(request, out string message)) { log.Error(nameof(Resources.CO_API_DGC_002), new object[] { message }); return(new BadRequestObjectResult(string.Empty)); } var utilParam = request.ConvertDtoToUtility(); var resultParam = _service.Create(utilParam); // Resultから返却ステータスを作成 response = SqlResultConverter.ConvertToActionResult( resultParam.ResultCode, resultParam.Message, resultParam.Entity.ConvertUtilityToResponseDto()); } catch (Exception e) { log.Error(e, nameof(Resources.CO_API_DGC_001)); response = new StatusCodeResult(StatusCodes.Status500InternalServerError); } finally { log.LeaveJson("Response: {0}", response); } return(response); }
public IActionResult PutDeliveryFileStatus( [RequestBodyType(typeof(DeliveryFileStatusUpdateRequestDto), "配信ファイル更新リクエスト")] [HttpTrigger(AuthorizationLevel.Function, "put", Route = "deliveryfiles/{deliveryFileId}/status")] DeliveryFileStatusUpdateRequestDto request, long deliveryFileId, ILogger log) { log.EnterJson("Request: {0}", request.ToStringProperties()); ActionResult response = null; try { // リクエストパラメータチェック string message = string.Empty; if (RequestValidator.IsBadRequestParameter(request, out message)) { log.Error(nameof(Resources.CO_API_DSU_002), new object[] { message }); return(new BadRequestObjectResult(string.Empty)); } var utilParam = request.ConvertDtoToUtility(deliveryFileId); var resultParam = _service.PutCancelFlag(utilParam); // Resultから返却ステータスを作成(レスポンスボディは空) response = SqlResultConverter.ConvertToActionResult(resultParam.ResultCode, resultParam.Message); } catch (Exception e) { log.Error(e, nameof(Resources.CO_API_DSU_001)); response = new StatusCodeResult(StatusCodes.Status500InternalServerError); } finally { log.LeaveJson("Response: {0}", response); } return(response); }
public async Task <IActionResult> PostDeviceRemoteAsync( [RequestBodyType(typeof(DeviceRemoteRequestDto), "リモート接続開始リクエスト")] [HttpTrigger(AuthorizationLevel.Function, "post", Route = "devices/{deviceId}/remote")] DeviceRemoteRequestDto request, long deviceId, ILogger log) { log.Enter($"{nameof(request)}: {{0}}, {nameof(deviceId)}: {{1}}", new object[] { request, deviceId }); ActionResult response = null; try { // リクエストパラメータチェック if (RequestValidator.IsBadRequestParameter(request, out var message)) { log.Error(nameof(Resources.CO_API_DRC_002), new object[] { message }); return(new BadRequestObjectResult(string.Empty)); } var requestRemote = request.ConvertDtoToUtility(deviceId); var resultParam = await _deviceService.RequestRemoteAsync(requestRemote); // Resultから返却ステータスを作成(レスポンスボディは空) response = SqlResultConverter.ConvertToActionResult(resultParam.ResultCode, resultParam.Message); } catch (Exception e) { log.Error(e, nameof(Resources.CO_API_DRC_001)); response = new StatusCodeResult(StatusCodes.Status500InternalServerError); } finally { log.Leave($"Response Status: {response}"); } return(response); }
public void IsBadRequestParameterInvalidParamInnerEmptyList(string testTarget, bool expected, RequiredInnerListClass target) { bool result = RequestValidator.IsBadRequestParameter(target, out string message); Assert.AreEqual(expected, result, testTarget); }
public void IsBadRequestParameterIsNullAllInstancePropertyTest(string testTarget, bool expected, object target) { bool result = RequestValidator.IsBadRequestParameter(target, out string message); Assert.AreEqual(expected, result, testTarget); }