mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-04 23:08:42 +01:00
Merge remote-tracking branch 'upstream/master' into authenticationdb-efcore
This commit is contained in:
@@ -15,9 +15,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.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.9" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0" />
|
||||
|
||||
@@ -171,11 +171,11 @@ namespace Jellyfin.Common.Tests.Cryptography
|
||||
[InlineData("$PBKDF2$=$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D")] // Invalid parmeter
|
||||
[InlineData("$PBKDF2$=1000$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D")] // Invalid parmeter
|
||||
[InlineData("$PBKDF2$iterations=$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D")] // Invalid parmeter
|
||||
[InlineData("$PBKDF2$iterations=$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D$")] // Ends on $
|
||||
[InlineData("$PBKDF2$iterations=$69F420$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D$")] // Extra segment
|
||||
[InlineData("$PBKDF2$iterations=$69F420$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D$anotherone")] // Extra segment
|
||||
[InlineData("$PBKDF2$iterations=$invalidstalt$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D")] // Invalid salt
|
||||
[InlineData("$PBKDF2$iterations=$69F420$invalid hash")] // Invalid hash
|
||||
[InlineData("$PBKDF2$iterations=1000$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D$")] // Ends on $
|
||||
[InlineData("$PBKDF2$iterations=1000$69F420$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D$")] // Extra segment
|
||||
[InlineData("$PBKDF2$iterations=1000$69F420$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D$anotherone")] // Extra segment
|
||||
[InlineData("$PBKDF2$iterations=1000$invalidstalt$62FBA410AFCA5B4475F35137AB2E8596B127E4D927BA23F6CC05C067E897042D")] // Invalid salt
|
||||
[InlineData("$PBKDF2$iterations=1000$69F420$invalid hash")] // Invalid hash
|
||||
[InlineData("$PBKDF2$69F420$")] // Empty hash
|
||||
public static void Parse_InvalidFormat_ThrowsFormatException(string passwordHash)
|
||||
{
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0" />
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.15.3" />
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.16.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Code Analyzers -->
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
@@ -17,7 +17,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.15.3" />
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.16.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Code Analyzers -->
|
||||
|
||||
@@ -9,15 +9,18 @@ namespace Jellyfin.MediaEncoding.Tests
|
||||
{
|
||||
public class EncoderValidatorTests
|
||||
{
|
||||
private readonly EncoderValidator _encoderValidator = new EncoderValidator(new NullLogger<EncoderValidatorTests>(), "ffmpeg");
|
||||
|
||||
[Theory]
|
||||
[ClassData(typeof(GetFFmpegVersionTestData))]
|
||||
public void GetFFmpegVersionTest(string versionOutput, Version? version)
|
||||
{
|
||||
var val = new EncoderValidator(new NullLogger<EncoderValidatorTests>());
|
||||
Assert.Equal(version, val.GetFFmpegVersion(versionOutput));
|
||||
Assert.Equal(version, _encoderValidator.GetFFmpegVersionInternal(versionOutput));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(EncoderValidatorTestsData.FFmpegV44Output, true)]
|
||||
[InlineData(EncoderValidatorTestsData.FFmpegV432Output, true)]
|
||||
[InlineData(EncoderValidatorTestsData.FFmpegV431Output, true)]
|
||||
[InlineData(EncoderValidatorTestsData.FFmpegV43Output, true)]
|
||||
[InlineData(EncoderValidatorTestsData.FFmpegV421Output, true)]
|
||||
@@ -28,14 +31,15 @@ namespace Jellyfin.MediaEncoding.Tests
|
||||
[InlineData(EncoderValidatorTestsData.FFmpegGitUnknownOutput, false)]
|
||||
public void ValidateVersionInternalTest(string versionOutput, bool valid)
|
||||
{
|
||||
var val = new EncoderValidator(new NullLogger<EncoderValidatorTests>());
|
||||
Assert.Equal(valid, val.ValidateVersionInternal(versionOutput));
|
||||
Assert.Equal(valid, _encoderValidator.ValidateVersionInternal(versionOutput));
|
||||
}
|
||||
|
||||
private class GetFFmpegVersionTestData : IEnumerable<object?[]>
|
||||
{
|
||||
public IEnumerator<object?[]> GetEnumerator()
|
||||
{
|
||||
yield return new object?[] { EncoderValidatorTestsData.FFmpegV44Output, new Version(4, 4) };
|
||||
yield return new object?[] { EncoderValidatorTestsData.FFmpegV432Output, new Version(4, 3, 2) };
|
||||
yield return new object?[] { EncoderValidatorTestsData.FFmpegV431Output, new Version(4, 3, 1) };
|
||||
yield return new object?[] { EncoderValidatorTestsData.FFmpegV43Output, new Version(4, 3) };
|
||||
yield return new object?[] { EncoderValidatorTestsData.FFmpegV421Output, new Version(4, 2, 1) };
|
||||
|
||||
@@ -2,6 +2,30 @@ namespace Jellyfin.MediaEncoding.Tests
|
||||
{
|
||||
internal static class EncoderValidatorTestsData
|
||||
{
|
||||
public const string FFmpegV44Output = @"ffmpeg version 4.4-Jellyfin Copyright (c) 2000-2021 the FFmpeg developers
|
||||
built with gcc 10.3.0 (Rev5, Built by MSYS2 project)
|
||||
configuration: --disable-static --enable-shared --extra-version=Jellyfin --disable-ffplay --disable-debug --enable-gpl --enable-version3 --enable-bzlib --enable-iconv --enable-lzma --enable-zlib --enable-sdl2 --enable-fontconfig --enable-gmp --enable-libass --enable-libzimg --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d --enable-opencl --enable-dxva2 --enable-d3d11va --enable-amf --enable-libmfx --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvenc --enable-nvdec --enable-ffnvcodec --enable-gnutls
|
||||
libavutil 56. 70.100 / 56. 70.100
|
||||
libavcodec 58.134.100 / 58.134.100
|
||||
libavformat 58. 76.100 / 58. 76.100
|
||||
libavdevice 58. 13.100 / 58. 13.100
|
||||
libavfilter 7.110.100 / 7.110.100
|
||||
libswscale 5. 9.100 / 5. 9.100
|
||||
libswresample 3. 9.100 / 3. 9.100
|
||||
libpostproc 55. 9.100 / 55. 9.100";
|
||||
|
||||
public const string FFmpegV432Output = @"ffmpeg version n4.3.2-Jellyfin Copyright (c) 2000-2021 the FFmpeg developers
|
||||
built with gcc 10.2.0 (Rev9, Built by MSYS2 project)
|
||||
configuration: --disable-static --enable-shared --cc='ccache gcc' --cxx='ccache g++' --extra-version=Jellyfin --disable-ffplay --disable-debug --enable-lto --enable-gpl --enable-version3 --enable-bzlib --enable-iconv --enable-lzma --enable-zlib --enable-sdl2 --enable-fontconfig --enable-gmp --enable-libass --enable-libzimg --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libdav1d --enable-opencl --enable-dxva2 --enable-d3d11va --enable-amf --enable-libmfx --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvenc --enable-nvdec --enable-ffnvcodec --enable-gnutls
|
||||
libavutil 56. 51.100 / 56. 51.100
|
||||
libavcodec 58. 91.100 / 58. 91.100
|
||||
libavformat 58. 45.100 / 58. 45.100
|
||||
libavdevice 58. 10.100 / 58. 10.100
|
||||
libavfilter 7. 85.100 / 7. 85.100
|
||||
libswscale 5. 7.100 / 5. 7.100
|
||||
libswresample 3. 7.100 / 3. 7.100
|
||||
libpostproc 55. 7.100 / 55. 7.100";
|
||||
|
||||
public const string FFmpegV431Output = @"ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
|
||||
built with gcc 10.1.0 (GCC)
|
||||
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0" />
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Text.Json;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using MediaBrowser.MediaEncoding.Probing;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
@@ -91,5 +92,38 @@ namespace Jellyfin.MediaEncoding.Tests.Probing
|
||||
Assert.Contains("Pop", res.Genres);
|
||||
Assert.Contains("Jazz", res.Genres);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMediaInfo_Music_Success()
|
||||
{
|
||||
var bytes = File.ReadAllBytes("Test Data/Probing/music_metadata.json");
|
||||
var internalMediaInfoResult = JsonSerializer.Deserialize<InternalMediaInfoResult>(bytes, _jsonOptions);
|
||||
MediaInfo res = _probeResultNormalizer.GetMediaInfo(internalMediaInfoResult, null, true, "Test Data/Probing/music.flac", MediaProtocol.File);
|
||||
|
||||
Assert.Equal("UP NO MORE", res.Name);
|
||||
Assert.Single(res.Artists);
|
||||
Assert.Equal("TWICE", res.Artists[0]);
|
||||
Assert.Equal("Eyes wide open", res.Album);
|
||||
Assert.Equal(2020, res.ProductionYear);
|
||||
Assert.True(res.PremiereDate.HasValue);
|
||||
Assert.Equal(DateTime.Parse("2020-10-26T00:00Z", DateTimeFormatInfo.CurrentInfo).ToUniversalTime(), res.PremiereDate);
|
||||
Assert.Equal(22, res.People.Length);
|
||||
Assert.Equal("Krysta Youngs", res.People[0].Name);
|
||||
Assert.Equal(PersonType.Composer, res.People[0].Type);
|
||||
Assert.Equal("Julia Ross", res.People[1].Name);
|
||||
Assert.Equal(PersonType.Composer, res.People[1].Type);
|
||||
Assert.Equal("Yiwoomin", res.People[2].Name);
|
||||
Assert.Equal(PersonType.Composer, res.People[2].Type);
|
||||
Assert.Equal("Ji-hyo Park", res.People[3].Name);
|
||||
Assert.Equal(PersonType.Lyricist, res.People[3].Type);
|
||||
Assert.Equal("Yiwoomin", res.People[4].Name);
|
||||
Assert.Equal(PersonType.Actor, res.People[4].Type);
|
||||
Assert.Equal("Electric Piano", res.People[4].Role);
|
||||
Assert.Equal(4, res.Genres.Length);
|
||||
Assert.Contains("Electronic", res.Genres);
|
||||
Assert.Contains("Trance", res.Genres);
|
||||
Assert.Contains("Dance", res.Genres);
|
||||
Assert.Contains("Jazz", res.Genres);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
{
|
||||
"streams": [
|
||||
{
|
||||
"index": 0,
|
||||
"codec_name": "flac",
|
||||
"codec_long_name": "FLAC (Free Lossless Audio Codec)",
|
||||
"codec_type": "audio",
|
||||
"codec_tag_string": "[0][0][0][0]",
|
||||
"codec_tag": "0x0000",
|
||||
"sample_fmt": "s16",
|
||||
"sample_rate": "44100",
|
||||
"channels": 2,
|
||||
"channel_layout": "stereo",
|
||||
"bits_per_sample": 0,
|
||||
"r_frame_rate": "0/0",
|
||||
"avg_frame_rate": "0/0",
|
||||
"time_base": "1/44100",
|
||||
"start_pts": 0,
|
||||
"start_time": "0.000000",
|
||||
"duration_ts": 9447984,
|
||||
"duration": "214.240000",
|
||||
"bits_per_raw_sample": "16",
|
||||
"disposition": {
|
||||
"default": 0,
|
||||
"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
|
||||
}
|
||||
},
|
||||
{
|
||||
"index": 1,
|
||||
"codec_name": "mjpeg",
|
||||
"codec_long_name": "Motion JPEG",
|
||||
"profile": "Baseline",
|
||||
"codec_type": "video",
|
||||
"codec_tag_string": "[0][0][0][0]",
|
||||
"codec_tag": "0x0000",
|
||||
"width": 500,
|
||||
"height": 500,
|
||||
"coded_width": 500,
|
||||
"coded_height": 500,
|
||||
"closed_captions": 0,
|
||||
"has_b_frames": 0,
|
||||
"sample_aspect_ratio": "1:1",
|
||||
"display_aspect_ratio": "1:1",
|
||||
"pix_fmt": "yuvj420p",
|
||||
"level": -99,
|
||||
"color_range": "pc",
|
||||
"color_space": "bt470bg",
|
||||
"chroma_location": "center",
|
||||
"refs": 1,
|
||||
"r_frame_rate": "90000/1",
|
||||
"avg_frame_rate": "0/0",
|
||||
"time_base": "1/90000",
|
||||
"start_pts": 0,
|
||||
"start_time": "0.000000",
|
||||
"duration_ts": 19281600,
|
||||
"duration": "214.240000",
|
||||
"bits_per_raw_sample": "8",
|
||||
"disposition": {
|
||||
"default": 0,
|
||||
"dub": 0,
|
||||
"original": 0,
|
||||
"comment": 0,
|
||||
"lyrics": 0,
|
||||
"karaoke": 0,
|
||||
"forced": 0,
|
||||
"hearing_impaired": 0,
|
||||
"visual_impaired": 0,
|
||||
"clean_effects": 0,
|
||||
"attached_pic": 1,
|
||||
"timed_thumbnails": 0
|
||||
},
|
||||
"tags": {
|
||||
"comment": "Cover (front)"
|
||||
}
|
||||
}
|
||||
],
|
||||
"format": {
|
||||
"filename": "03 UP NO MORE.flac",
|
||||
"nb_streams": 2,
|
||||
"nb_programs": 0,
|
||||
"format_name": "flac",
|
||||
"format_long_name": "raw FLAC",
|
||||
"start_time": "0.000000",
|
||||
"duration": "214.240000",
|
||||
"size": "28714641",
|
||||
"bit_rate": "1072242",
|
||||
"probe_score": 100,
|
||||
"tags": {
|
||||
"MUSICBRAINZ_RELEASEGROUPID": "aa05ff10-8589-4c9c-a0d4-6b024f4e4556",
|
||||
"ORIGINALDATE": "2020-10-26",
|
||||
"ORIGINALYEAR": "2020",
|
||||
"RELEASETYPE": "album",
|
||||
"MUSICBRAINZ_ALBUMID": "222e6610-75c9-400e-8dc3-bb61f9fc5ca7",
|
||||
"SCRIPT": "Latn",
|
||||
"ALBUM": "Eyes wide open",
|
||||
"RELEASECOUNTRY": "JP",
|
||||
"BARCODE": "190295105280",
|
||||
"LABEL": "JYP Entertainment",
|
||||
"RELEASESTATUS": "official",
|
||||
"DATE": "2020-10-26",
|
||||
"MUSICBRAINZ_ALBUMARTISTID": "8da127cc-c432-418f-b356-ef36210d82ac",
|
||||
"album_artist": "TWICE",
|
||||
"ALBUMARTISTSORT": "TWICE",
|
||||
"TOTALDISCS": "1",
|
||||
"TOTALTRACKS": "13",
|
||||
"MEDIA": "Digital Media",
|
||||
"disc": "1",
|
||||
"MUSICBRAINZ_TRACKID": "7d1a1044-b564-480d-9df3-22f9656fdb97",
|
||||
"TITLE": "UP NO MORE",
|
||||
"ISRC": "US5TA2000136",
|
||||
"PERFORMER": "Yiwoomin (electric piano);Yiwoomin (synthesizer);Yiwoomin (bass);Yiwoomin (guitar);TWICE;Tzu-yu Chou (vocals);Momo Hirai (vocals);Na-yeon Im (vocals);Da-hyun Kim (vocals);Sana Minatozaki (vocals);Mina Myoui (vocals);Ji-hyo Park (vocals);Chae-young Son (vocals);Jeong-yeon Yoo (vocals);Perrie (background vocals)",
|
||||
"MIXER": "Bong Won Shin",
|
||||
"ARRANGER": "Krysta Youngs;Julia Ross;Yiwoomin",
|
||||
"MUSICBRAINZ_WORKID": "02b37083-0337-4721-9f17-bf31971043e8",
|
||||
"LANGUAGE": "kor;eng",
|
||||
"WORK": "Up No More",
|
||||
"COMPOSER": "Krysta Youngs;Julia Ross;Yiwoomin",
|
||||
"COMPOSERSORT": "Krysta Youngs;Ross, Julia;Yiwoomin",
|
||||
"LYRICIST": "Ji-hyo Park",
|
||||
"MUSICBRAINZ_ARTISTID": "8da127cc-c432-418f-b356-ef36210d82ac",
|
||||
"ARTIST": "TWICE",
|
||||
"ARTISTSORT": "TWICE",
|
||||
"ARTISTS": "TWICE",
|
||||
"MUSICBRAINZ_RELEASETRACKID": "ad49b840-da9e-4e7c-924b-29fdee187052",
|
||||
"track": "3",
|
||||
"GENRE": "Electronic;Trance;Dance;Jazz",
|
||||
"WEBSITE": "http://twice.jype.com/;http://www.twicejapan.com/",
|
||||
"ACOUSTID_ID": "aae2e972-108c-4d0c-8e31-9d078283e3dc",
|
||||
"MOOD": "Not acoustic;Not aggressive;Electronic;Happy;Party;Not relaxed;Not sad",
|
||||
"TRACKTOTAL": "13",
|
||||
"DISCTOTAL": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using Xunit;
|
||||
|
||||
@@ -5,6 +6,85 @@ namespace Jellyfin.Model.Tests.Entities
|
||||
{
|
||||
public class MediaStreamTests
|
||||
{
|
||||
public static IEnumerable<object[]> Get_DisplayTitle_TestData()
|
||||
{
|
||||
return new List<object[]>
|
||||
{
|
||||
new object[]
|
||||
{
|
||||
new MediaStream
|
||||
{
|
||||
Type = MediaStreamType.Subtitle,
|
||||
Title = "English",
|
||||
Language = string.Empty,
|
||||
IsForced = false,
|
||||
IsDefault = false,
|
||||
Codec = "ASS"
|
||||
},
|
||||
"English - Und - ASS"
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
new MediaStream
|
||||
{
|
||||
Type = MediaStreamType.Subtitle,
|
||||
Title = "English",
|
||||
Language = string.Empty,
|
||||
IsForced = false,
|
||||
IsDefault = false,
|
||||
Codec = string.Empty
|
||||
},
|
||||
"English - Und"
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
new MediaStream
|
||||
{
|
||||
Type = MediaStreamType.Subtitle,
|
||||
Title = "English",
|
||||
Language = "EN",
|
||||
IsForced = false,
|
||||
IsDefault = false,
|
||||
Codec = string.Empty
|
||||
},
|
||||
"English"
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
new MediaStream
|
||||
{
|
||||
Type = MediaStreamType.Subtitle,
|
||||
Title = "English",
|
||||
Language = "EN",
|
||||
IsForced = true,
|
||||
IsDefault = true,
|
||||
Codec = "SRT"
|
||||
},
|
||||
"English - Default - Forced - SRT"
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
new MediaStream
|
||||
{
|
||||
Type = MediaStreamType.Subtitle,
|
||||
Title = null,
|
||||
Language = null,
|
||||
IsForced = false,
|
||||
IsDefault = false,
|
||||
Codec = null
|
||||
},
|
||||
"Und"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(Get_DisplayTitle_TestData))]
|
||||
public void Get_DisplayTitle_should_return_valid_title(MediaStream mediaStream, string expected)
|
||||
{
|
||||
Assert.Equal(expected, mediaStream.DisplayTitle);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null, false, null)]
|
||||
[InlineData(null, 0, false, null)]
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0" />
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.15.3" />
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.16.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Code Analyzers -->
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0" />
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0" />
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.15.3" />
|
||||
<PackageReference Include="FsCheck.Xunit" Version="2.16.1" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
|
||||
@@ -109,6 +109,9 @@ namespace Jellyfin.Server.Implementations.Tests.Data
|
||||
[InlineData("")]
|
||||
[InlineData("*")]
|
||||
[InlineData("https://image.tmdb.org/t/p/original/zhB5CHEgqqh4wnEqDNJLfWXJlcL.jpg*0")]
|
||||
[InlineData("/mnt/series/Family Guy/Season 1/Family Guy - S01E01-thumb.jpg*6374520964785129080*WjQbtJtSO8nhNZ%L_Io#R/oaS<o}-;adXAoIn7j[%hW9s:WGw[nN")] // Invalid modified date
|
||||
[InlineData("/mnt/series/Family Guy/Season 1/Family Guy - S01E01-thumb.jpg*-637452096478512963*WjQbtJtSO8nhNZ%L_Io#R/oaS<o}-;adXAoIn7j[%hW9s:WGw[nN")] // Negative modified date
|
||||
[InlineData("/mnt/series/Family Guy/Season 1/Family Guy - S01E01-thumb.jpg*637452096478512963*Invalid*1920*1080*WjQbtJtSO8nhNZ%L_Io#R/oaS6o}-;adXAoIn7j[%hW9s:WGw[nN")] // Invalid type
|
||||
public void ItemImageInfoFromValueString_Invalid_Null(string value)
|
||||
{
|
||||
Assert.Null(_sqliteItemRepository.ItemImageInfoFromValueString(value));
|
||||
|
||||
@@ -21,7 +21,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.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
|
||||
var germany = localizationManager.FindLanguageInfo(identifier);
|
||||
Assert.NotNull(germany);
|
||||
|
||||
Assert.Equal("ger", germany.ThreeLetterISOLanguageName);
|
||||
Assert.Equal("ger", germany!.ThreeLetterISOLanguageName);
|
||||
Assert.Equal("German", germany.DisplayName);
|
||||
Assert.Equal("German", germany.Name);
|
||||
Assert.Contains("deu", germany.ThreeLetterISOLanguageNames);
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Emby.Server.Implementations.Sorting;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Server.Implementations.Tests.Sorting
|
||||
{
|
||||
public class AiredEpisodeOrderComparerTests
|
||||
{
|
||||
[Theory]
|
||||
[ClassData(typeof(EpisodeBadData))]
|
||||
public void Compare_GivenNull_ThrowsArgumentNullException(BaseItem x, BaseItem y)
|
||||
{
|
||||
var cmp = new AiredEpisodeOrderComparer();
|
||||
Assert.Throws<ArgumentNullException>(() => cmp.Compare(x, y));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[ClassData(typeof(EpisodeTestData))]
|
||||
public void AiredEpisodeOrderCompareTest(BaseItem x, BaseItem y, int expected)
|
||||
{
|
||||
var cmp = new AiredEpisodeOrderComparer();
|
||||
|
||||
Assert.Equal(expected, cmp.Compare(x, y));
|
||||
Assert.Equal(-expected, cmp.Compare(y, x));
|
||||
}
|
||||
|
||||
private class EpisodeBadData : IEnumerable<object?[]>
|
||||
{
|
||||
public IEnumerator<object?[]> GetEnumerator()
|
||||
{
|
||||
yield return new object?[] { null, new Episode() };
|
||||
yield return new object?[] { new Episode(), null };
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
|
||||
private class EpisodeTestData : IEnumerable<object?[]>
|
||||
{
|
||||
public IEnumerator<object?[]> GetEnumerator()
|
||||
{
|
||||
yield return new object?[]
|
||||
{
|
||||
new Movie(),
|
||||
new Movie(),
|
||||
0
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Movie(),
|
||||
new Episode(),
|
||||
1
|
||||
};
|
||||
// Good cases
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode(),
|
||||
new Episode(),
|
||||
0
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
||||
0
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 2 },
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
||||
1
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 2, IndexNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
||||
1
|
||||
};
|
||||
// Good Specials
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
||||
0
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 2 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
||||
1
|
||||
};
|
||||
|
||||
// Specials to Episodes
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
||||
1
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 2 },
|
||||
1
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 2 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
||||
1
|
||||
};
|
||||
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 2 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
||||
1
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 2 },
|
||||
1
|
||||
};
|
||||
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsAfterSeasonNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
||||
1
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 3, IndexNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsAfterSeasonNumber = 1 },
|
||||
1
|
||||
};
|
||||
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 3, IndexNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsAfterSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
||||
1
|
||||
};
|
||||
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1 },
|
||||
1
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 2 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
||||
1
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
||||
0
|
||||
};
|
||||
yield return new object?[]
|
||||
{
|
||||
new Episode { ParentIndexNumber = 1, IndexNumber = 3 },
|
||||
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
||||
1
|
||||
};
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Server.Implementations.Tests.TypedBaseItem
|
||||
{
|
||||
public class BaseItemKindTests
|
||||
{
|
||||
public static TheoryData<Type> BaseItemKind_TestData()
|
||||
{
|
||||
var data = new TheoryData<Type>();
|
||||
|
||||
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
foreach (var assembly in loadedAssemblies)
|
||||
{
|
||||
if (IsProjectAssemblyName(assembly.FullName))
|
||||
{
|
||||
var baseItemTypes = assembly.GetTypes()
|
||||
.Where(targetType => targetType.IsClass
|
||||
&& !targetType.IsAbstract
|
||||
&& targetType.IsSubclassOf(typeof(MediaBrowser.Controller.Entities.BaseItem)));
|
||||
foreach (var baseItemType in baseItemTypes)
|
||||
{
|
||||
data.Add(baseItemType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(BaseItemKind_TestData))]
|
||||
public void EnumParse_GivenValidBaseItemType_ReturnsEnumValue(Type baseItemDescendantType)
|
||||
{
|
||||
var enumValue = Enum.Parse<BaseItemKind>(baseItemDescendantType.Name);
|
||||
Assert.True(Enum.IsDefined(typeof(BaseItemKind), enumValue));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(BaseItemKind_TestData))]
|
||||
public void GetBaseItemKind_WhenCalledAfterDefaultCtor_DoesNotThrow(Type baseItemDescendantType)
|
||||
{
|
||||
var defaultConstructor = baseItemDescendantType.GetConstructor(Type.EmptyTypes);
|
||||
var instance = (MediaBrowser.Controller.Entities.BaseItem)defaultConstructor!.Invoke(null);
|
||||
var exception = Record.Exception(() => instance.GetBaseItemKind());
|
||||
Assert.Null(exception);
|
||||
}
|
||||
|
||||
private static bool IsProjectAssemblyName(string? name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return name.StartsWith("Jellyfin", StringComparison.OrdinalIgnoreCase)
|
||||
|| name.StartsWith("Emby", StringComparison.OrdinalIgnoreCase)
|
||||
|| name.StartsWith("MediaBrowser", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Mime;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Api.Models.LibraryStructureDto;
|
||||
using Jellyfin.Extensions.Json;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||
{
|
||||
public sealed class MediaStructureControllerTests : IClassFixture<JellyfinApplicationFactory>
|
||||
{
|
||||
private readonly JellyfinApplicationFactory _factory;
|
||||
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
|
||||
private static string? _accessToken;
|
||||
|
||||
public MediaStructureControllerTests(JellyfinApplicationFactory factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RenameVirtualFolder_WhiteSpaceName_ReturnsBadRequest()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||
|
||||
using var postContent = new ByteArrayContent(Array.Empty<byte>());
|
||||
var response = await client.PostAsync("Library/VirtualFolders/Name?name=+&newName=test", postContent).ConfigureAwait(false);
|
||||
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RenameVirtualFolder_WhiteSpaceNewName_ReturnsBadRequest()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||
|
||||
using var postContent = new ByteArrayContent(Array.Empty<byte>());
|
||||
var response = await client.PostAsync("Library/VirtualFolders/Name?name=test&newName=+", postContent).ConfigureAwait(false);
|
||||
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RenameVirtualFolder_NameDoesntExist_ReturnsNotFound()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||
|
||||
using var postContent = new ByteArrayContent(Array.Empty<byte>());
|
||||
var response = await client.PostAsync("Library/VirtualFolders/Name?name=doesnt+exist&newName=test", postContent).ConfigureAwait(false);
|
||||
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddMediaPath_PathDoesntExist_ReturnsNotFound()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||
|
||||
var data = new MediaPathDto()
|
||||
{
|
||||
Name = "Test",
|
||||
Path = "/this/path/doesnt/exist"
|
||||
};
|
||||
|
||||
using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(data, _jsonOptions));
|
||||
postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
||||
var response = await client.PostAsync("Library/VirtualFolders/Paths", postContent).ConfigureAwait(false);
|
||||
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateMediaPath_WhiteSpaceName_ReturnsBadRequest()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||
|
||||
var data = new UpdateMediaPathRequestDto()
|
||||
{
|
||||
Name = " ",
|
||||
PathInfo = new MediaPathInfo("test")
|
||||
};
|
||||
|
||||
using var postContent = new ByteArrayContent(JsonSerializer.SerializeToUtf8Bytes(data, _jsonOptions));
|
||||
postContent.Headers.ContentType = MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Json);
|
||||
var response = await client.PostAsync("Library/VirtualFolders/Paths/Update", postContent).ConfigureAwait(false);
|
||||
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RemoveMediaPath_WhiteSpaceName_ReturnsBadRequest()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||
|
||||
var response = await client.DeleteAsync("Library/VirtualFolders/Paths?name=+").ConfigureAwait(false);
|
||||
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RemoveMediaPath_PathDoesntExist_ReturnsNotFound()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||
|
||||
var response = await client.DeleteAsync("Library/VirtualFolders/Paths?name=none&path=%2Fthis%2Fpath%2Fdoesnt%2Fexist").ConfigureAwait(false);
|
||||
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,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.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.9" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.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" />
|
||||
|
||||
@@ -10,9 +10,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.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.9" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0" />
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Jellyfin.Networking.Configuration;
|
||||
using Jellyfin.Networking.Manager;
|
||||
using Jellyfin.Server.Extensions;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
@@ -13,20 +18,63 @@ namespace Jellyfin.Server.Tests
|
||||
{
|
||||
public class ParseNetworkTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Order of the result has always got to be hosts, then networks.
|
||||
/// </summary>
|
||||
/// <param name="ip4">IP4 enabled.</param>
|
||||
/// <param name="ip6">IP6 enabled.</param>
|
||||
/// <param name="hostList">List to parse.</param>
|
||||
/// <param name="match">What it should match.</param>
|
||||
public static TheoryData<bool, bool, string[], IPAddress[], IPNetwork[]> TestNetworks_TestData()
|
||||
{
|
||||
var data = new TheoryData<bool, bool, string[], IPAddress[], IPNetwork[]>();
|
||||
data.Add(
|
||||
true,
|
||||
true,
|
||||
new string[] { "192.168.t", "127.0.0.1", "1234.1232.12.1234" },
|
||||
new IPAddress[] { IPAddress.Loopback.MapToIPv6() },
|
||||
Array.Empty<IPNetwork>());
|
||||
|
||||
data.Add(
|
||||
true,
|
||||
false,
|
||||
new string[] { "192.168.x", "127.0.0.1", "1234.1232.12.1234" },
|
||||
new IPAddress[] { IPAddress.Loopback },
|
||||
Array.Empty<IPNetwork>());
|
||||
|
||||
data.Add(
|
||||
true,
|
||||
true,
|
||||
new string[] { "::1" },
|
||||
Array.Empty<IPAddress>(),
|
||||
new IPNetwork[] { new IPNetwork(IPAddress.IPv6Loopback, 128) });
|
||||
|
||||
data.Add(
|
||||
false,
|
||||
false,
|
||||
new string[] { "localhost" },
|
||||
Array.Empty<IPAddress>(),
|
||||
Array.Empty<IPNetwork>());
|
||||
|
||||
data.Add(
|
||||
true,
|
||||
false,
|
||||
new string[] { "localhost" },
|
||||
new IPAddress[] { IPAddress.Loopback },
|
||||
Array.Empty<IPNetwork>());
|
||||
|
||||
data.Add(
|
||||
false,
|
||||
true,
|
||||
new string[] { "localhost" },
|
||||
Array.Empty<IPAddress>(),
|
||||
new IPNetwork[] { new IPNetwork(IPAddress.IPv6Loopback, 128) });
|
||||
|
||||
data.Add(
|
||||
true,
|
||||
true,
|
||||
new string[] { "localhost" },
|
||||
new IPAddress[] { IPAddress.Loopback.MapToIPv6() },
|
||||
new IPNetwork[] { new IPNetwork(IPAddress.IPv6Loopback, 128) });
|
||||
return data;
|
||||
}
|
||||
|
||||
[Theory]
|
||||
// [InlineData(true, true, "192.168.0.0/16,www.yahoo.co.uk", "::ffff:212.82.100.150,::ffff:192.168.0.0/16")] <- fails on Max. www.yahoo.co.uk resolves to a different ip address.
|
||||
// [InlineData(true, false, "192.168.0.0/16,www.yahoo.co.uk", "212.82.100.150,192.168.0.0/16")]
|
||||
[InlineData(true, true, "192.168.t,127.0.0.1,1234.1232.12.1234", "::ffff:127.0.0.1")]
|
||||
[InlineData(true, false, "192.168.x,127.0.0.1,1234.1232.12.1234", "127.0.0.1")]
|
||||
[InlineData(true, true, "::1", "::1/128")]
|
||||
public void TestNetworks(bool ip4, bool ip6, string hostList, string match)
|
||||
[MemberData(nameof(TestNetworks_TestData))]
|
||||
public void TestNetworks(bool ip4, bool ip6, string[] hostList, IPAddress[] knownProxies, IPNetwork[] knownNetworks)
|
||||
{
|
||||
using var nm = CreateNetworkManager();
|
||||
|
||||
@@ -36,31 +84,25 @@ namespace Jellyfin.Server.Tests
|
||||
EnableIPV6 = ip6
|
||||
};
|
||||
|
||||
var result = match + ",";
|
||||
ForwardedHeadersOptions options = new ForwardedHeadersOptions();
|
||||
|
||||
// Need this here as ::1 and 127.0.0.1 are in them by default.
|
||||
options.KnownProxies.Clear();
|
||||
options.KnownNetworks.Clear();
|
||||
|
||||
ApiServiceCollectionExtensions.AddProxyAddresses(settings, hostList.Split(','), options);
|
||||
ApiServiceCollectionExtensions.AddProxyAddresses(settings, hostList, options);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
foreach (var item in options.KnownProxies)
|
||||
Assert.Equal(knownProxies.Length, options.KnownProxies.Count);
|
||||
foreach (var item in knownProxies)
|
||||
{
|
||||
sb.Append(item)
|
||||
.Append(',');
|
||||
Assert.True(options.KnownProxies.Contains(item));
|
||||
}
|
||||
|
||||
foreach (var item in options.KnownNetworks)
|
||||
Assert.Equal(knownNetworks.Length, options.KnownNetworks.Count);
|
||||
foreach (var item in knownNetworks)
|
||||
{
|
||||
sb.Append(item.Prefix)
|
||||
.Append('/')
|
||||
.Append(item.PrefixLength.ToString(CultureInfo.InvariantCulture))
|
||||
.Append(',');
|
||||
Assert.NotNull(options.KnownNetworks.FirstOrDefault(x => x.Prefix.Equals(item.Prefix) && x.PrefixLength == item.PrefixLength));
|
||||
}
|
||||
|
||||
Assert.Equal(sb.ToString(), result);
|
||||
}
|
||||
|
||||
private static IConfigurationManager GetMockConfig(NetworkConfiguration conf)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
|
||||
|
||||
@@ -207,6 +207,20 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
|
||||
Assert.Equal(id, item.ProviderIds[provider]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parse_GivenFileWithFanartTag_Success()
|
||||
{
|
||||
var result = new MetadataResult<Video>()
|
||||
{
|
||||
Item = new Movie()
|
||||
};
|
||||
|
||||
_parser.Fetch(result, "Test Data/Fanart.nfo", CancellationToken.None);
|
||||
|
||||
Assert.Single(result.RemoteImages.Where(x => x.type == ImageType.Backdrop));
|
||||
Assert.Equal("https://assets.fanart.tv/fanart/movies/141052/moviebackground/justice-league-5a5332c7b5e77.jpg", result.RemoteImages.First(x => x.type == ImageType.Backdrop).url);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parse_RadarrUrlFile_Success()
|
||||
{
|
||||
|
||||
33
tests/Jellyfin.XbmcMetadata.Tests/Test Data/Fanart.nfo
Normal file
33
tests/Jellyfin.XbmcMetadata.Tests/Test Data/Fanart.nfo
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<movie>
|
||||
<thumb aspect="clearlogo" preview="https://assets.fanart.tv/preview/movies/141052/hdmovielogo/justice-league-5865bf95cbadb.png">https://assets.fanart.tv/fanart/movies/141052/hdmovielogo/justice-league-5865bf95cbadb.png</thumb>
|
||||
<thumb aspect="clearlogo" preview="https://assets.fanart.tv/preview/movies/141052/hdmovielogo/justice-league-585e9ca3bcf6a.png">https://assets.fanart.tv/fanart/movies/141052/hdmovielogo/justice-league-585e9ca3bcf6a.png</thumb>
|
||||
<thumb aspect="clearlogo" preview="https://assets.fanart.tv/preview/movies/141052/hdmovielogo/justice-league-57b476a831d74.png">https://assets.fanart.tv/fanart/movies/141052/hdmovielogo/justice-league-57b476a831d74.png</thumb>
|
||||
<thumb aspect="clearlogo" preview="https://assets.fanart.tv/preview/movies/141052/hdmovielogo/justice-league-57947e28cf10b.png">https://assets.fanart.tv/fanart/movies/141052/hdmovielogo/justice-league-57947e28cf10b.png</thumb>
|
||||
<thumb aspect="clearlogo" preview="https://assets.fanart.tv/preview/movies/141052/hdmovielogo/justice-league-5863d5c0cf0c9.png">https://assets.fanart.tv/fanart/movies/141052/hdmovielogo/justice-league-5863d5c0cf0c9.png</thumb>
|
||||
<thumb aspect="clearlogo" preview="https://assets.fanart.tv/preview/movies/141052/hdmovielogo/justice-league-5a801747e5545.png">https://assets.fanart.tv/fanart/movies/141052/hdmovielogo/justice-league-5a801747e5545.png</thumb>
|
||||
<thumb aspect="clearlogo" preview="https://assets.fanart.tv/preview/movies/141052/hdmovielogo/justice-league-5cd75683df92b.png">https://assets.fanart.tv/fanart/movies/141052/hdmovielogo/justice-league-5cd75683df92b.png</thumb>
|
||||
<thumb aspect="banner" preview="https://assets.fanart.tv/preview/movies/141052/moviebanner/justice-league-586017e95adbd.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebanner/justice-league-586017e95adbd.jpg</thumb>
|
||||
<thumb aspect="banner" preview="https://assets.fanart.tv/preview/movies/141052/moviebanner/justice-league-5934d45bc6592.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebanner/justice-league-5934d45bc6592.jpg</thumb>
|
||||
<thumb aspect="banner" preview="https://assets.fanart.tv/preview/movies/141052/moviebanner/justice-league-5aa9289a379fa.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebanner/justice-league-5aa9289a379fa.jpg</thumb>
|
||||
<thumb aspect="landscape" preview="https://assets.fanart.tv/preview/movies/141052/moviethumb/justice-league-585fb155c3743.jpg">https://assets.fanart.tv/fanart/movies/141052/moviethumb/justice-league-585fb155c3743.jpg</thumb>
|
||||
<thumb aspect="landscape" preview="https://assets.fanart.tv/preview/movies/141052/moviethumb/justice-league-585edbda91d82.jpg">https://assets.fanart.tv/fanart/movies/141052/moviethumb/justice-league-585edbda91d82.jpg</thumb>
|
||||
<thumb aspect="landscape" preview="https://assets.fanart.tv/preview/movies/141052/moviethumb/justice-league-5b86588882c12.jpg">https://assets.fanart.tv/fanart/movies/141052/moviethumb/justice-league-5b86588882c12.jpg</thumb>
|
||||
<thumb aspect="landscape" preview="https://assets.fanart.tv/preview/movies/141052/moviethumb/justice-league-5bbb9babe600c.jpg">https://assets.fanart.tv/fanart/movies/141052/moviethumb/justice-league-5bbb9babe600c.jpg</thumb>
|
||||
<thumb aspect="clearart" preview="https://assets.fanart.tv/preview/movies/141052/hdmovieclearart/justice-league-5865c23193041.png">https://assets.fanart.tv/fanart/movies/141052/hdmovieclearart/justice-league-5865c23193041.png</thumb>
|
||||
<thumb aspect="discart" preview="https://assets.fanart.tv/preview/movies/141052/moviedisc/justice-league-5a3af26360617.png">https://assets.fanart.tv/fanart/movies/141052/moviedisc/justice-league-5a3af26360617.png</thumb>
|
||||
<thumb aspect="discart" preview="https://assets.fanart.tv/preview/movies/141052/moviedisc/justice-league-58690967b9765.png">https://assets.fanart.tv/fanart/movies/141052/moviedisc/justice-league-58690967b9765.png</thumb>
|
||||
<thumb aspect="discart" preview="https://assets.fanart.tv/preview/movies/141052/moviedisc/justice-league-5a953ca4db6a6.png">https://assets.fanart.tv/fanart/movies/141052/moviedisc/justice-league-5a953ca4db6a6.png</thumb>
|
||||
<thumb aspect="discart" preview="https://assets.fanart.tv/preview/movies/141052/moviedisc/justice-league-5a0b913c233be.png">https://assets.fanart.tv/fanart/movies/141052/moviedisc/justice-league-5a0b913c233be.png</thumb>
|
||||
<thumb aspect="discart" preview="https://assets.fanart.tv/preview/movies/141052/moviedisc/justice-league-5a87e0cdb1209.png">https://assets.fanart.tv/fanart/movies/141052/moviedisc/justice-league-5a87e0cdb1209.png</thumb>
|
||||
<thumb aspect="discart" preview="https://assets.fanart.tv/preview/movies/141052/moviedisc/justice-league-59dc595362ef1.png">https://assets.fanart.tv/fanart/movies/141052/moviedisc/justice-league-59dc595362ef1.png</thumb>
|
||||
<fanart>
|
||||
<thumb preview="https://assets.fanart.tv/preview/movies/141052/moviebackground/justice-league-5a5332c7b5e77.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebackground/justice-league-5a5332c7b5e77.jpg</thumb>
|
||||
<thumb preview="https://assets.fanart.tv/preview/movies/141052/moviebackground/justice-league-5a53cf2dac1c8.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebackground/justice-league-5a53cf2dac1c8.jpg</thumb>
|
||||
<thumb preview="https://assets.fanart.tv/preview/movies/141052/moviebackground/justice-league-5976ba93eb5d3.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebackground/justice-league-5976ba93eb5d3.jpg</thumb>
|
||||
<thumb preview="https://assets.fanart.tv/preview/movies/141052/moviebackground/justice-league-58fa1f1932897.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebackground/justice-league-58fa1f1932897.jpg</thumb>
|
||||
<thumb preview="https://assets.fanart.tv/preview/movies/141052/moviebackground/justice-league-5a14f5fd8dd16.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebackground/justice-league-5a14f5fd8dd16.jpg</thumb>
|
||||
<thumb preview="https://assets.fanart.tv/preview/movies/141052/moviebackground/justice-league-5a119394ea362.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebackground/justice-league-5a119394ea362.jpg</thumb>
|
||||
</fanart>
|
||||
<thumb aspect="fanart">This-should-not-be-saved-as-a-fanart-image.jpg</thumb>
|
||||
</movie>
|
||||
Reference in New Issue
Block a user