diff options
| author | Brian J. Murrell <brian@interlinx.bc.ca> | 2021-11-29 17:53:26 -0500 |
|---|---|---|
| committer | Brian J. Murrell <brian@interlinx.bc.ca> | 2021-11-29 17:53:26 -0500 |
| commit | 757970bfc17b0eb1566b45fbe700dcb16423b190 (patch) | |
| tree | 63fbc171621f5ec7ae156f341d9b1df37643deac /tests/Jellyfin.Server.Integration.Tests/EncodedQueryStringTest.cs | |
| parent | a3a4689af22693b535e80b98624831866fda2a61 (diff) | |
| parent | c677b4f6b7f7e874097aa2cee866d9ed1e574178 (diff) | |
Merge remote-tracking branch 'origin/master' into HEAD
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests/EncodedQueryStringTest.cs')
| -rw-r--r-- | tests/Jellyfin.Server.Integration.Tests/EncodedQueryStringTest.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Integration.Tests/EncodedQueryStringTest.cs b/tests/Jellyfin.Server.Integration.Tests/EncodedQueryStringTest.cs new file mode 100644 index 000000000..2361e4aa4 --- /dev/null +++ b/tests/Jellyfin.Server.Integration.Tests/EncodedQueryStringTest.cs @@ -0,0 +1,49 @@ +using System.Net; +using System.Threading.Tasks; +using Xunit; + +namespace Jellyfin.Server.Integration.Tests +{ + /// <summary> + /// Defines the test for encoded querystrings in the url. + /// </summary> + public class EncodedQueryStringTest : IClassFixture<JellyfinApplicationFactory> + { + private readonly JellyfinApplicationFactory _factory; + + public EncodedQueryStringTest(JellyfinApplicationFactory factory) + { + _factory = factory; + } + + [Theory] + [InlineData("a=1&b=2&c=3", "a=1&b=2&c=3")] // won't be processed as there is more than 1. + [InlineData("a=1", "a=1")] // won't be processed as it has a value + [InlineData("a%3D1%26b%3D2%26c%3D3", "a=1&b=2&c=3")] // will be processed. + [InlineData("a=b&a=c", "a=b")] + [InlineData("a%3D1", "a=1")] + [InlineData("a%3Db%26a%3Dc", "a=b")] + public async Task Ensure_Decoding_Of_Urls_Is_Working(string sourceUrl, string unencodedUrl) + { + var client = _factory.CreateClient(); + + var response = await client.GetAsync("Encoder/UrlDecode?" + sourceUrl).ConfigureAwait(false); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + string reply = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + Assert.Equal(unencodedUrl, reply); + } + + [Theory] + [InlineData("a=b&a=c", "a=b,c")] + [InlineData("a%3Db%26a%3Dc", "a=b,c")] + public async Task Ensure_Array_Decoding_Of_Urls_Is_Working(string sourceUrl, string unencodedUrl) + { + var client = _factory.CreateClient(); + + var response = await client.GetAsync("Encoder/UrlArrayDecode?" + sourceUrl).ConfigureAwait(false); + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + string reply = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + Assert.Equal(unencodedUrl, reply); + } + } +} |
