mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-22 01:54:42 +01:00
Merge branch 'master' into authenticationdb-efcore
# Conflicts: # Emby.Server.Implementations/Devices/DeviceManager.cs # Emby.Server.Implementations/HttpServer/Security/SessionContext.cs # Emby.Server.Implementations/Security/AuthenticationRepository.cs # Emby.Server.Implementations/Session/SessionManager.cs # Jellyfin.Server.Implementations/Security/AuthorizationContext.cs # MediaBrowser.Controller/Library/IUserManager.cs # MediaBrowser.Controller/Net/ISessionContext.cs
This commit is contained in:
@@ -18,9 +18,9 @@
|
||||
<PackageReference Include="AutoFixture" Version="4.17.0" />
|
||||
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
|
||||
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.3" />
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.3" />
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.15.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Code Analyzers -->
|
||||
|
||||
@@ -1,34 +1,45 @@
|
||||
using System.Text.Json;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using FsCheck;
|
||||
using FsCheck.Xunit;
|
||||
using MediaBrowser.Common.Json.Converters;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Common.Tests.Json
|
||||
{
|
||||
public static class JsonBoolNumberTests
|
||||
public class JsonBoolNumberTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions()
|
||||
{
|
||||
Converters =
|
||||
{
|
||||
new JsonBoolNumberConverter()
|
||||
}
|
||||
};
|
||||
|
||||
[Theory]
|
||||
[InlineData("1", true)]
|
||||
[InlineData("0", false)]
|
||||
[InlineData("2", true)]
|
||||
[InlineData("true", true)]
|
||||
[InlineData("false", false)]
|
||||
public static void Deserialize_Number_Valid_Success(string input, bool? output)
|
||||
public void Deserialize_Number_Valid_Success(string input, bool? output)
|
||||
{
|
||||
var options = new JsonSerializerOptions();
|
||||
options.Converters.Add(new JsonBoolNumberConverter());
|
||||
var value = JsonSerializer.Deserialize<bool>(input, options);
|
||||
var value = JsonSerializer.Deserialize<bool>(input, _jsonOptions);
|
||||
Assert.Equal(value, output);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true, "true")]
|
||||
[InlineData(false, "false")]
|
||||
public static void Serialize_Bool_Success(bool input, string output)
|
||||
public void Serialize_Bool_Success(bool input, string output)
|
||||
{
|
||||
var options = new JsonSerializerOptions();
|
||||
options.Converters.Add(new JsonBoolNumberConverter());
|
||||
var value = JsonSerializer.Serialize(input, options);
|
||||
var value = JsonSerializer.Serialize(input, _jsonOptions);
|
||||
Assert.Equal(value, output);
|
||||
}
|
||||
|
||||
[Property]
|
||||
public Property Deserialize_NonZeroInt_True(NonZeroInt input)
|
||||
=> JsonSerializer.Deserialize<bool>(input.ToString(), _jsonOptions).ToProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,13 @@ namespace Jellyfin.Common.Tests.Json
|
||||
{
|
||||
public class JsonStringConverterTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonSerializerOptions
|
||||
= new ()
|
||||
private readonly JsonSerializerOptions _jsonSerializerOptions = new ()
|
||||
{
|
||||
Converters =
|
||||
{
|
||||
Converters =
|
||||
{
|
||||
new JsonStringConverter()
|
||||
}
|
||||
};
|
||||
new JsonStringConverter()
|
||||
}
|
||||
};
|
||||
|
||||
[Theory]
|
||||
[InlineData("\"test\"", "test")]
|
||||
@@ -36,4 +35,4 @@ namespace Jellyfin.Common.Tests.Json
|
||||
Assert.Equal(deserialized, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using MediaBrowser.Controller.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Controller.Extensions.Tests
|
||||
{
|
||||
public class StringExtensionsTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("", '_', 0)]
|
||||
[InlineData("___", '_', 3)]
|
||||
[InlineData("test\x00", '\x00', 1)]
|
||||
[InlineData("Imdb=tt0119567|Tmdb=330|TmdbCollection=328", '|', 2)]
|
||||
public void ReadOnlySpan_Count_Success(string str, char needle, int count)
|
||||
{
|
||||
Assert.Equal(count, str.AsSpan().Count(needle));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.3" />
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using MediaBrowser.Common.Json;
|
||||
@@ -17,9 +19,9 @@ namespace Jellyfin.MediaEncoding.Tests.Probing
|
||||
[Fact]
|
||||
public void GetMediaInfo_MetaData_Success()
|
||||
{
|
||||
var bytes = File.ReadAllBytes("Test Data/Probing/some_matadata.json");
|
||||
var bytes = File.ReadAllBytes("Test Data/Probing/video_metadata.json");
|
||||
var internalMediaInfoResult = JsonSerializer.Deserialize<InternalMediaInfoResult>(bytes, _jsonOptions);
|
||||
MediaInfo res = _probeResultNormalizer.GetMediaInfo(internalMediaInfoResult, VideoType.VideoFile, false, "Test Data/Probing/some_matadata.mkv", MediaProtocol.File);
|
||||
MediaInfo res = _probeResultNormalizer.GetMediaInfo(internalMediaInfoResult, VideoType.VideoFile, false, "Test Data/Probing/video_metadata.mkv", MediaProtocol.File);
|
||||
|
||||
Assert.Single(res.MediaStreams);
|
||||
|
||||
@@ -52,5 +54,22 @@ namespace Jellyfin.MediaEncoding.Tests.Probing
|
||||
Assert.Empty(res.Chapters);
|
||||
Assert.Equal("Just color bars", res.Overview);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMediaInfo_MusicVideo_Success()
|
||||
{
|
||||
var bytes = File.ReadAllBytes("Test Data/Probing/music_video_metadata.json");
|
||||
var internalMediaInfoResult = JsonSerializer.Deserialize<InternalMediaInfoResult>(bytes, _jsonOptions);
|
||||
MediaInfo res = _probeResultNormalizer.GetMediaInfo(internalMediaInfoResult, VideoType.VideoFile, false, "Test Data/Probing/music_video.mkv", MediaProtocol.File);
|
||||
|
||||
Assert.Equal("The Title", res.Name);
|
||||
Assert.Equal("Title, The", res.ForcedSortName);
|
||||
Assert.Single(res.Artists);
|
||||
Assert.Equal("The Artist", res.Artists[0]);
|
||||
Assert.Equal("Album", res.Album);
|
||||
Assert.Equal(2021, res.ProductionYear);
|
||||
Assert.True(res.PremiereDate.HasValue);
|
||||
Assert.Equal(DateTime.Parse("2021-01-01T00:00Z", DateTimeFormatInfo.CurrentInfo).ToUniversalTime(), res.PremiereDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"streams": [
|
||||
{
|
||||
"index": 0,
|
||||
"codec_name": "h264",
|
||||
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
|
||||
"profile": "High",
|
||||
"codec_type": "video",
|
||||
"codec_time_base": "1001/48000",
|
||||
"codec_tag_string": "[0][0][0][0]",
|
||||
"codec_tag": "0x0000",
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"coded_width": 1920,
|
||||
"coded_height": 1088,
|
||||
"closed_captions": 0,
|
||||
"has_b_frames": 0,
|
||||
"sample_aspect_ratio": "1:1",
|
||||
"display_aspect_ratio": "16:9",
|
||||
"pix_fmt": "yuv420p",
|
||||
"level": 42,
|
||||
"chroma_location": "left",
|
||||
"field_order": "progressive",
|
||||
"refs": 1,
|
||||
"is_avc": "true",
|
||||
"nal_length_size": "4",
|
||||
"r_frame_rate": "24000/1001",
|
||||
"avg_frame_rate": "24000/1001",
|
||||
"time_base": "1/1000",
|
||||
"start_pts": 0,
|
||||
"start_time": "0.000000",
|
||||
"bits_per_raw_sample": "8",
|
||||
"disposition": {
|
||||
"default": 1,
|
||||
"dub": 0,
|
||||
"original": 0,
|
||||
"comment": 0,
|
||||
"lyrics": 0,
|
||||
"karaoke": 0,
|
||||
"forced": 0,
|
||||
"hearing_impaired": 0,
|
||||
"visual_impaired": 0,
|
||||
"clean_effects": 0,
|
||||
"attached_pic": 0,
|
||||
"timed_thumbnails": 0
|
||||
},
|
||||
"tags": {
|
||||
"language": "eng"
|
||||
}
|
||||
},
|
||||
{
|
||||
"index": 1,
|
||||
"codec_name": "aac",
|
||||
"codec_long_name": "AAC (Advanced Audio Coding)",
|
||||
"profile": "LC",
|
||||
"codec_type": "audio",
|
||||
"codec_time_base": "1/48000",
|
||||
"codec_tag_string": "[0][0][0][0]",
|
||||
"codec_tag": "0x0000",
|
||||
"sample_fmt": "fltp",
|
||||
"sample_rate": "48000",
|
||||
"channels": 2,
|
||||
"channel_layout": "stereo",
|
||||
"bits_per_sample": 0,
|
||||
"r_frame_rate": "0/0",
|
||||
"avg_frame_rate": "0/0",
|
||||
"time_base": "1/1000",
|
||||
"start_pts": 0,
|
||||
"start_time": "0.000000",
|
||||
"disposition": {
|
||||
"default": 1,
|
||||
"dub": 0,
|
||||
"original": 0,
|
||||
"comment": 0,
|
||||
"lyrics": 0,
|
||||
"karaoke": 0,
|
||||
"forced": 0,
|
||||
"hearing_impaired": 0,
|
||||
"visual_impaired": 0,
|
||||
"clean_effects": 0,
|
||||
"attached_pic": 0,
|
||||
"timed_thumbnails": 0
|
||||
},
|
||||
"tags": {
|
||||
"language": "eng"
|
||||
}
|
||||
}
|
||||
],
|
||||
"chapters": [
|
||||
],
|
||||
"format": {
|
||||
"filename": "music_video.mkv",
|
||||
"nb_streams": 2,
|
||||
"nb_programs": 0,
|
||||
"format_name": "matroska,webm",
|
||||
"format_long_name": "Matroska / WebM",
|
||||
"start_time": "0.000000",
|
||||
"duration": "180.000000",
|
||||
"size": "500000000",
|
||||
"bit_rate": "22222222",
|
||||
"probe_score": 100,
|
||||
"tags": {
|
||||
"TITLE-eng": "The Title",
|
||||
"TITLESORT": "Title, The",
|
||||
"ARTIST": "The Artist",
|
||||
"ARTISTSORT": "Artist, The",
|
||||
"ALBUM": "Album",
|
||||
"DATE_RELEASED": "2021-01-01"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
using System;
|
||||
using FsCheck;
|
||||
using FsCheck.Xunit;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using Xunit;
|
||||
|
||||
@@ -10,9 +13,20 @@ namespace Jellyfin.Model.Tests.Extensions
|
||||
[InlineData("banana", "Banana")]
|
||||
[InlineData("Banana", "Banana")]
|
||||
[InlineData("ä", "Ä")]
|
||||
[InlineData("\027", "\027")]
|
||||
public void StringHelper_ValidArgs_Success(string input, string expectedResult)
|
||||
{
|
||||
Assert.Equal(expectedResult, StringHelper.FirstToUpper(input));
|
||||
}
|
||||
|
||||
[Property]
|
||||
public Property FirstToUpper_RandomArg_Correct(NonEmptyString input)
|
||||
{
|
||||
var result = StringHelper.FirstToUpper(input.Item);
|
||||
|
||||
// We check IsLower instead of IsUpper because both return false for non-letters
|
||||
return (!char.IsLower(result[0])).Label("First char is uppercase")
|
||||
.And(input.Item.Length == 1 || result[1..].Equals(input.Item[1..], StringComparison.Ordinal)).Label("Remaining chars are unmodified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.3" />
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.15.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Code Analyzers -->
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.3" />
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
input = Path.GetFileName(input);
|
||||
|
||||
var result = new VideoResolver(_namingOptions).CleanDateTime(input);
|
||||
var result = VideoResolver.CleanDateTime(input, _namingOptions);
|
||||
|
||||
Assert.Equal(expectedName, result.Name, true);
|
||||
Assert.Equal(expectedYear, result.Year);
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public sealed class CleanStringTests
|
||||
{
|
||||
private readonly VideoResolver _videoResolver = new VideoResolver(new NamingOptions());
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Theory]
|
||||
[InlineData("Super movie 480p.mp4", "Super movie")]
|
||||
@@ -26,7 +26,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
// FIXME: [InlineData("After The Sunset - [0004].mkv", "After The Sunset")]
|
||||
public void CleanStringTest_NeedsCleaning_Success(string input, string expectedName)
|
||||
{
|
||||
Assert.True(_videoResolver.TryCleanString(input, out ReadOnlySpan<char> newName));
|
||||
Assert.True(VideoResolver.TryCleanString(input, _namingOptions, out ReadOnlySpan<char> newName));
|
||||
// TODO: compare spans when XUnit supports it
|
||||
Assert.Equal(expectedName, newName.ToString());
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
[InlineData("Run lola run (lola rennt) (2009).mp4")]
|
||||
public void CleanStringTest_DoesntNeedCleaning_False(string? input)
|
||||
{
|
||||
Assert.False(_videoResolver.TryCleanString(input, out ReadOnlySpan<char> newName));
|
||||
Assert.False(VideoResolver.TryCleanString(input, _namingOptions, out ReadOnlySpan<char> newName));
|
||||
Assert.True(newName.IsEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +104,6 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
Assert.Equal(rule, res.Rule);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestFlagsParser()
|
||||
{
|
||||
var flags = new FlagParser(_videoOptions).GetFlags(string.Empty);
|
||||
Assert.Empty(flags);
|
||||
}
|
||||
|
||||
private ExtraResolver GetExtraTypeParser(NamingOptions videoOptions)
|
||||
{
|
||||
return new ExtraResolver(videoOptions);
|
||||
|
||||
@@ -22,8 +22,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
[Fact]
|
||||
public void Test3DName()
|
||||
{
|
||||
var result =
|
||||
new VideoResolver(_namingOptions).ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv");
|
||||
var result = VideoResolver.ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv", _namingOptions);
|
||||
|
||||
Assert.Equal("hsbs", result?.Format3D);
|
||||
Assert.Equal("Oblivion", result?.Name);
|
||||
@@ -58,15 +57,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
|
||||
private void Test(string input, bool is3D, string? format3D)
|
||||
{
|
||||
var parser = new Format3DParser(_namingOptions);
|
||||
|
||||
var result = parser.Parse(input);
|
||||
var result = Format3DParser.Parse(input, _namingOptions);
|
||||
|
||||
Assert.Equal(is3D, result.Is3D);
|
||||
|
||||
if (format3D == null)
|
||||
{
|
||||
Assert.Null(result.Format3D);
|
||||
Assert.Null(result?.Format3D);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public class MultiVersionTests
|
||||
{
|
||||
private readonly VideoListResolver _videoListResolver = new VideoListResolver(new NamingOptions());
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Fact]
|
||||
public void TestMultiEdition1()
|
||||
@@ -22,11 +22,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/X-Men Days of Future Past/X-Men Days of Future Past [hsbs].mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Single(result[0].Extras);
|
||||
@@ -43,11 +45,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/X-Men Days of Future Past/X-Men Days of Future Past [banana].mp4"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Single(result[0].Extras);
|
||||
@@ -63,11 +67,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/The Phantom of the Opera (1925)/The Phantom of the Opera (1925) - 1929 version.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Single(result[0].AlternateVersions);
|
||||
@@ -87,11 +93,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/M/Movie 7.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(7, result.Count);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -113,11 +121,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Movie/Movie-8.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -140,11 +150,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Mo/Movie 9.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(9, result.Count);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -163,11 +175,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Movie/Movie 5.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(5, result.Count);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -188,11 +202,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Iron Man/Iron Man (2011).mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(5, result.Count);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -214,11 +230,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Iron Man/Iron Man[test].mkv",
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -243,11 +261,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Iron Man/Iron Man [test].mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -266,11 +286,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Iron Man/Iron Man - C (2007).mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(2, result.Count);
|
||||
}
|
||||
@@ -289,11 +311,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Iron Man/Iron Man_3d.hsbs.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(7, result.Count);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -314,11 +338,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Iron Man/Iron Man (2011).mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(5, result.Count);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -334,11 +360,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/Blade Runner (1982)/Blade Runner (1982) [EE by ADM] [480p HEVC AAC,AAC,AAC].mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -354,11 +382,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) [2160p] Blu-ray.x265.AAC.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -374,11 +404,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/John Wick - Kapitel 3 (2019) [imdbid=tt6146586]/John Wick - Kapitel 3 (2019) [imdbid=tt6146586] - Version 2.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Empty(result[0].Extras);
|
||||
@@ -394,11 +426,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/movies/John Wick - Chapter 3 (2019)/John Wick - Chapter 3 (2019) [Version 2.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(2, result.Count);
|
||||
}
|
||||
@@ -406,7 +440,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
[Fact]
|
||||
public void TestEmptyList()
|
||||
{
|
||||
var result = _videoListResolver.Resolve(new List<FileSystemMetadata>()).ToList();
|
||||
var result = VideoListResolver.Resolve(new List<FileSystemMetadata>(), _namingOptions).ToList();
|
||||
|
||||
Assert.Empty(result);
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
[Fact]
|
||||
public void TestStubName()
|
||||
{
|
||||
var result =
|
||||
new VideoResolver(_namingOptions).ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.dvd.disc");
|
||||
var result = VideoResolver.ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.dvd.disc", _namingOptions);
|
||||
|
||||
Assert.Equal("Oblivion", result?.Name);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public class VideoListResolverTests
|
||||
{
|
||||
private readonly VideoListResolver _videoListResolver = new VideoListResolver(new NamingOptions());
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Fact]
|
||||
public void TestStackAndExtras()
|
||||
@@ -40,11 +40,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
"WillyWonka-trailer.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(5, result.Count);
|
||||
var batman = result.FirstOrDefault(x => string.Equals(x.Name, "Batman", StringComparison.Ordinal));
|
||||
@@ -67,11 +69,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
"300.nfo"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -85,11 +89,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
"300 trailer.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -103,11 +109,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
"X-Men Days of Future Past-trailer.mp4"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -122,11 +130,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
"X-Men Days of Future Past-trailer2.mp4"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -140,11 +150,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
"Looper.2012.bluray.720p.x264.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -162,11 +174,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
"My video 5.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(5, result.Count);
|
||||
}
|
||||
@@ -180,11 +194,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"M:/Movies (DVD)/Movies (Musical)/Sound of Music (1965)/Sound of Music Disc 2"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = true,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = true,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -199,11 +215,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"My movie #2.mp4"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = true,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = true,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(2, result.Count);
|
||||
}
|
||||
@@ -218,11 +236,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"No (2012) part1-trailer.mp4"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -237,11 +257,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"No (2012)-trailer.mp4"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -257,11 +279,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"trailer.mp4"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -277,11 +301,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Disc 2 cd2.avi"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(2, result.Count);
|
||||
}
|
||||
@@ -294,11 +320,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/nas-markrobbo78/Videos/INDEX HTPC/Movies/Watched/3 - ACTION/Argo (2012)/movie.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -311,11 +339,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"The Colony.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -329,11 +359,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"Four Sisters and a Wedding - B.avi"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -347,11 +379,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"Four Rooms - A.mp4"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(2, result.Count);
|
||||
}
|
||||
@@ -365,11 +399,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/Server/Despicable Me/movie-trailer.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
@@ -385,11 +421,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/Server/Despicable Me/Baywatch (2017) - Trailer.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Equal(4, result.Count);
|
||||
}
|
||||
@@ -403,11 +441,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
@"/Movies/Despicable Me/trailers/trailer.mkv"
|
||||
};
|
||||
|
||||
var result = _videoListResolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList()).ToList();
|
||||
var result = VideoListResolver.Resolve(
|
||||
files.Select(i => new FileSystemMetadata
|
||||
{
|
||||
IsDirectory = false,
|
||||
FullName = i
|
||||
}).ToList(),
|
||||
_namingOptions).ToList();
|
||||
|
||||
Assert.Single(result);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public class VideoResolverTests
|
||||
{
|
||||
private readonly VideoResolver _videoResolver = new VideoResolver(new NamingOptions());
|
||||
private static NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
public static IEnumerable<object[]> ResolveFile_ValidFileNameTestData()
|
||||
{
|
||||
@@ -159,27 +159,27 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
[MemberData(nameof(ResolveFile_ValidFileNameTestData))]
|
||||
public void ResolveFile_ValidFileName_Success(VideoFileInfo expectedResult)
|
||||
{
|
||||
var result = _videoResolver.ResolveFile(expectedResult.Path);
|
||||
var result = VideoResolver.ResolveFile(expectedResult.Path, _namingOptions);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(result?.Path, expectedResult.Path);
|
||||
Assert.Equal(result?.Container, expectedResult.Container);
|
||||
Assert.Equal(result?.Name, expectedResult.Name);
|
||||
Assert.Equal(result?.Year, expectedResult.Year);
|
||||
Assert.Equal(result?.ExtraType, expectedResult.ExtraType);
|
||||
Assert.Equal(result?.Format3D, expectedResult.Format3D);
|
||||
Assert.Equal(result?.Is3D, expectedResult.Is3D);
|
||||
Assert.Equal(result?.IsStub, expectedResult.IsStub);
|
||||
Assert.Equal(result?.StubType, expectedResult.StubType);
|
||||
Assert.Equal(result?.IsDirectory, expectedResult.IsDirectory);
|
||||
Assert.Equal(result?.FileNameWithoutExtension, expectedResult.FileNameWithoutExtension);
|
||||
Assert.Equal(result?.ToString(), expectedResult.ToString());
|
||||
Assert.Equal(result!.Path, expectedResult.Path);
|
||||
Assert.Equal(result.Container, expectedResult.Container);
|
||||
Assert.Equal(result.Name, expectedResult.Name);
|
||||
Assert.Equal(result.Year, expectedResult.Year);
|
||||
Assert.Equal(result.ExtraType, expectedResult.ExtraType);
|
||||
Assert.Equal(result.Format3D, expectedResult.Format3D);
|
||||
Assert.Equal(result.Is3D, expectedResult.Is3D);
|
||||
Assert.Equal(result.IsStub, expectedResult.IsStub);
|
||||
Assert.Equal(result.StubType, expectedResult.StubType);
|
||||
Assert.Equal(result.IsDirectory, expectedResult.IsDirectory);
|
||||
Assert.Equal(result.FileNameWithoutExtension.ToString(), expectedResult.FileNameWithoutExtension.ToString());
|
||||
Assert.Equal(result.ToString(), expectedResult.ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveFile_EmptyPath()
|
||||
{
|
||||
var result = _videoResolver.ResolveFile(string.Empty);
|
||||
var result = VideoResolver.ResolveFile(string.Empty, _namingOptions);
|
||||
|
||||
Assert.Null(result);
|
||||
}
|
||||
@@ -194,7 +194,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
string.Empty
|
||||
};
|
||||
|
||||
var results = paths.Select(path => _videoResolver.ResolveDirectory(path)).ToList();
|
||||
var results = paths.Select(path => VideoResolver.ResolveDirectory(path, _namingOptions)).ToList();
|
||||
|
||||
Assert.Equal(3, results.Count);
|
||||
Assert.NotNull(results[0]);
|
||||
|
||||
53
tests/Jellyfin.Networking.Tests/IPHostTests.cs
Normal file
53
tests/Jellyfin.Networking.Tests/IPHostTests.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using FsCheck;
|
||||
using FsCheck.Xunit;
|
||||
using MediaBrowser.Common.Net;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Networking.Tests
|
||||
{
|
||||
public static class IPHostTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks IP address formats.
|
||||
/// </summary>
|
||||
/// <param name="address">IP Address.</param>
|
||||
[Theory]
|
||||
[InlineData("127.0.0.1")]
|
||||
[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")]
|
||||
[InlineData("fe80::7add:12ff:febb:c67b%16")]
|
||||
[InlineData("[fe80::7add:12ff:febb:c67b%16]:123")]
|
||||
[InlineData("fe80::7add:12ff:febb:c67b%16:123")]
|
||||
[InlineData("[fe80::7add:12ff:febb:c67b%16]")]
|
||||
[InlineData("192.168.1.2/255.255.255.0")]
|
||||
[InlineData("192.168.1.2/24")]
|
||||
public static void TryParse_ValidHostStrings_True(string address)
|
||||
=> Assert.True(IPHost.TryParse(address, out _));
|
||||
|
||||
[Property]
|
||||
public static Property TryParse_IPv4Address_True(IPv4Address address)
|
||||
=> IPHost.TryParse(address.Item.ToString(), out _).ToProperty();
|
||||
|
||||
[Property]
|
||||
public static Property TryParse_IPv6Address_True(IPv6Address address)
|
||||
=> IPHost.TryParse(address.Item.ToString(), out _).ToProperty();
|
||||
|
||||
/// <summary>
|
||||
/// All should be invalid address strings.
|
||||
/// </summary>
|
||||
/// <param name="address">Invalid address strings.</param>
|
||||
[Theory]
|
||||
[InlineData("256.128.0.0.0.1")]
|
||||
[InlineData("127.0.0.1#")]
|
||||
[InlineData("localhost!")]
|
||||
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517:1231")]
|
||||
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517:1231]")]
|
||||
public static void TryParse_InvalidAddressString_False(string address)
|
||||
=> Assert.False(IPHost.TryParse(address, out _));
|
||||
}
|
||||
}
|
||||
49
tests/Jellyfin.Networking.Tests/IPNetAddressTests.cs
Normal file
49
tests/Jellyfin.Networking.Tests/IPNetAddressTests.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using FsCheck;
|
||||
using FsCheck.Xunit;
|
||||
using MediaBrowser.Common.Net;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Networking.Tests
|
||||
{
|
||||
public static class IPNetAddressTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks IP address formats.
|
||||
/// </summary>
|
||||
/// <param name="address">IP Address.</param>
|
||||
[Theory]
|
||||
[InlineData("127.0.0.1")]
|
||||
[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]")]
|
||||
[InlineData("fe80::7add:12ff:febb:c67b%16")]
|
||||
[InlineData("[fe80::7add:12ff:febb:c67b%16]:123")]
|
||||
[InlineData("fe80::7add:12ff:febb:c67b%16:123")]
|
||||
[InlineData("[fe80::7add:12ff:febb:c67b%16]")]
|
||||
[InlineData("192.168.1.2/255.255.255.0")]
|
||||
[InlineData("192.168.1.2/24")]
|
||||
public static void TryParse_ValidIPStrings_True(string address)
|
||||
=> Assert.True(IPNetAddress.TryParse(address, out _));
|
||||
|
||||
[Property]
|
||||
public static Property TryParse_IPv4Address_True(IPv4Address address)
|
||||
=> IPNetAddress.TryParse(address.Item.ToString(), out _).ToProperty();
|
||||
|
||||
[Property]
|
||||
public static Property TryParse_IPv6Address_True(IPv6Address address)
|
||||
=> IPNetAddress.TryParse(address.Item.ToString(), out _).ToProperty();
|
||||
|
||||
/// <summary>
|
||||
/// All should be invalid address strings.
|
||||
/// </summary>
|
||||
/// <param name="address">Invalid address strings.</param>
|
||||
[Theory]
|
||||
[InlineData("256.128.0.0.0.1")]
|
||||
[InlineData("127.0.0.1#")]
|
||||
[InlineData("localhost!")]
|
||||
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517:1231")]
|
||||
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517:1231]")]
|
||||
public static void TryParse_InvalidAddressString_False(string address)
|
||||
=> Assert.False(IPNetAddress.TryParse(address, out _));
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.3" />
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.15.3" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -56,66 +56,6 @@ namespace Jellyfin.Networking.Tests
|
||||
Assert.Equal(nm.GetInternalBindAddresses().AsString(), value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks IP address formats.
|
||||
/// </summary>
|
||||
/// <param name="address">IP Address.</param>
|
||||
[Theory]
|
||||
[InlineData("127.0.0.1")]
|
||||
[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")]
|
||||
[InlineData("fe80::7add:12ff:febb:c67b%16")]
|
||||
[InlineData("[fe80::7add:12ff:febb:c67b%16]:123")]
|
||||
[InlineData("fe80::7add:12ff:febb:c67b%16:123")]
|
||||
[InlineData("[fe80::7add:12ff:febb:c67b%16]")]
|
||||
[InlineData("192.168.1.2/255.255.255.0")]
|
||||
[InlineData("192.168.1.2/24")]
|
||||
public void ValidHostStrings(string address)
|
||||
{
|
||||
Assert.True(IPHost.TryParse(address, out _));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks IP address formats.
|
||||
/// </summary>
|
||||
/// <param name="address">IP Address.</param>
|
||||
[Theory]
|
||||
[InlineData("127.0.0.1")]
|
||||
[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]")]
|
||||
[InlineData("fe80::7add:12ff:febb:c67b%16")]
|
||||
[InlineData("[fe80::7add:12ff:febb:c67b%16]:123")]
|
||||
[InlineData("fe80::7add:12ff:febb:c67b%16:123")]
|
||||
[InlineData("[fe80::7add:12ff:febb:c67b%16]")]
|
||||
[InlineData("192.168.1.2/255.255.255.0")]
|
||||
[InlineData("192.168.1.2/24")]
|
||||
public void ValidIPStrings(string address)
|
||||
{
|
||||
Assert.True(IPNetAddress.TryParse(address, out _));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All should be invalid address strings.
|
||||
/// </summary>
|
||||
/// <param name="address">Invalid address strings.</param>
|
||||
[Theory]
|
||||
[InlineData("256.128.0.0.0.1")]
|
||||
[InlineData("127.0.0.1#")]
|
||||
[InlineData("localhost!")]
|
||||
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517:1231")]
|
||||
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517:1231]")]
|
||||
public void InvalidAddressString(string address)
|
||||
{
|
||||
Assert.False(IPNetAddress.TryParse(address, out _));
|
||||
Assert.False(IPHost.TryParse(address, out _));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test collection parsing.
|
||||
/// </summary>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
|
||||
@@ -166,6 +166,38 @@ namespace Jellyfin.Server.Implementations.Tests.Data
|
||||
};
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> DeserializeImages_ValidAndInvalid_TestData()
|
||||
{
|
||||
yield return new object[]
|
||||
{
|
||||
string.Empty,
|
||||
Array.Empty<ItemImageInfo>()
|
||||
};
|
||||
|
||||
yield return new object[]
|
||||
{
|
||||
"/mnt/series/Family Guy/Season 1/Family Guy - S01E01-thumb.jpg*637452096478512963*Primary*1920*1080*WjQbtJtSO8nhNZ%L_Io#R/oaS6o}-;adXAoIn7j[%hW9s:WGw[nN|test|1234||ss",
|
||||
new ItemImageInfo[]
|
||||
{
|
||||
new ()
|
||||
{
|
||||
Path = "/mnt/series/Family Guy/Season 1/Family Guy - S01E01-thumb.jpg",
|
||||
Type = ImageType.Primary,
|
||||
DateModified = new DateTime(637452096478512963, DateTimeKind.Utc),
|
||||
Width = 1920,
|
||||
Height = 1080,
|
||||
BlurHash = "WjQbtJtSO8nhNZ%L_Io#R*oaS6o}-;adXAoIn7j[%hW9s:WGw[nN"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
yield return new object[]
|
||||
{
|
||||
"|",
|
||||
Array.Empty<ItemImageInfo>()
|
||||
};
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(DeserializeImages_Valid_TestData))]
|
||||
public void DeserializeImages_Valid_Success(string value, ItemImageInfo[] expected)
|
||||
@@ -183,6 +215,23 @@ namespace Jellyfin.Server.Implementations.Tests.Data
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(DeserializeImages_ValidAndInvalid_TestData))]
|
||||
public void DeserializeImages_ValidAndInvalid_Success(string value, ItemImageInfo[] expected)
|
||||
{
|
||||
var result = _sqliteItemRepository.DeserializeImages(value);
|
||||
Assert.Equal(expected.Length, result.Length);
|
||||
for (int i = 0; i < expected.Length; i++)
|
||||
{
|
||||
Assert.Equal(expected[i].Path, result[i].Path);
|
||||
Assert.Equal(expected[i].Type, result[i].Type);
|
||||
Assert.Equal(expected[i].DateModified, result[i].DateModified);
|
||||
Assert.Equal(expected[i].Width, result[i].Width);
|
||||
Assert.Equal(expected[i].Height, result[i].Height);
|
||||
Assert.Equal(expected[i].BlurHash, result[i].BlurHash);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(DeserializeImages_Valid_TestData))]
|
||||
public void SerializeImages_Valid_Success(string expected, ItemImageInfo[] value)
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoFixture" Version="4.17.0" />
|
||||
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
@@ -42,6 +42,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Emby.Server.Implementations\Emby.Server.Implementations.csproj" />
|
||||
<ProjectReference Include="..\..\Jellyfin.Server.Implementations\Jellyfin.Server.Implementations.csproj" />
|
||||
<ProjectReference Include="..\Jellyfin.Server.Integration.Tests\Jellyfin.Server.Integration.Tests.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -46,12 +47,36 @@ namespace Jellyfin.Server.Implementations.Tests.Updates
|
||||
[Fact]
|
||||
public async Task GetPackages_Valid_Success()
|
||||
{
|
||||
IList<PackageInfo> packages = await _installationManager.GetPackages(
|
||||
PackageInfo[] packages = await _installationManager.GetPackages(
|
||||
"Jellyfin Stable",
|
||||
"https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
|
||||
false);
|
||||
|
||||
Assert.Equal(25, packages.Count);
|
||||
Assert.Equal(25, packages.Length);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FilterPackages_NameOnly_Success()
|
||||
{
|
||||
PackageInfo[] packages = await _installationManager.GetPackages(
|
||||
"Jellyfin Stable",
|
||||
"https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
|
||||
false);
|
||||
|
||||
packages = _installationManager.FilterPackages(packages, "Anime").ToArray();
|
||||
Assert.Single(packages);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FilterPackages_GuidOnly_Success()
|
||||
{
|
||||
PackageInfo[] packages = await _installationManager.GetPackages(
|
||||
"Jellyfin Stable",
|
||||
"https://repo.jellyfin.org/releases/plugin/manifest-stable.json",
|
||||
false);
|
||||
|
||||
packages = _installationManager.FilterPackages(packages, id: new Guid("a4df60c5-6ab4-412a-8f79-2cab93fb2bc5")).ToArray();
|
||||
Assert.Single(packages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using Jellyfin.Api;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Base controller for testing infrastructure.
|
||||
/// Automatically ignored in generated openapi spec.
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public class BaseJellyfinTestController : BaseJellyfinApiController
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Controller for testing the encoded url.
|
||||
/// </summary>
|
||||
public class EncoderController : BaseJellyfinTestController
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests the url decoding.
|
||||
/// </summary>
|
||||
/// <param name="params">Parameters to echo back in the response.</param>
|
||||
/// <returns>An <see cref="OkResult"/>.</returns>
|
||||
/// <response code="200">Information retrieved.</response>
|
||||
[HttpGet("UrlDecode")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public ContentResult TestUrlDecoding([FromQuery] Dictionary<string, string>? @params = null)
|
||||
{
|
||||
return new ContentResult()
|
||||
{
|
||||
Content = (@params != null && @params.Count > 0)
|
||||
? string.Join("&", @params.Select(x => x.Key + "=" + x.Value))
|
||||
: string.Empty,
|
||||
ContentType = "text/plain; charset=utf-8",
|
||||
StatusCode = 200
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the url decoding.
|
||||
/// </summary>
|
||||
/// <param name="params">Parameters to echo back in the response.</param>
|
||||
/// <returns>An <see cref="OkResult"/>.</returns>
|
||||
/// <response code="200">Information retrieved.</response>
|
||||
[HttpGet("UrlArrayDecode")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public ContentResult TestUrlArrayDecoding([FromQuery] Dictionary<string, string[]>? @params = null)
|
||||
{
|
||||
return new ContentResult()
|
||||
{
|
||||
Content = (@params != null && @params.Count > 0)
|
||||
? string.Join("&", @params.Select(x => x.Key + "=" + string.Join(',', x.Value)))
|
||||
: string.Empty,
|
||||
ContentType = "text/plain; charset=utf-8",
|
||||
StatusCode = 200
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Server.Integration.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the test for encoded querystrings in the url.
|
||||
/// </summary>
|
||||
public class EncodedQueryStringTest : IClassFixture<JellyfinApplicationFactory>
|
||||
{
|
||||
private readonly JellyfinApplicationFactory _factory;
|
||||
|
||||
public EncodedQueryStringTest(JellyfinApplicationFactory factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("a=1&b=2&c=3", "a=1&b=2&c=3")] // won't be processed as there is more than 1.
|
||||
[InlineData("a=1", "a=1")] // won't be processed as it has a value
|
||||
[InlineData("a%3D1%26b%3D2%26c%3D3", "a=1&b=2&c=3")] // will be processed.
|
||||
[InlineData("a=b&a=c", "a=b")]
|
||||
[InlineData("a%3Db%26a%3Dc", "a=b")]
|
||||
public async Task Ensure_Decoding_Of_Urls_Is_Working(string sourceUrl, string unencodedUrl)
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
var response = await client.GetAsync("Encoder/UrlDecode?" + sourceUrl).ConfigureAwait(false);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
string reply = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
Assert.Equal(unencodedUrl, reply);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("a=b&a=c", "a=b,c")]
|
||||
[InlineData("a%3Db%26a%3Dc", "a=b,c")]
|
||||
public async Task Ensure_Array_Decoding_Of_Urls_Is_Working(string sourceUrl, string unencodedUrl)
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
var response = await client.GetAsync("Encoder/UrlArrayDecode?" + sourceUrl).ConfigureAwait(false);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
string reply = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
Assert.Equal(unencodedUrl, reply);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,9 @@
|
||||
<PackageReference Include="AutoFixture" Version="4.17.0" />
|
||||
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
|
||||
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="Xunit.Priority" Version="1.1.6" />
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
<PackageReference Include="AutoFixture" Version="4.17.0" />
|
||||
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
|
||||
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.3" />
|
||||
|
||||
31
tests/Jellyfin.Server.Tests/UrlDecodeQueryFeatureTests.cs
Normal file
31
tests/Jellyfin.Server.Tests/UrlDecodeQueryFeatureTests.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Jellyfin.Server.Middleware;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Server.Tests
|
||||
{
|
||||
public static class UrlDecodeQueryFeatureTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("e0a72cb2a2c7", "e0a72cb2a2c7")] // isn't encoded
|
||||
[InlineData("random+test", "random test")] // encoded
|
||||
[InlineData("random%20test", "random test")] // encoded
|
||||
[InlineData("++", " ")] // encoded
|
||||
public static void EmptyValueTest(string query, string key)
|
||||
{
|
||||
var dict = new Dictionary<string, StringValues>
|
||||
{
|
||||
{ query, StringValues.Empty }
|
||||
};
|
||||
var test = new UrlDecodeQueryFeature(new QueryFeature(new QueryCollection(dict)));
|
||||
Assert.Single(test.Query);
|
||||
var (k, v) = test.Query.First();
|
||||
Assert.Equal(key, k);
|
||||
Assert.Empty(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
|
||||
@@ -14,8 +14,6 @@ using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
#pragma warning disable CA5369
|
||||
|
||||
namespace Jellyfin.XbmcMetadata.Tests.Parsers
|
||||
{
|
||||
public class EpisodeNfoProviderTests
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma warning disable CA5369
|
||||
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#pragma warning disable CA5369
|
||||
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
|
||||
Reference in New Issue
Block a user