2021-03-02 01:57:36 +00:00
|
|
|
using System.Net;
|
2021-02-22 15:27:02 +00:00
|
|
|
using System.Net.Mime;
|
|
|
|
using System.Text;
|
2020-04-20 19:47:36 +00:00
|
|
|
using System.Text.Json;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using MediaBrowser.Model.Branding;
|
|
|
|
using Xunit;
|
|
|
|
|
2021-03-01 18:35:58 +00:00
|
|
|
namespace Jellyfin.Server.Integration.Tests
|
2020-04-20 19:47:36 +00:00
|
|
|
{
|
2021-02-22 12:15:29 +00:00
|
|
|
public sealed class BrandingControllerTests : IClassFixture<JellyfinApplicationFactory>
|
2020-04-20 19:47:36 +00:00
|
|
|
{
|
|
|
|
private readonly JellyfinApplicationFactory _factory;
|
|
|
|
|
2021-02-22 12:15:29 +00:00
|
|
|
public BrandingControllerTests(JellyfinApplicationFactory factory)
|
2020-04-20 19:47:36 +00:00
|
|
|
{
|
|
|
|
_factory = factory;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public async Task GetConfiguration_ReturnsCorrectResponse()
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
var client = _factory.CreateClient();
|
|
|
|
|
|
|
|
// Act
|
|
|
|
var response = await client.GetAsync("/Branding/Configuration");
|
|
|
|
|
|
|
|
// Assert
|
2021-03-02 01:57:36 +00:00
|
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
2021-02-22 15:27:02 +00:00
|
|
|
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
|
|
|
Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
|
2020-04-20 19:47:36 +00:00
|
|
|
var responseBody = await response.Content.ReadAsStreamAsync();
|
|
|
|
_ = await JsonSerializer.DeserializeAsync<BrandingOptions>(responseBody);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
[InlineData("/Branding/Css")]
|
|
|
|
[InlineData("/Branding/Css.css")]
|
|
|
|
public async Task GetCss_ReturnsCorrectResponse(string url)
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
var client = _factory.CreateClient();
|
|
|
|
|
|
|
|
// Act
|
|
|
|
var response = await client.GetAsync(url);
|
|
|
|
|
|
|
|
// Assert
|
2021-02-22 12:15:29 +00:00
|
|
|
Assert.True(response.IsSuccessStatusCode);
|
2021-02-22 15:27:02 +00:00
|
|
|
Assert.Equal("text/css", response.Content.Headers.ContentType?.MediaType);
|
|
|
|
Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
|
2020-04-20 19:47:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|