mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-04 06:48:35 +01:00
Merge branch 'master' into network-rewrite
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoMoq;
|
||||
using Jellyfin.Api.Auth.DefaultAuthorizationPolicy;
|
||||
using Jellyfin.Api.Constants;
|
||||
using Jellyfin.Data.Entities;
|
||||
using Jellyfin.Server.Implementations.Security;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -51,6 +55,32 @@ namespace Jellyfin.Api.Tests.Auth.DefaultAuthorizationPolicy
|
||||
Assert.True(context.HasSucceeded);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShouldSucceedOnApiKey()
|
||||
{
|
||||
TestHelpers.SetupConfigurationManager(_configurationManagerMock, true);
|
||||
|
||||
_httpContextAccessor
|
||||
.Setup(h => h.HttpContext!.Connection.RemoteIpAddress)
|
||||
.Returns(new IPAddress(0));
|
||||
|
||||
_userManagerMock
|
||||
.Setup(u => u.GetUserById(It.IsAny<Guid>()))
|
||||
.Returns<User>(null);
|
||||
|
||||
var claims = new[]
|
||||
{
|
||||
new Claim(InternalClaimTypes.IsApiKey, bool.TrueString)
|
||||
};
|
||||
|
||||
var identity = new ClaimsIdentity(claims, string.Empty);
|
||||
var principal = new ClaimsPrincipal(identity);
|
||||
var context = new AuthorizationHandlerContext(_requirements, principal, null);
|
||||
|
||||
await _sut.HandleAsync(context);
|
||||
Assert.True(context.HasSucceeded);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetParts_ValidAuthHeader_Success_Data))]
|
||||
public void GetParts_ValidAuthHeader_Success(string input, Dictionary<string, string> parts)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using Emby.Dlna.Server;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Dlna.Server.Tests;
|
||||
|
||||
public class DescriptionXmlBuilderTests
|
||||
{
|
||||
[Fact]
|
||||
public void GetFriendlyName_EmptyProfile_ReturnsServerName()
|
||||
{
|
||||
const string ServerName = "Test Server Name";
|
||||
var builder = new DescriptionXmlBuilder(new DeviceProfile(), "serverUdn", "localhost", ServerName, string.Empty);
|
||||
Assert.Equal(ServerName, builder.GetFriendlyName());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFriendlyName_FriendlyName_ReturnsFriendlyName()
|
||||
{
|
||||
const string FriendlyName = "Friendly Neighborhood Test Server";
|
||||
var builder = new DescriptionXmlBuilder(
|
||||
new DeviceProfile()
|
||||
{
|
||||
FriendlyName = FriendlyName
|
||||
},
|
||||
"serverUdn",
|
||||
"localhost",
|
||||
"Test Server Name",
|
||||
string.Empty);
|
||||
Assert.Equal(FriendlyName, builder.GetFriendlyName());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFriendlyName_FriendlyNameInterpolation_ReturnsFriendlyName()
|
||||
{
|
||||
var builder = new DescriptionXmlBuilder(
|
||||
new DeviceProfile()
|
||||
{
|
||||
FriendlyName = "Friendly Neighborhood ${HostName}"
|
||||
},
|
||||
"serverUdn",
|
||||
"localhost",
|
||||
"Test Server Name",
|
||||
string.Empty);
|
||||
Assert.Equal("Friendly Neighborhood TestServerName", builder.GetFriendlyName());
|
||||
}
|
||||
}
|
||||
@@ -188,8 +188,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Iron Man/Iron Man-bluray.mkv",
|
||||
@"/movies/Iron Man/Iron Man-3d.mkv",
|
||||
@"/movies/Iron Man/Iron Man-3d-hsbs.mkv",
|
||||
@"/movies/Iron Man/Iron Man-3d.hsbs.mkv",
|
||||
@"/movies/Iron Man/Iron Man[test].mkv",
|
||||
@"/movies/Iron Man/Iron Man[test].mkv"
|
||||
};
|
||||
|
||||
var result = VideoListResolver.Resolve(
|
||||
@@ -197,10 +196,14 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Equal(7, result[0].AlternateVersions.Count);
|
||||
Assert.False(result[0].AlternateVersions[2].Is3D);
|
||||
Assert.True(result[0].AlternateVersions[3].Is3D);
|
||||
Assert.True(result[0].AlternateVersions[4].Is3D);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man.mkv", result[0].Files[0].Path);
|
||||
Assert.Equal(6, result[0].AlternateVersions.Count);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man-720p.mkv", result[0].AlternateVersions[0].Path);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man-3d.mkv", result[0].AlternateVersions[1].Path);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man-3d-hsbs.mkv", result[0].AlternateVersions[2].Path);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man-bluray.mkv", result[0].AlternateVersions[3].Path);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man-test.mkv", result[0].AlternateVersions[4].Path);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man[test].mkv", result[0].AlternateVersions[5].Path);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -214,7 +217,6 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Iron Man/Iron Man - bluray.mkv",
|
||||
@"/movies/Iron Man/Iron Man - 3d.mkv",
|
||||
@"/movies/Iron Man/Iron Man - 3d-hsbs.mkv",
|
||||
@"/movies/Iron Man/Iron Man - 3d.hsbs.mkv",
|
||||
@"/movies/Iron Man/Iron Man [test].mkv"
|
||||
};
|
||||
|
||||
@@ -223,10 +225,14 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Equal(7, result[0].AlternateVersions.Count);
|
||||
Assert.False(result[0].AlternateVersions[3].Is3D);
|
||||
Assert.True(result[0].AlternateVersions[4].Is3D);
|
||||
Assert.True(result[0].AlternateVersions[5].Is3D);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man.mkv", result[0].Files[0].Path);
|
||||
Assert.Equal(6, result[0].AlternateVersions.Count);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man - 720p.mkv", result[0].AlternateVersions[0].Path);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man - 3d.mkv", result[0].AlternateVersions[1].Path);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man - 3d-hsbs.mkv", result[0].AlternateVersions[2].Path);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man - bluray.mkv", result[0].AlternateVersions[3].Path);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man - test.mkv", result[0].AlternateVersions[4].Path);
|
||||
Assert.Equal("/movies/Iron Man/Iron Man [test].mkv", result[0].AlternateVersions[5].Path);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -328,8 +334,12 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
var files = new[]
|
||||
{
|
||||
@"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - Theatrical Release.mkv",
|
||||
@"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - Directors Cut.mkv",
|
||||
@"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 1080p.mkv",
|
||||
@"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016).mkv"
|
||||
@"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 2160p.mkv",
|
||||
@"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 720p.mkv",
|
||||
@"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016).mkv",
|
||||
};
|
||||
|
||||
var result = VideoListResolver.Resolve(
|
||||
@@ -338,8 +348,12 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Equal("/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016).mkv", result[0].Files[0].Path);
|
||||
Assert.Single(result[0].AlternateVersions);
|
||||
Assert.Equal("/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 1080p.mkv", result[0].AlternateVersions[0].Path);
|
||||
Assert.Equal(5, result[0].AlternateVersions.Count);
|
||||
Assert.Equal("/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 2160p.mkv", result[0].AlternateVersions[0].Path);
|
||||
Assert.Equal("/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 1080p.mkv", result[0].AlternateVersions[1].Path);
|
||||
Assert.Equal("/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 720p.mkv", result[0].AlternateVersions[2].Path);
|
||||
Assert.Equal("/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - Directors Cut.mkv", result[0].AlternateVersions[3].Path);
|
||||
Assert.Equal("/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - Theatrical Release.mkv", result[0].AlternateVersions[4].Path);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -83,11 +83,11 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
|
||||
await localizationManager.LoadAll();
|
||||
var ratings = localizationManager.GetParentalRatings().ToList();
|
||||
|
||||
Assert.Equal(23, ratings.Count);
|
||||
Assert.Equal(53, ratings.Count);
|
||||
|
||||
var tvma = ratings.FirstOrDefault(x => x.Name.Equals("TV-MA", StringComparison.Ordinal));
|
||||
Assert.NotNull(tvma);
|
||||
Assert.Equal(9, tvma!.Value);
|
||||
Assert.Equal(17, tvma!.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -100,21 +100,21 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
|
||||
await localizationManager.LoadAll();
|
||||
var ratings = localizationManager.GetParentalRatings().ToList();
|
||||
|
||||
Assert.Equal(10, ratings.Count);
|
||||
Assert.Equal(18, ratings.Count);
|
||||
|
||||
var fsk = ratings.FirstOrDefault(x => x.Name.Equals("FSK-12", StringComparison.Ordinal));
|
||||
Assert.NotNull(fsk);
|
||||
Assert.Equal(7, fsk!.Value);
|
||||
Assert.Equal(12, fsk!.Value);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("CA-R", "CA", 10)]
|
||||
[InlineData("FSK-16", "DE", 8)]
|
||||
[InlineData("FSK-18", "DE", 9)]
|
||||
[InlineData("FSK-18", "US", 9)]
|
||||
[InlineData("TV-MA", "US", 9)]
|
||||
[InlineData("XXX", "asdf", 100)]
|
||||
[InlineData("Germany: FSK-18", "DE", 9)]
|
||||
[InlineData("CA-R", "CA", 18)]
|
||||
[InlineData("FSK-16", "DE", 16)]
|
||||
[InlineData("FSK-18", "DE", 18)]
|
||||
[InlineData("FSK-18", "US", 18)]
|
||||
[InlineData("TV-MA", "US", 17)]
|
||||
[InlineData("XXX", "asdf", 1000)]
|
||||
[InlineData("Germany: FSK-18", "DE", 18)]
|
||||
public async Task GetRatingLevel_GivenValidString_Success(string value, string countryCode, int expectedLevel)
|
||||
{
|
||||
var localizationManager = Setup(new ServerConfiguration()
|
||||
@@ -135,6 +135,9 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
|
||||
UICulture = "de-DE"
|
||||
});
|
||||
await localizationManager.LoadAll();
|
||||
Assert.Null(localizationManager.GetRatingLevel("NR"));
|
||||
Assert.Null(localizationManager.GetRatingLevel("unrated"));
|
||||
Assert.Null(localizationManager.GetRatingLevel("Not Rated"));
|
||||
Assert.Null(localizationManager.GetRatingLevel("n/a"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user