forked from ddrilling/AsbCloudServer
Add Mock controller
This commit is contained in:
parent
4e58841619
commit
fd5deaa5a2
@ -5,16 +5,19 @@ using System.Linq;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Имитирует разные типы ответа сервера
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class MockController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// получить статистику
|
||||
/// имитирует http-400
|
||||
/// </summary>
|
||||
[HttpGet("400")]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), (int)System.Net.HttpStatusCode.BadRequest)]
|
||||
public IActionResult Get([FromQuery, Required]IDictionary<string, string> args)
|
||||
public IActionResult Get400([FromQuery, Required]IDictionary<string, string> args)
|
||||
{
|
||||
var errors = new Dictionary<string, string[]>();
|
||||
|
||||
@ -38,5 +41,32 @@ namespace AsbCloudWebApi.Controllers
|
||||
return BadRequest(problem);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// имитирует http-403
|
||||
/// </summary>
|
||||
[HttpGet("403")]
|
||||
public IActionResult Get403()
|
||||
{
|
||||
return Forbid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// имитирует http-401
|
||||
/// </summary>
|
||||
[HttpGet("401")]
|
||||
public IActionResult Get401()
|
||||
{
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// имитирует http-500
|
||||
/// </summary>
|
||||
[HttpGet("500")]
|
||||
public IActionResult Get500()
|
||||
{
|
||||
throw new System.Exception("Это тестовое исключение");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user