The Free Software Media System - Server Backend & API
Add test for RobotsRedirectionMiddleware
Bond_009e19dce3c536d
diff --git a/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs b/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.csindex d9ec81a271..976e19d468 100644--- a/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs+++ b/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs@@ -44,10 +44,7 @@ namespace Jellyfin.Server.Integration.Testsprotected override void ConfigureWebHost(IWebHostBuilder builder){// Specify the startup command line options- var commandLineOpts = new StartupOptions- {- NoWebClient = true- };+ var commandLineOpts = new StartupOptions();// Use a temporary directory for the application pathsvar webHostPathRoot = Path.Combine(_testPathRoot, "test-host-" + Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));diff --git a/tests/Jellyfin.Server.Integration.Tests/Middleware/RobotsRedirectionMiddlewareTests.cs b/tests/Jellyfin.Server.Integration.Tests/Middleware/RobotsRedirectionMiddlewareTests.csnew file mode 100644index 0000000000..8c49a2e2b5--- /dev/null+++ b/tests/Jellyfin.Server.Integration.Tests/Middleware/RobotsRedirectionMiddlewareTests.cs@@ -0,0 +1,32 @@+using System.Net;+using System.Threading.Tasks;+using Microsoft.AspNetCore.Mvc.Testing;+using Xunit;++namespace Jellyfin.Server.Integration.Tests.Middleware+{+ public sealed class RobotsRedirectionMiddlewareTests : IClassFixture<JellyfinApplicationFactory>+ {+ private readonly JellyfinApplicationFactory _factory;++ public RobotsRedirectionMiddlewareTests(JellyfinApplicationFactory factory)+ {+ _factory = factory;+ }++ [Fact]+ public async Task RobotsDotTxtRedirects()+ {+ var client = _factory.CreateClient(+ new WebApplicationFactoryClientOptions()+ {+ AllowAutoRedirect = false+ });++ var response = await client.GetAsync("robots.txt").ConfigureAwait(false);++ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);+ Assert.Equal("web/robots.txt", response.Headers.Location?.ToString());+ }+ }+}