mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-23 22:21:04 +02:00
Merge pull request #6268 from Bond-009/redirecttest
Add test for RobotsRedirectionMiddleware
This commit is contained in:
commit
40c73e96a9
|
@ -44,10 +44,7 @@ namespace Jellyfin.Server.Integration.Tests
|
||||||
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
||||||
{
|
{
|
||||||
// Specify the startup command line options
|
// Specify the startup command line options
|
||||||
var commandLineOpts = new StartupOptions
|
var commandLineOpts = new StartupOptions();
|
||||||
{
|
|
||||||
NoWebClient = true
|
|
||||||
};
|
|
||||||
|
|
||||||
// Use a temporary directory for the application paths
|
// Use a temporary directory for the application paths
|
||||||
var webHostPathRoot = Path.Combine(_testPathRoot, "test-host-" + Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));
|
var webHostPathRoot = Path.Combine(_testPathRoot, "test-host-" + Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue