Add test for RobotsRedirectionMiddleware

This commit is contained in:
Bond_009
2021-07-06 01:07:10 +02:00
parent a9aeb6570b
commit e19dce3c53
2 changed files with 33 additions and 4 deletions

View File

@@ -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());
}
}
}