EncodedQueryStringTest.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. using System.Net;
  2. using System.Threading.Tasks;
  3. using Xunit;
  4. namespace Jellyfin.Server.Integration.Tests
  5. {
  6. /// <summary>
  7. /// Defines the test for encoded querystrings in the url.
  8. /// </summary>
  9. public class EncodedQueryStringTest : IClassFixture<JellyfinApplicationFactory>
  10. {
  11. private readonly JellyfinApplicationFactory _factory;
  12. public EncodedQueryStringTest(JellyfinApplicationFactory factory)
  13. {
  14. _factory = factory;
  15. }
  16. [Theory]
  17. [InlineData("a=1&b=2&c=3", "a=1&b=2&c=3")] // won't be processed as there is more than 1.
  18. [InlineData("a=1", "a=1")] // won't be processed as it has a value
  19. [InlineData("a%3D1%26b%3D2%26c%3D3", "a=1&b=2&c=3")] // will be processed.
  20. public async Task Ensure_Decoding_Of_Urls_Is_Working(string sourceUrl, string unencodedUrl)
  21. {
  22. var client = _factory.CreateClient();
  23. var response = await client.GetAsync("Tests/UrlDecode?" + sourceUrl).ConfigureAwait(false);
  24. Assert.Equal(HttpStatusCode.OK, response.StatusCode);
  25. string reply = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
  26. Assert.Equal(unencodedUrl, reply);
  27. }
  28. }
  29. }