RobotsRedirectionMiddlewareTests.cs 969 B

1234567891011121314151617181920212223242526272829303132
  1. using System.Net;
  2. using System.Threading.Tasks;
  3. using Microsoft.AspNetCore.Mvc.Testing;
  4. using Xunit;
  5. namespace Jellyfin.Server.Integration.Tests.Middleware
  6. {
  7. public sealed class RobotsRedirectionMiddlewareTests : IClassFixture<JellyfinApplicationFactory>
  8. {
  9. private readonly JellyfinApplicationFactory _factory;
  10. public RobotsRedirectionMiddlewareTests(JellyfinApplicationFactory factory)
  11. {
  12. _factory = factory;
  13. }
  14. [Fact]
  15. public async Task RobotsDotTxtRedirects()
  16. {
  17. var client = _factory.CreateClient(
  18. new WebApplicationFactoryClientOptions()
  19. {
  20. AllowAutoRedirect = false
  21. });
  22. var response = await client.GetAsync("robots.txt");
  23. Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
  24. Assert.Equal("web/robots.txt", response.Headers.Location?.ToString());
  25. }
  26. }
  27. }