This commit is contained in:
BaronGreenback 2021-01-17 13:35:30 +00:00
parent 688e7c6a2d
commit b9f0f4f53b
3 changed files with 34 additions and 30 deletions

View File

@ -43,6 +43,8 @@ using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen; using Swashbuckle.AspNetCore.SwaggerGen;
using AuthenticationSchemes = Jellyfin.Api.Constants.AuthenticationSchemes; using AuthenticationSchemes = Jellyfin.Api.Constants.AuthenticationSchemes;
[assembly: InternalsVisibleTo("Jellyfin.Api.Tests")]
namespace Jellyfin.Server.Extensions namespace Jellyfin.Server.Extensions
{ {
/// <summary> /// <summary>

View File

@ -36,12 +36,6 @@
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>Jellyfin.Api.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" /> <PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />
@ -79,4 +73,10 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Jellyfin.Api.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Project> </Project>

View File

@ -14,27 +14,6 @@ namespace Jellyfin.Api.Tests
{ {
public class ParseNetworkTests public class ParseNetworkTests
{ {
private static IConfigurationManager GetMockConfig(NetworkConfiguration conf)
{
var configManager = new Mock<IConfigurationManager>
{
CallBase = true
};
configManager.Setup(x => x.GetConfiguration(It.IsAny<string>())).Returns(conf);
return (IConfigurationManager)configManager.Object;
}
private static NetworkManager CreateNetworkManager()
{
var conf = new NetworkConfiguration()
{
EnableIPV6 = true,
EnableIPV4 = true,
};
return new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
}
/// <summary> /// <summary>
/// Order of the result has always got to be hosts, then networks. /// Order of the result has always got to be hosts, then networks.
/// </summary> /// </summary>
@ -53,9 +32,11 @@ namespace Jellyfin.Api.Tests
using var nm = CreateNetworkManager(); using var nm = CreateNetworkManager();
nm.SystemIP6Enabled = ip6; nm.SystemIP6Enabled = ip6;
var settings = new NetworkConfiguration(); var settings = new NetworkConfiguration
settings.EnableIPV4 = ip4; {
settings.EnableIPV6 = ip6; EnableIPV4 = ip4,
EnableIPV6 = ip6
};
var result = match + ','; var result = match + ',';
ForwardedHeadersOptions options = new ForwardedHeadersOptions(); ForwardedHeadersOptions options = new ForwardedHeadersOptions();
@ -83,5 +64,26 @@ namespace Jellyfin.Api.Tests
Assert.True(string.Equals(sb.ToString(), result, StringComparison.OrdinalIgnoreCase), "Not matched: " + sb.ToString() + " does not match " + result); Assert.True(string.Equals(sb.ToString(), result, StringComparison.OrdinalIgnoreCase), "Not matched: " + sb.ToString() + " does not match " + result);
} }
private static IConfigurationManager GetMockConfig(NetworkConfiguration conf)
{
var configManager = new Mock<IConfigurationManager>
{
CallBase = true
};
configManager.Setup(x => x.GetConfiguration(It.IsAny<string>())).Returns(conf);
return (IConfigurationManager)configManager.Object;
}
private static NetworkManager CreateNetworkManager()
{
var conf = new NetworkConfiguration()
{
EnableIPV6 = true,
EnableIPV4 = true,
};
return new NetworkManager(GetMockConfig(conf), new NullLogger<NetworkManager>());
}
} }
} }