jellyfin-server/tests/Jellyfin.Server.Integration.Tests/Controllers/EncoderController.cs

54 lines
2.0 KiB
C#
Raw Normal View History

2021-05-15 19:24:41 +00:00
using System.Collections.Generic;
2021-05-07 13:37:26 +00:00
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
2021-06-13 12:30:28 +00:00
namespace Jellyfin.Server.Integration.Tests.Controllers
2021-05-07 13:37:26 +00:00
{
/// <summary>
2021-05-15 19:24:41 +00:00
/// Controller for testing the encoded url.
2021-05-07 13:37:26 +00:00
/// </summary>
2021-06-13 12:30:28 +00:00
public class EncoderController : BaseJellyfinTestController
2021-05-07 13:37:26 +00:00
{
/// <summary>
/// Tests the url decoding.
/// </summary>
/// <param name="params">Parameters to echo back in the response.</param>
/// <returns>An <see cref="OkResult"/>.</returns>
/// <response code="200">Information retrieved.</response>
[HttpGet("UrlDecode")]
2021-05-07 13:37:26 +00:00
[ProducesResponseType(StatusCodes.Status200OK)]
public ContentResult TestUrlDecoding([FromQuery] Dictionary<string, string>? @params = null)
2021-05-07 13:37:26 +00:00
{
2021-05-07 19:11:32 +00:00
return new ContentResult()
2021-05-07 13:37:26 +00:00
{
2022-12-05 14:01:13 +00:00
Content = (@params is not null && @params.Count > 0)
2021-05-07 19:11:32 +00:00
? string.Join("&", @params.Select(x => x.Key + "=" + x.Value))
: string.Empty,
ContentType = "text/plain; charset=utf-8",
StatusCode = 200
};
2021-05-07 13:37:26 +00:00
}
/// <summary>
/// Tests the url decoding.
/// </summary>
/// <param name="params">Parameters to echo back in the response.</param>
/// <returns>An <see cref="OkResult"/>.</returns>
/// <response code="200">Information retrieved.</response>
[HttpGet("UrlArrayDecode")]
[ProducesResponseType(StatusCodes.Status200OK)]
public ContentResult TestUrlArrayDecoding([FromQuery] Dictionary<string, string[]>? @params = null)
{
return new ContentResult()
{
2022-12-05 14:01:13 +00:00
Content = (@params is not null && @params.Count > 0)
? string.Join("&", @params.Select(x => x.Key + "=" + string.Join(',', x.Value)))
: string.Empty,
ContentType = "text/plain; charset=utf-8",
StatusCode = 200
};
}
2021-05-07 13:37:26 +00:00
}
}