aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Server.Integration.Tests/Controllers/EncoderController.cs
blob: 1a720c2f62bbf8ccc182d75e6a518e7cd1c022ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Jellyfin.Server.Integration.Tests.Controllers
{
    /// <summary>
    /// Controller for testing the encoded url.
    /// </summary>
    public class EncoderController : BaseJellyfinTestController
    {
        /// <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")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        public ContentResult TestUrlDecoding([FromQuery] Dictionary<string, string>? @params = null)
        {
            return new ContentResult()
            {
                Content = (@params != null && @params.Count > 0)
                    ? string.Join("&", @params.Select(x => x.Key + "=" + x.Value))
                    : string.Empty,
                ContentType = "text/plain; charset=utf-8",
                StatusCode = 200
            };
        }

        /// <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()
            {
                Content = (@params != 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
            };
        }
    }
}