mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-27 19:08:27 +01:00
Merge branch 'master' into fix-resharper-warnings
# Conflicts: # Emby.Server.Implementations/Net/SocketFactory.cs # RSSDP/SsdpCommunicationsServer.cs # RSSDP/SsdpDeviceLocator.cs # RSSDP/SsdpDevicePublisher.cs
This commit is contained in:
@@ -30,4 +30,17 @@ public static class ImageFormatExtensionsTests
|
||||
[InlineData((ImageFormat)5)]
|
||||
public static void GetMimeType_Valid_ThrowsInvalidEnumArgumentException(ImageFormat format)
|
||||
=> Assert.Throws<InvalidEnumArgumentException>(() => format.GetMimeType());
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetAllImageFormats))]
|
||||
public static void GetExtension_Valid_Valid(ImageFormat format)
|
||||
=> Assert.Null(Record.Exception(() => format.GetExtension()));
|
||||
|
||||
[Theory]
|
||||
[InlineData((ImageFormat)int.MinValue)]
|
||||
[InlineData((ImageFormat)int.MaxValue)]
|
||||
[InlineData((ImageFormat)(-1))]
|
||||
[InlineData((ImageFormat)5)]
|
||||
public static void GetExtension_Valid_ThrowsInvalidEnumArgumentException(ImageFormat format)
|
||||
=> Assert.Throws<InvalidEnumArgumentException>(() => format.GetExtension());
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace Jellyfin.Networking.Tests
|
||||
[InlineData("127.0.0.1:123")]
|
||||
[InlineData("localhost")]
|
||||
[InlineData("localhost:1345")]
|
||||
[InlineData("www.google.co.uk")]
|
||||
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517")]
|
||||
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517/56")]
|
||||
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517]:124")]
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System.Net;
|
||||
using Jellyfin.Networking.Configuration;
|
||||
using Jellyfin.Networking.Manager;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Networking.Tests
|
||||
@@ -28,7 +30,8 @@ namespace Jellyfin.Networking.Tests
|
||||
LocalNetworkSubnets = network.Split(',')
|
||||
};
|
||||
|
||||
using var networkManager = new NetworkManager(NetworkParseTests.GetMockConfig(conf), new NullLogger<NetworkManager>());
|
||||
var startupConf = new Mock<IConfiguration>();
|
||||
using var networkManager = new NetworkManager(NetworkParseTests.GetMockConfig(conf), startupConf.Object, new NullLogger<NetworkManager>());
|
||||
|
||||
Assert.True(networkManager.IsInLocalNetwork(ip));
|
||||
}
|
||||
@@ -56,9 +59,10 @@ namespace Jellyfin.Networking.Tests
|
||||
LocalNetworkSubnets = network.Split(',')
|
||||
};
|
||||
|
||||
using var nm = new NetworkManager(NetworkParseTests.GetMockConfig(conf), new NullLogger<NetworkManager>());
|
||||
var startupConf = new Mock<IConfiguration>();
|
||||
using var networkManager = new NetworkManager(NetworkParseTests.GetMockConfig(conf), startupConf.Object, new NullLogger<NetworkManager>());
|
||||
|
||||
Assert.False(nm.IsInLocalNetwork(ip));
|
||||
Assert.False(networkManager.IsInLocalNetwork(ip));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using Jellyfin.Networking.Extensions;
|
||||
using Jellyfin.Networking.Manager;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Model.Net;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
@@ -54,7 +55,8 @@ namespace Jellyfin.Networking.Tests
|
||||
};
|
||||
|
||||
NetworkManager.MockNetworkSettings = interfaces;
|
||||
using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
|
||||
var startupConf = new Mock<IConfiguration>();
|
||||
using var nm = new NetworkManager(NetworkParseTests.GetMockConfig(conf), startupConf.Object, new NullLogger<NetworkManager>());
|
||||
NetworkManager.MockNetworkSettings = string.Empty;
|
||||
|
||||
Assert.Equal(value, "[" + string.Join(",", nm.GetInternalBindAddresses().Select(x => x.Address + "/" + x.Subnet.PrefixLength)) + "]");
|
||||
@@ -200,7 +202,8 @@ namespace Jellyfin.Networking.Tests
|
||||
};
|
||||
|
||||
NetworkManager.MockNetworkSettings = "192.168.1.208/24,-16,eth16|200.200.200.200/24,11,eth11";
|
||||
using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
|
||||
var startupConf = new Mock<IConfiguration>();
|
||||
using var nm = new NetworkManager(NetworkParseTests.GetMockConfig(conf), startupConf.Object, new NullLogger<NetworkManager>());
|
||||
NetworkManager.MockNetworkSettings = string.Empty;
|
||||
|
||||
// Check to see if DNS resolution is working. If not, skip test.
|
||||
@@ -229,24 +232,24 @@ namespace Jellyfin.Networking.Tests
|
||||
[InlineData("192.168.1.1", "192.168.1.0/24", "eth16,eth11", false, "192.168.1.0/24=internal.jellyfin", "internal.jellyfin")]
|
||||
|
||||
// User on external network, we're bound internal and external - so result is override.
|
||||
[InlineData("8.8.8.8", "192.168.1.0/24", "eth16,eth11", false, "0.0.0.0=http://helloworld.com", "http://helloworld.com")]
|
||||
[InlineData("8.8.8.8", "192.168.1.0/24", "eth16,eth11", false, "all=http://helloworld.com", "http://helloworld.com")]
|
||||
|
||||
// User on internal network, we're bound internal only, but the address isn't in the LAN - so return the override.
|
||||
[InlineData("10.10.10.10", "192.168.1.0/24", "eth16", false, "0.0.0.0=http://internalButNotDefinedAsLan.com", "http://internalButNotDefinedAsLan.com")]
|
||||
[InlineData("10.10.10.10", "192.168.1.0/24", "eth16", false, "external=http://internalButNotDefinedAsLan.com", "http://internalButNotDefinedAsLan.com")]
|
||||
|
||||
// User on internal network, no binding specified - so result is the 1st internal.
|
||||
[InlineData("192.168.1.1", "192.168.1.0/24", "", false, "0.0.0.0=http://helloworld.com", "eth16")]
|
||||
[InlineData("192.168.1.1", "192.168.1.0/24", "", false, "external=http://helloworld.com", "eth16")]
|
||||
|
||||
// User on external network, internal binding only - so assumption is a proxy forward, return external override.
|
||||
[InlineData("jellyfin.org", "192.168.1.0/24", "eth16", false, "0.0.0.0=http://helloworld.com", "http://helloworld.com")]
|
||||
[InlineData("jellyfin.org", "192.168.1.0/24", "eth16", false, "external=http://helloworld.com", "http://helloworld.com")]
|
||||
|
||||
// User on external network, no binding - so result is the 1st external which is overriden.
|
||||
[InlineData("jellyfin.org", "192.168.1.0/24", "", false, "0.0.0.0=http://helloworld.com", "http://helloworld.com")]
|
||||
[InlineData("jellyfin.org", "192.168.1.0/24", "", false, "external=http://helloworld.com", "http://helloworld.com")]
|
||||
|
||||
// User assumed to be internal, no binding - so result is the 1st internal.
|
||||
[InlineData("", "192.168.1.0/24", "", false, "0.0.0.0=http://helloworld.com", "eth16")]
|
||||
// User assumed to be internal, no binding - so result is the 1st matching interface.
|
||||
[InlineData("", "192.168.1.0/24", "", false, "all=http://helloworld.com", "eth16")]
|
||||
|
||||
// User is internal, no binding - so result is the 1st internal, which is then overridden.
|
||||
// User is internal, no binding - so result is the 1st internal interface, which is then overridden.
|
||||
[InlineData("192.168.1.1", "192.168.1.0/24", "", false, "eth16=http://helloworld.com", "http://helloworld.com")]
|
||||
public void TestBindInterfaceOverrides(string source, string lan, string bindAddresses, bool ipv6enabled, string publishedServers, string result)
|
||||
{
|
||||
@@ -264,7 +267,8 @@ namespace Jellyfin.Networking.Tests
|
||||
};
|
||||
|
||||
NetworkManager.MockNetworkSettings = "192.168.1.208/24,-16,eth16|200.200.200.200/24,11,eth11";
|
||||
using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
|
||||
var startupConf = new Mock<IConfiguration>();
|
||||
using var nm = new NetworkManager(NetworkParseTests.GetMockConfig(conf), startupConf.Object, new NullLogger<NetworkManager>());
|
||||
NetworkManager.MockNetworkSettings = string.Empty;
|
||||
|
||||
if (nm.TryParseInterface(result, out IReadOnlyList<IPData>? resultObj) && resultObj is not null)
|
||||
@@ -293,7 +297,9 @@ namespace Jellyfin.Networking.Tests
|
||||
RemoteIPFilter = addresses.Split(','),
|
||||
IsRemoteIPFilterBlacklist = false
|
||||
};
|
||||
using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
|
||||
|
||||
var startupConf = new Mock<IConfiguration>();
|
||||
using var nm = new NetworkManager(NetworkParseTests.GetMockConfig(conf), startupConf.Object, new NullLogger<NetworkManager>());
|
||||
|
||||
Assert.NotEqual(nm.HasRemoteAccess(IPAddress.Parse(remoteIP)), denied);
|
||||
}
|
||||
@@ -314,7 +320,8 @@ namespace Jellyfin.Networking.Tests
|
||||
IsRemoteIPFilterBlacklist = true
|
||||
};
|
||||
|
||||
using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
|
||||
var startupConf = new Mock<IConfiguration>();
|
||||
using var nm = new NetworkManager(NetworkParseTests.GetMockConfig(conf), startupConf.Object, new NullLogger<NetworkManager>());
|
||||
|
||||
Assert.NotEqual(nm.HasRemoteAccess(IPAddress.Parse(remoteIP)), denied);
|
||||
}
|
||||
@@ -334,7 +341,8 @@ namespace Jellyfin.Networking.Tests
|
||||
};
|
||||
|
||||
NetworkManager.MockNetworkSettings = interfaces;
|
||||
using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
|
||||
var startupConf = new Mock<IConfiguration>();
|
||||
using var nm = new NetworkManager(NetworkParseTests.GetMockConfig(conf), startupConf.Object, new NullLogger<NetworkManager>());
|
||||
|
||||
var interfaceToUse = nm.GetBindAddress(string.Empty, out _);
|
||||
|
||||
@@ -358,7 +366,8 @@ namespace Jellyfin.Networking.Tests
|
||||
};
|
||||
|
||||
NetworkManager.MockNetworkSettings = interfaces;
|
||||
using var nm = new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
|
||||
var startupConf = new Mock<IConfiguration>();
|
||||
using var nm = new NetworkManager(NetworkParseTests.GetMockConfig(conf), startupConf.Object, new NullLogger<NetworkManager>());
|
||||
|
||||
var interfaceToUse = nm.GetBindAddress(source, out _);
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace Jellyfin.Server.Integration.Tests
|
||||
{
|
||||
public static class AuthHelper
|
||||
{
|
||||
public const string AuthHeaderName = "X-Emby-Authorization";
|
||||
public const string DummyAuthHeader = "MediaBrowser Client=\"Jellyfin.Server Integration Tests\", DeviceId=\"69420\", Device=\"Apple II\", Version=\"10.8.0\"";
|
||||
public const string AuthHeaderName = "Authorization";
|
||||
public const string DummyAuthHeader = "MediaBrowser Client=\"Jellyfin.Server%20Integration%20Tests\", DeviceId=\"69420\", Device=\"Apple%20II\", Version=\"10.8.0\"";
|
||||
|
||||
public static async Task<string> CompleteStartupAsync(HttpClient client)
|
||||
{
|
||||
@@ -27,16 +27,19 @@ namespace Jellyfin.Server.Integration.Tests
|
||||
using var completeResponse = await client.PostAsync("/Startup/Complete", new ByteArrayContent(Array.Empty<byte>()));
|
||||
Assert.Equal(HttpStatusCode.NoContent, completeResponse.StatusCode);
|
||||
|
||||
using var content = JsonContent.Create(
|
||||
using var httpRequest = new HttpRequestMessage(HttpMethod.Post, "/Users/AuthenticateByName");
|
||||
httpRequest.Headers.TryAddWithoutValidation(AuthHeaderName, DummyAuthHeader);
|
||||
httpRequest.Content = JsonContent.Create(
|
||||
new AuthenticateUserByName()
|
||||
{
|
||||
Username = user!.Name,
|
||||
Pw = user.Password,
|
||||
},
|
||||
options: jsonOptions);
|
||||
content.Headers.Add("X-Emby-Authorization", DummyAuthHeader);
|
||||
|
||||
using var authResponse = await client.PostAsync("/Users/AuthenticateByName", content);
|
||||
using var authResponse = await client.SendAsync(httpRequest);
|
||||
authResponse.EnsureSuccessStatusCode();
|
||||
|
||||
var auth = await JsonSerializer.DeserializeAsync<AuthenticationResultDto>(
|
||||
await authResponse.Content.ReadAsStreamAsync(),
|
||||
jsonOptions);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Server.Integration.Tests.Controllers;
|
||||
|
||||
public class PersonsControllerTests : IClassFixture<JellyfinApplicationFactory>
|
||||
{
|
||||
private readonly JellyfinApplicationFactory _factory;
|
||||
private static string? _accessToken;
|
||||
|
||||
public PersonsControllerTests(JellyfinApplicationFactory factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetPerson_DoesntExist_NotFound()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||
|
||||
using var response = await client.GetAsync($"Persons/DoesntExist");
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using Jellyfin.Server.Extensions;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
@@ -119,8 +120,8 @@ namespace Jellyfin.Server.Tests
|
||||
EnableIPv6 = true,
|
||||
EnableIPv4 = true,
|
||||
};
|
||||
|
||||
return new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
|
||||
var startupConf = new Mock<IConfiguration>();
|
||||
return new NetworkManager(GetMockConfig(conf), startupConf.Object, new NullLogger<NetworkManager>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Jellyfin.Data.Enums;
|
||||
@@ -114,11 +114,11 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
|
||||
_parser.Fetch(result, "Test Data/Rising.nfo", CancellationToken.None);
|
||||
|
||||
var item = result.Item;
|
||||
Assert.Equal("Rising (1)", item.Name);
|
||||
Assert.Equal("Rising (1) / Rising (2)", item.Name);
|
||||
Assert.Equal(1, item.IndexNumber);
|
||||
Assert.Equal(2, item.IndexNumberEnd);
|
||||
Assert.Equal(1, item.ParentIndexNumber);
|
||||
Assert.Equal("A new Stargate team embarks on a dangerous mission to a distant galaxy, where they discover a mythical lost city -- and a deadly new enemy.", item.Overview);
|
||||
Assert.Equal("A new Stargate team embarks on a dangerous mission to a distant galaxy, where they discover a mythical lost city -- and a deadly new enemy. / Sheppard tries to convince Weir to mount a rescue mission to free Colonel Sumner, Teyla, and the others captured by the Wraith.", item.Overview);
|
||||
Assert.Equal(new DateTime(2004, 7, 16), item.PremiereDate);
|
||||
Assert.Equal(2004, item.ProductionYear);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user