# Conflicts: # Jellyfin.Api/Auth/SyncPlayAccessPolicy/SyncPlayAccessHandler.cspull/9282/head
commit
52e2776d8e
@ -0,0 +1,23 @@
|
|||||||
|
<Project>
|
||||||
|
<!-- Sets defaults for all test projects -->
|
||||||
|
|
||||||
|
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)/jellyfin-tests.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Code Analyzers -->
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="SerilogAnalyzer" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" PrivateAssets="All" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<tv date="20221104">
|
||||||
|
<programme channel="3297" start="20221104130000 -0400" stop="20221105235959 -0400">
|
||||||
|
<category lang="en" />
|
||||||
|
<category lang="en">sports</category>
|
||||||
|
</programme>
|
||||||
|
</tv>
|
@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Jellyfin.Extensions.Json;
|
||||||
|
using MediaBrowser.Model.Dto;
|
||||||
|
using MediaBrowser.Model.Querying;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Jellyfin.Server.Integration.Tests.Controllers;
|
||||||
|
|
||||||
|
public sealed class ItemsControllerTests : IClassFixture<JellyfinApplicationFactory>
|
||||||
|
{
|
||||||
|
private readonly JellyfinApplicationFactory _factory;
|
||||||
|
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
|
||||||
|
private static string? _accessToken;
|
||||||
|
|
||||||
|
public ItemsControllerTests(JellyfinApplicationFactory factory)
|
||||||
|
{
|
||||||
|
_factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetItems_NoApiKeyOrUserId_BadRequest()
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var response = await client.GetAsync("Items").ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("Users/{0}/Items")]
|
||||||
|
[InlineData("Users/{0}/Items/Resume")]
|
||||||
|
public async Task GetUserItems_NonExistentUserId_NotFound(string format)
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid())).ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("Items?userId={0}")]
|
||||||
|
[InlineData("Users/{0}/Items")]
|
||||||
|
[InlineData("Users/{0}/Items/Resume")]
|
||||||
|
public async Task GetItems_UserId_Ok(string format)
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, userDto.Id)).ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
var items = await JsonSerializer.DeserializeAsync<QueryResult<BaseItemDto>>(
|
||||||
|
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
||||||
|
_jsonOptions).ConfigureAwait(false);
|
||||||
|
Assert.NotNull(items);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Jellyfin.Server.Integration.Tests.Controllers;
|
||||||
|
|
||||||
|
public sealed class LibraryControllerTests : IClassFixture<JellyfinApplicationFactory>
|
||||||
|
{
|
||||||
|
private readonly JellyfinApplicationFactory _factory;
|
||||||
|
private static string? _accessToken;
|
||||||
|
|
||||||
|
public LibraryControllerTests(JellyfinApplicationFactory factory)
|
||||||
|
{
|
||||||
|
_factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("Items/{0}/File")]
|
||||||
|
[InlineData("Items/{0}/ThemeSongs")]
|
||||||
|
[InlineData("Items/{0}/ThemeVideos")]
|
||||||
|
[InlineData("Items/{0}/ThemeMedia")]
|
||||||
|
[InlineData("Items/{0}/Ancestors")]
|
||||||
|
[InlineData("Items/{0}/Download")]
|
||||||
|
[InlineData("Artists/{0}/Similar")]
|
||||||
|
[InlineData("Items/{0}/Similar")]
|
||||||
|
[InlineData("Albums/{0}/Similar")]
|
||||||
|
[InlineData("Shows/{0}/Similar")]
|
||||||
|
[InlineData("Movies/{0}/Similar")]
|
||||||
|
[InlineData("Trailers/{0}/Similar")]
|
||||||
|
public async Task Get_NonExistentItemId_NotFound(string format)
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid())).ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using System.Net;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Jellyfin.Server.Integration.Tests.Controllers;
|
||||||
|
|
||||||
|
public sealed class MusicGenreControllerTests : IClassFixture<JellyfinApplicationFactory>
|
||||||
|
{
|
||||||
|
private readonly JellyfinApplicationFactory _factory;
|
||||||
|
private static string? _accessToken;
|
||||||
|
|
||||||
|
public MusicGenreControllerTests(JellyfinApplicationFactory factory)
|
||||||
|
{
|
||||||
|
_factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task MusicGenres_FakeMusicGenre_NotFound()
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var response = await client.GetAsync("MusicGenres/Fake-MusicGenre").ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,129 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Jellyfin.Extensions.Json;
|
||||||
|
using MediaBrowser.Model.Dto;
|
||||||
|
using MediaBrowser.Model.Querying;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Jellyfin.Server.Integration.Tests.Controllers;
|
||||||
|
|
||||||
|
public sealed class UserLibraryControllerTests : IClassFixture<JellyfinApplicationFactory>
|
||||||
|
{
|
||||||
|
private readonly JellyfinApplicationFactory _factory;
|
||||||
|
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
|
||||||
|
private static string? _accessToken;
|
||||||
|
|
||||||
|
public UserLibraryControllerTests(JellyfinApplicationFactory factory)
|
||||||
|
{
|
||||||
|
_factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetRootFolder_NonExistenUserId_NotFound()
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var response = await client.GetAsync($"Users/{Guid.NewGuid()}/Items/Root").ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetRootFolder_UserId_Valid()
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
_ = await AuthHelper.GetRootFolderDtoAsync(client).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("Users/{0}/Items/{1}")]
|
||||||
|
[InlineData("Users/{0}/Items/{1}/Intros")]
|
||||||
|
[InlineData("Users/{0}/Items/{1}/LocalTrailers")]
|
||||||
|
[InlineData("Users/{0}/Items/{1}/SpecialFeatures")]
|
||||||
|
[InlineData("Users/{0}/Items/{1}/Lyrics")]
|
||||||
|
public async Task GetItem_NonExistenUserId_NotFound(string format)
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid(), rootFolderDto.Id)).ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("Users/{0}/Items/{1}")]
|
||||||
|
[InlineData("Users/{0}/Items/{1}/Intros")]
|
||||||
|
[InlineData("Users/{0}/Items/{1}/LocalTrailers")]
|
||||||
|
[InlineData("Users/{0}/Items/{1}/SpecialFeatures")]
|
||||||
|
[InlineData("Users/{0}/Items/{1}/Lyrics")]
|
||||||
|
public async Task GetItem_NonExistentItemId_NotFound(string format)
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, userDto.Id, Guid.NewGuid())).ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetItem_UserIdAndItemId_Valid()
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
||||||
|
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client, userDto.Id).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var response = await client.GetAsync($"Users/{userDto.Id}/Items/{rootFolderDto.Id}").ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
var rootDto = await JsonSerializer.DeserializeAsync<BaseItemDto>(
|
||||||
|
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
||||||
|
_jsonOptions).ConfigureAwait(false);
|
||||||
|
Assert.NotNull(rootDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetIntros_UserIdAndItemId_Valid()
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
||||||
|
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client, userDto.Id).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var response = await client.GetAsync($"Users/{userDto.Id}/Items/{rootFolderDto.Id}/Intros").ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
var rootDto = await JsonSerializer.DeserializeAsync<QueryResult<BaseItemDto>>(
|
||||||
|
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
||||||
|
_jsonOptions).ConfigureAwait(false);
|
||||||
|
Assert.NotNull(rootDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[InlineData("Users/{0}/Items/{1}/LocalTrailers")]
|
||||||
|
[InlineData("Users/{0}/Items/{1}/SpecialFeatures")]
|
||||||
|
public async Task LocalTrailersAndSpecialFeatures_UserIdAndItemId_Valid(string format)
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
||||||
|
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client, userDto.Id).ConfigureAwait(false);
|
||||||
|
|
||||||
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, userDto.Id, rootFolderDto.Id)).ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
var rootDto = await JsonSerializer.DeserializeAsync<BaseItemDto[]>(
|
||||||
|
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
||||||
|
_jsonOptions).ConfigureAwait(false);
|
||||||
|
Assert.NotNull(rootDto);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Jellyfin.Server.Integration.Tests.Controllers;
|
||||||
|
|
||||||
|
public sealed class VideosControllerTests : IClassFixture<JellyfinApplicationFactory>
|
||||||
|
{
|
||||||
|
private readonly JellyfinApplicationFactory _factory;
|
||||||
|
private static string? _accessToken;
|
||||||
|
|
||||||
|
public VideosControllerTests(JellyfinApplicationFactory factory)
|
||||||
|
{
|
||||||
|
_factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task DeleteAlternateSources_NonExistentItemId_NotFound()
|
||||||
|
{
|
||||||
|
var client = _factory.CreateClient();
|
||||||
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
||||||
|
|
||||||
|
var response = await client.DeleteAsync($"Videos/{Guid.NewGuid()}").ConfigureAwait(false);
|
||||||
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue