aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Server.Integration.Tests/Middleware/RobotsRedirectionMiddlewareTests.cs
blob: 1ea79f7deb3c6fea02f8717d26ba55fc6a4dfa60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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");

            Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
            Assert.Equal("web/robots.txt", response.Headers.Location?.ToString());
        }
    }
}