Fix xUnit1030: Do not call ConfigureAwait in test method
This commit is contained in:
parent
5669955aca
commit
03b6adf068
|
@ -97,7 +97,7 @@ namespace Jellyfin.MediaEncoding.Subtitles.Tests
|
||||||
{
|
{
|
||||||
var fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
|
var fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
|
||||||
var subtitleEncoder = fixture.Create<SubtitleEncoder>();
|
var subtitleEncoder = fixture.Create<SubtitleEncoder>();
|
||||||
var result = await subtitleEncoder.GetReadableFile(mediaSource, subtitleStream, CancellationToken.None).ConfigureAwait(false);
|
var result = await subtitleEncoder.GetReadableFile(mediaSource, subtitleStream, CancellationToken.None);
|
||||||
Assert.Equal(subtitleInfo.Path, result.Path);
|
Assert.Equal(subtitleInfo.Path, result.Path);
|
||||||
Assert.Equal(subtitleInfo.Protocol, result.Protocol);
|
Assert.Equal(subtitleInfo.Protocol, result.Protocol);
|
||||||
Assert.Equal(subtitleInfo.Format, result.Format);
|
Assert.Equal(subtitleInfo.Format, result.Format);
|
||||||
|
|
|
@ -82,7 +82,7 @@ namespace Jellyfin.Providers.Tests.Manager
|
||||||
AddParts(providerManager, metadataServices: servicesList.Select(s => s.Object).ToArray());
|
AddParts(providerManager, metadataServices: servicesList.Select(s => s.Object).ToArray());
|
||||||
|
|
||||||
var refreshOptions = new MetadataRefreshOptions(Mock.Of<IDirectoryService>(MockBehavior.Strict));
|
var refreshOptions = new MetadataRefreshOptions(Mock.Of<IDirectoryService>(MockBehavior.Strict));
|
||||||
var actual = await providerManager.RefreshSingleItem(item, refreshOptions, CancellationToken.None).ConfigureAwait(false);
|
var actual = await providerManager.RefreshSingleItem(item, refreshOptions, CancellationToken.None);
|
||||||
|
|
||||||
Assert.Equal(ItemUpdateType.MetadataDownload, actual);
|
Assert.Equal(ItemUpdateType.MetadataDownload, actual);
|
||||||
for (var i = 0; i < servicesList.Length; i++)
|
for (var i = 0; i < servicesList.Length; i++)
|
||||||
|
@ -105,7 +105,7 @@ namespace Jellyfin.Providers.Tests.Manager
|
||||||
AddParts(providerManager, metadataServices: servicesList.Select(s => s.Object).ToArray());
|
AddParts(providerManager, metadataServices: servicesList.Select(s => s.Object).ToArray());
|
||||||
|
|
||||||
var refreshOptions = new MetadataRefreshOptions(Mock.Of<IDirectoryService>(MockBehavior.Strict));
|
var refreshOptions = new MetadataRefreshOptions(Mock.Of<IDirectoryService>(MockBehavior.Strict));
|
||||||
var actual = await providerManager.RefreshSingleItem(item, refreshOptions, CancellationToken.None).ConfigureAwait(false);
|
var actual = await providerManager.RefreshSingleItem(item, refreshOptions, CancellationToken.None);
|
||||||
|
|
||||||
var expectedResult = serviceFound ? ItemUpdateType.MetadataDownload : ItemUpdateType.None;
|
var expectedResult = serviceFound ? ItemUpdateType.MetadataDownload : ItemUpdateType.None;
|
||||||
Assert.Equal(expectedResult, actual);
|
Assert.Equal(expectedResult, actual);
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv
|
||||||
Url = "192.168.1.182"
|
Url = "192.168.1.182"
|
||||||
};
|
};
|
||||||
|
|
||||||
var modelInfo = await _hdHomerunHost.GetModelInfo(host, true, CancellationToken.None).ConfigureAwait(false);
|
var modelInfo = await _hdHomerunHost.GetModelInfo(host, true, CancellationToken.None);
|
||||||
Assert.Equal("HDHomeRun PRIME", modelInfo.FriendlyName);
|
Assert.Equal("HDHomeRun PRIME", modelInfo.FriendlyName);
|
||||||
Assert.Equal("HDHR3-CC", modelInfo.ModelNumber);
|
Assert.Equal("HDHR3-CC", modelInfo.ModelNumber);
|
||||||
Assert.Equal("hdhomerun3_cablecard", modelInfo.FirmwareName);
|
Assert.Equal("hdhomerun3_cablecard", modelInfo.FirmwareName);
|
||||||
|
@ -72,7 +72,7 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv
|
||||||
Url = "10.10.10.100"
|
Url = "10.10.10.100"
|
||||||
};
|
};
|
||||||
|
|
||||||
var modelInfo = await _hdHomerunHost.GetModelInfo(host, true, CancellationToken.None).ConfigureAwait(false);
|
var modelInfo = await _hdHomerunHost.GetModelInfo(host, true, CancellationToken.None);
|
||||||
Assert.Equal("HDHomeRun DUAL", modelInfo.FriendlyName);
|
Assert.Equal("HDHomeRun DUAL", modelInfo.FriendlyName);
|
||||||
Assert.Equal("HDHR3-US", modelInfo.ModelNumber);
|
Assert.Equal("HDHR3-US", modelInfo.ModelNumber);
|
||||||
Assert.Equal("hdhomerun3_atsc", modelInfo.FirmwareName);
|
Assert.Equal("hdhomerun3_atsc", modelInfo.FirmwareName);
|
||||||
|
@ -103,7 +103,7 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv
|
||||||
Url = "192.168.1.182"
|
Url = "192.168.1.182"
|
||||||
};
|
};
|
||||||
|
|
||||||
var channels = await _hdHomerunHost.GetLineup(host, CancellationToken.None).ConfigureAwait(false);
|
var channels = await _hdHomerunHost.GetLineup(host, CancellationToken.None);
|
||||||
Assert.Equal(6, channels.Count);
|
Assert.Equal(6, channels.Count);
|
||||||
Assert.Equal("4.1", channels[0].GuideNumber);
|
Assert.Equal("4.1", channels[0].GuideNumber);
|
||||||
Assert.Equal("WCMH-DT", channels[0].GuideName);
|
Assert.Equal("WCMH-DT", channels[0].GuideName);
|
||||||
|
@ -133,7 +133,7 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv
|
||||||
ImportFavoritesOnly = true
|
ImportFavoritesOnly = true
|
||||||
};
|
};
|
||||||
|
|
||||||
var channels = await _hdHomerunHost.GetLineup(host, CancellationToken.None).ConfigureAwait(false);
|
var channels = await _hdHomerunHost.GetLineup(host, CancellationToken.None);
|
||||||
Assert.Single(channels);
|
Assert.Single(channels);
|
||||||
Assert.Equal("4.1", channels[0].GuideNumber);
|
Assert.Equal("4.1", channels[0].GuideNumber);
|
||||||
Assert.Equal("WCMH-DT", channels[0].GuideName);
|
Assert.Equal("WCMH-DT", channels[0].GuideName);
|
||||||
|
@ -145,7 +145,7 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task TryGetTunerHostInfo_Valid_Success()
|
public async Task TryGetTunerHostInfo_Valid_Success()
|
||||||
{
|
{
|
||||||
var host = await _hdHomerunHost.TryGetTunerHostInfo("192.168.1.182", CancellationToken.None).ConfigureAwait(false);
|
var host = await _hdHomerunHost.TryGetTunerHostInfo("192.168.1.182", CancellationToken.None);
|
||||||
Assert.Equal(_hdHomerunHost.Type, host.Type);
|
Assert.Equal(_hdHomerunHost.Type, host.Type);
|
||||||
Assert.Equal("192.168.1.182", host.Url);
|
Assert.Equal("192.168.1.182", host.Url);
|
||||||
Assert.Equal("HDHomeRun PRIME", host.FriendlyName);
|
Assert.Equal("HDHomeRun PRIME", host.FriendlyName);
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace Jellyfin.Server.Implementations.Tests.Updates
|
||||||
Checksum = "InvalidChecksum"
|
Checksum = "InvalidChecksum"
|
||||||
};
|
};
|
||||||
|
|
||||||
await Assert.ThrowsAsync<InvalidDataException>(() => _installationManager.InstallPackage(packageInfo, CancellationToken.None)).ConfigureAwait(false);
|
await Assert.ThrowsAsync<InvalidDataException>(() => _installationManager.InstallPackage(packageInfo, CancellationToken.None));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -103,7 +103,7 @@ namespace Jellyfin.Server.Implementations.Tests.Updates
|
||||||
Checksum = "11b5b2f1a9ebc4f66d6ef19018543361"
|
Checksum = "11b5b2f1a9ebc4f66d6ef19018543361"
|
||||||
};
|
};
|
||||||
|
|
||||||
var ex = await Record.ExceptionAsync(() => _installationManager.InstallPackage(packageInfo, CancellationToken.None)).ConfigureAwait(false);
|
var ex = await Record.ExceptionAsync(() => _installationManager.InstallPackage(packageInfo, CancellationToken.None));
|
||||||
Assert.Null(ex);
|
Assert.Null(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,10 @@ namespace Jellyfin.Server.Integration.Tests
|
||||||
public static async Task<string> CompleteStartupAsync(HttpClient client)
|
public static async Task<string> CompleteStartupAsync(HttpClient client)
|
||||||
{
|
{
|
||||||
var jsonOptions = JsonDefaults.Options;
|
var jsonOptions = JsonDefaults.Options;
|
||||||
var userResponse = await client.GetByteArrayAsync("/Startup/User").ConfigureAwait(false);
|
var userResponse = await client.GetByteArrayAsync("/Startup/User");
|
||||||
var user = JsonSerializer.Deserialize<StartupUserDto>(userResponse, jsonOptions);
|
var user = JsonSerializer.Deserialize<StartupUserDto>(userResponse, jsonOptions);
|
||||||
|
|
||||||
using var completeResponse = await client.PostAsync("/Startup/Complete", new ByteArrayContent(Array.Empty<byte>())).ConfigureAwait(false);
|
using var completeResponse = await client.PostAsync("/Startup/Complete", new ByteArrayContent(Array.Empty<byte>()));
|
||||||
Assert.Equal(HttpStatusCode.NoContent, completeResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, completeResponse.StatusCode);
|
||||||
|
|
||||||
using var content = JsonContent.Create(
|
using var content = JsonContent.Create(
|
||||||
|
@ -36,20 +36,20 @@ namespace Jellyfin.Server.Integration.Tests
|
||||||
options: jsonOptions);
|
options: jsonOptions);
|
||||||
content.Headers.Add("X-Emby-Authorization", DummyAuthHeader);
|
content.Headers.Add("X-Emby-Authorization", DummyAuthHeader);
|
||||||
|
|
||||||
using var authResponse = await client.PostAsync("/Users/AuthenticateByName", content).ConfigureAwait(false);
|
using var authResponse = await client.PostAsync("/Users/AuthenticateByName", content);
|
||||||
var auth = await JsonSerializer.DeserializeAsync<AuthenticationResultDto>(
|
var auth = await JsonSerializer.DeserializeAsync<AuthenticationResultDto>(
|
||||||
await authResponse.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
await authResponse.Content.ReadAsStreamAsync(),
|
||||||
jsonOptions).ConfigureAwait(false);
|
jsonOptions);
|
||||||
|
|
||||||
return auth!.AccessToken;
|
return auth!.AccessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<UserDto> GetUserDtoAsync(HttpClient client)
|
public static async Task<UserDto> GetUserDtoAsync(HttpClient client)
|
||||||
{
|
{
|
||||||
using var response = await client.GetAsync("Users/Me").ConfigureAwait(false);
|
using var response = await client.GetAsync("Users/Me");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
var userDto = await JsonSerializer.DeserializeAsync<UserDto>(
|
var userDto = await JsonSerializer.DeserializeAsync<UserDto>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false), JsonDefaults.Options).ConfigureAwait(false);
|
await response.Content.ReadAsStreamAsync(), JsonDefaults.Options);
|
||||||
Assert.NotNull(userDto);
|
Assert.NotNull(userDto);
|
||||||
return userDto;
|
return userDto;
|
||||||
}
|
}
|
||||||
|
@ -58,15 +58,15 @@ namespace Jellyfin.Server.Integration.Tests
|
||||||
{
|
{
|
||||||
if (userId.Equals(default))
|
if (userId.Equals(default))
|
||||||
{
|
{
|
||||||
var userDto = await GetUserDtoAsync(client).ConfigureAwait(false);
|
var userDto = await GetUserDtoAsync(client);
|
||||||
userId = userDto.Id;
|
userId = userDto.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
var response = await client.GetAsync($"Users/{userId}/Items/Root").ConfigureAwait(false);
|
var response = await client.GetAsync($"Users/{userId}/Items/Root");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
var rootDto = await JsonSerializer.DeserializeAsync<BaseItemDto>(
|
var rootDto = await JsonSerializer.DeserializeAsync<BaseItemDto>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
await response.Content.ReadAsStreamAsync(),
|
||||||
JsonDefaults.Options).ConfigureAwait(false);
|
JsonDefaults.Options);
|
||||||
Assert.NotNull(rootDto);
|
Assert.NotNull(rootDto);
|
||||||
return rootDto;
|
return rootDto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task ActivityLog_GetEntries_Ok()
|
public async Task ActivityLog_GetEntries_Ok()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync("System/ActivityLog/Entries").ConfigureAwait(false);
|
var response = await client.GetAsync("System/ActivityLog/Entries");
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
|
|
||||||
var response = await client.GetAsync("web/ConfigurationPage?name=ThisPageDoesntExists").ConfigureAwait(false);
|
var response = await client.GetAsync("web/ConfigurationPage?name=ThisPageDoesntExists");
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,12 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
|
|
||||||
var response = await client.GetAsync("/web/ConfigurationPage?name=TestPlugin").ConfigureAwait(false);
|
var response = await client.GetAsync("/web/ConfigurationPage?name=TestPlugin");
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Text.Html, response.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Text.Html, response.Content.Headers.ContentType?.MediaType);
|
||||||
StreamReader reader = new StreamReader(typeof(TestPlugin).Assembly.GetManifestResourceStream("Jellyfin.Server.Integration.Tests.TestPage.html")!);
|
StreamReader reader = new StreamReader(typeof(TestPlugin).Assembly.GetManifestResourceStream("Jellyfin.Server.Integration.Tests.TestPage.html")!);
|
||||||
Assert.Equal(await response.Content.ReadAsStringAsync().ConfigureAwait(false), await reader.ReadToEndAsync().ConfigureAwait(false));
|
Assert.Equal(await response.Content.ReadAsStringAsync(), await reader.ReadToEndAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -49,7 +49,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
|
|
||||||
var response = await client.GetAsync("/web/ConfigurationPage?name=BrokenPage").ConfigureAwait(false);
|
var response = await client.GetAsync("/web/ConfigurationPage?name=BrokenPage");
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task GetConfigurationPages_NoParams_AllConfigurationPages()
|
public async Task GetConfigurationPages_NoParams_AllConfigurationPages()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync("/web/ConfigurationPages").ConfigureAwait(false);
|
var response = await client.GetAsync("/web/ConfigurationPages");
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task GetConfigurationPages_True_MainMenuConfigurationPages()
|
public async Task GetConfigurationPages_True_MainMenuConfigurationPages()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync("/web/ConfigurationPages?enableInMainMenu=true").ConfigureAwait(false);
|
var response = await client.GetAsync("/web/ConfigurationPages?enableInMainMenu=true");
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
||||||
|
|
|
@ -32,9 +32,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task GetProfile_DoesNotExist_NotFound()
|
public async Task GetProfile_DoesNotExist_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var response = await client.GetAsync("/Dlna/Profiles/" + NonExistentProfile).ConfigureAwait(false);
|
using var response = await client.GetAsync("/Dlna/Profiles/" + NonExistentProfile);
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,9 +43,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task DeleteProfile_DoesNotExist_NotFound()
|
public async Task DeleteProfile_DoesNotExist_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var response = await client.DeleteAsync("/Dlna/Profiles/" + NonExistentProfile).ConfigureAwait(false);
|
using var response = await client.DeleteAsync("/Dlna/Profiles/" + NonExistentProfile);
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,14 +54,14 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task UpdateProfile_DoesNotExist_NotFound()
|
public async Task UpdateProfile_DoesNotExist_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var deviceProfile = new DeviceProfile()
|
var deviceProfile = new DeviceProfile()
|
||||||
{
|
{
|
||||||
Name = "ThisProfileDoesNotExist"
|
Name = "ThisProfileDoesNotExist"
|
||||||
};
|
};
|
||||||
|
|
||||||
using var response = await client.PostAsJsonAsync("/Dlna/Profiles/" + NonExistentProfile, deviceProfile, _jsonOptions).ConfigureAwait(false);
|
using var response = await client.PostAsJsonAsync("/Dlna/Profiles/" + NonExistentProfile, deviceProfile, _jsonOptions);
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,14 +70,14 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task CreateProfile_Valid_NoContent()
|
public async Task CreateProfile_Valid_NoContent()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var deviceProfile = new DeviceProfile()
|
var deviceProfile = new DeviceProfile()
|
||||||
{
|
{
|
||||||
Name = "ThisProfileIsNew"
|
Name = "ThisProfileIsNew"
|
||||||
};
|
};
|
||||||
|
|
||||||
using var response = await client.PostAsJsonAsync("/Dlna/Profiles", deviceProfile, _jsonOptions).ConfigureAwait(false);
|
using var response = await client.PostAsJsonAsync("/Dlna/Profiles", deviceProfile, _jsonOptions);
|
||||||
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,16 +86,16 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task GetProfileInfos_Valid_ContainsThisProfileIsNew()
|
public async Task GetProfileInfos_Valid_ContainsThisProfileIsNew()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var response = await client.GetAsync("/Dlna/ProfileInfos").ConfigureAwait(false);
|
using var response = await client.GetAsync("/Dlna/ProfileInfos");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
||||||
Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
|
Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
|
||||||
|
|
||||||
var profiles = await JsonSerializer.DeserializeAsync<DeviceProfileInfo[]>(
|
var profiles = await JsonSerializer.DeserializeAsync<DeviceProfileInfo[]>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
await response.Content.ReadAsStreamAsync(),
|
||||||
_jsonOptions).ConfigureAwait(false);
|
_jsonOptions);
|
||||||
|
|
||||||
var newProfile = profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsNew", StringComparison.Ordinal));
|
var newProfile = profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsNew", StringComparison.Ordinal));
|
||||||
Assert.NotNull(newProfile);
|
Assert.NotNull(newProfile);
|
||||||
|
@ -107,7 +107,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task UpdateProfile_Valid_NoContent()
|
public async Task UpdateProfile_Valid_NoContent()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var updatedProfile = new DeviceProfile()
|
var updatedProfile = new DeviceProfile()
|
||||||
{
|
{
|
||||||
|
@ -115,18 +115,18 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
Id = _newDeviceProfileId
|
Id = _newDeviceProfileId
|
||||||
};
|
};
|
||||||
|
|
||||||
using var postResponse = await client.PostAsJsonAsync("/Dlna/Profiles/" + _newDeviceProfileId, updatedProfile, _jsonOptions).ConfigureAwait(false);
|
using var postResponse = await client.PostAsJsonAsync("/Dlna/Profiles/" + _newDeviceProfileId, updatedProfile, _jsonOptions);
|
||||||
Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
|
||||||
|
|
||||||
// Verify that the profile got updated
|
// Verify that the profile got updated
|
||||||
using var response = await client.GetAsync("/Dlna/ProfileInfos").ConfigureAwait(false);
|
using var response = await client.GetAsync("/Dlna/ProfileInfos");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
||||||
Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
|
Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
|
||||||
|
|
||||||
var profiles = await JsonSerializer.DeserializeAsync<DeviceProfileInfo[]>(
|
var profiles = await JsonSerializer.DeserializeAsync<DeviceProfileInfo[]>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
await response.Content.ReadAsStreamAsync(),
|
||||||
_jsonOptions).ConfigureAwait(false);
|
_jsonOptions);
|
||||||
|
|
||||||
Assert.Null(profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsNew", StringComparison.Ordinal)));
|
Assert.Null(profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsNew", StringComparison.Ordinal)));
|
||||||
var newProfile = profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsUpdated", StringComparison.Ordinal));
|
var newProfile = profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsUpdated", StringComparison.Ordinal));
|
||||||
|
@ -139,20 +139,20 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task DeleteProfile_Valid_NoContent()
|
public async Task DeleteProfile_Valid_NoContent()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var deleteResponse = await client.DeleteAsync("/Dlna/Profiles/" + _newDeviceProfileId).ConfigureAwait(false);
|
using var deleteResponse = await client.DeleteAsync("/Dlna/Profiles/" + _newDeviceProfileId);
|
||||||
Assert.Equal(HttpStatusCode.NoContent, deleteResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, deleteResponse.StatusCode);
|
||||||
|
|
||||||
// Verify that the profile got deleted
|
// Verify that the profile got deleted
|
||||||
using var response = await client.GetAsync("/Dlna/ProfileInfos").ConfigureAwait(false);
|
using var response = await client.GetAsync("/Dlna/ProfileInfos");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
||||||
Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
|
Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
|
||||||
|
|
||||||
var profiles = await JsonSerializer.DeserializeAsync<DeviceProfileInfo[]>(
|
var profiles = await JsonSerializer.DeserializeAsync<DeviceProfileInfo[]>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
await response.Content.ReadAsStreamAsync(),
|
||||||
_jsonOptions).ConfigureAwait(false);
|
_jsonOptions);
|
||||||
|
|
||||||
Assert.Null(profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsUpdated", StringComparison.Ordinal)));
|
Assert.Null(profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsUpdated", StringComparison.Ordinal)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ public sealed class ItemsControllerTests : IClassFixture<JellyfinApplicationFact
|
||||||
public async Task GetItems_NoApiKeyOrUserId_Success()
|
public async Task GetItems_NoApiKeyOrUserId_Success()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync("Items").ConfigureAwait(false);
|
var response = await client.GetAsync("Items");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ public sealed class ItemsControllerTests : IClassFixture<JellyfinApplicationFact
|
||||||
public async Task GetUserItems_NonExistentUserId_NotFound(string format)
|
public async Task GetUserItems_NonExistentUserId_NotFound(string format)
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid())).ConfigureAwait(false);
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid()));
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,15 +50,15 @@ public sealed class ItemsControllerTests : IClassFixture<JellyfinApplicationFact
|
||||||
public async Task GetItems_UserId_Ok(string format)
|
public async Task GetItems_UserId_Ok(string format)
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
var userDto = await AuthHelper.GetUserDtoAsync(client);
|
||||||
|
|
||||||
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, userDto.Id)).ConfigureAwait(false);
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, userDto.Id));
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
var items = await JsonSerializer.DeserializeAsync<QueryResult<BaseItemDto>>(
|
var items = await JsonSerializer.DeserializeAsync<QueryResult<BaseItemDto>>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
await response.Content.ReadAsStreamAsync(),
|
||||||
_jsonOptions).ConfigureAwait(false);
|
_jsonOptions);
|
||||||
Assert.NotNull(items);
|
Assert.NotNull(items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ public sealed class LibraryControllerTests : IClassFixture<JellyfinApplicationFa
|
||||||
public async Task Get_NonExistentItemId_NotFound(string format)
|
public async Task Get_NonExistentItemId_NotFound(string format)
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid())).ConfigureAwait(false);
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid()));
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public sealed class LibraryControllerTests : IClassFixture<JellyfinApplicationFa
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
|
|
||||||
var response = await client.DeleteAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid())).ConfigureAwait(false);
|
var response = await client.DeleteAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid()));
|
||||||
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
|
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ public sealed class LibraryControllerTests : IClassFixture<JellyfinApplicationFa
|
||||||
public async Task Delete_NonExistentItemId_NotFound(string format)
|
public async Task Delete_NonExistentItemId_NotFound(string format)
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.DeleteAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid())).ConfigureAwait(false);
|
var response = await client.DeleteAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid()));
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task BitrateTest_Default_Ok()
|
public async Task BitrateTest_Default_Ok()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync("Playback/BitrateTest").ConfigureAwait(false);
|
var response = await client.GetAsync("Playback/BitrateTest");
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Application.Octet, response.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Application.Octet, response.Content.Headers.ContentType?.MediaType);
|
||||||
|
@ -34,9 +34,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task BitrateTest_WithValidParam_Ok(int size)
|
public async Task BitrateTest_WithValidParam_Ok(int size)
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync("Playback/BitrateTest?size=" + size.ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
var response = await client.GetAsync("Playback/BitrateTest?size=" + size.ToString(CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Application.Octet, response.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Application.Octet, response.Content.Headers.ContentType?.MediaType);
|
||||||
|
@ -51,9 +51,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task BitrateTest_InvalidValue_BadRequest(int size)
|
public async Task BitrateTest_InvalidValue_BadRequest(int size)
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync("Playback/BitrateTest?size=" + size.ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
var response = await client.GetAsync("Playback/BitrateTest?size=" + size.ToString(CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,10 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task RenameVirtualFolder_WhiteSpaceName_ReturnsBadRequest()
|
public async Task RenameVirtualFolder_WhiteSpaceName_ReturnsBadRequest()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var postContent = new ByteArrayContent(Array.Empty<byte>());
|
using var postContent = new ByteArrayContent(Array.Empty<byte>());
|
||||||
var response = await client.PostAsync("Library/VirtualFolders/Name?name=+&newName=test", postContent).ConfigureAwait(false);
|
var response = await client.PostAsync("Library/VirtualFolders/Name?name=+&newName=test", postContent);
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task RenameVirtualFolder_WhiteSpaceNewName_ReturnsBadRequest()
|
public async Task RenameVirtualFolder_WhiteSpaceNewName_ReturnsBadRequest()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var postContent = new ByteArrayContent(Array.Empty<byte>());
|
using var postContent = new ByteArrayContent(Array.Empty<byte>());
|
||||||
var response = await client.PostAsync("Library/VirtualFolders/Name?name=test&newName=+", postContent).ConfigureAwait(false);
|
var response = await client.PostAsync("Library/VirtualFolders/Name?name=test&newName=+", postContent);
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task RenameVirtualFolder_NameDoesntExist_ReturnsNotFound()
|
public async Task RenameVirtualFolder_NameDoesntExist_ReturnsNotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var postContent = new ByteArrayContent(Array.Empty<byte>());
|
using var postContent = new ByteArrayContent(Array.Empty<byte>());
|
||||||
var response = await client.PostAsync("Library/VirtualFolders/Name?name=doesnt+exist&newName=test", postContent).ConfigureAwait(false);
|
var response = await client.PostAsync("Library/VirtualFolders/Name?name=doesnt+exist&newName=test", postContent);
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task AddMediaPath_PathDoesntExist_ReturnsNotFound()
|
public async Task AddMediaPath_PathDoesntExist_ReturnsNotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var data = new MediaPathDto()
|
var data = new MediaPathDto()
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
Path = "/this/path/doesnt/exist"
|
Path = "/this/path/doesnt/exist"
|
||||||
};
|
};
|
||||||
|
|
||||||
var response = await client.PostAsJsonAsync("Library/VirtualFolders/Paths", data, _jsonOptions).ConfigureAwait(false);
|
var response = await client.PostAsJsonAsync("Library/VirtualFolders/Paths", data, _jsonOptions);
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task UpdateMediaPath_WhiteSpaceName_ReturnsBadRequest()
|
public async Task UpdateMediaPath_WhiteSpaceName_ReturnsBadRequest()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var data = new UpdateMediaPathRequestDto()
|
var data = new UpdateMediaPathRequestDto()
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
PathInfo = new MediaPathInfo("test")
|
PathInfo = new MediaPathInfo("test")
|
||||||
};
|
};
|
||||||
|
|
||||||
var response = await client.PostAsJsonAsync("Library/VirtualFolders/Paths/Update", data, _jsonOptions).ConfigureAwait(false);
|
var response = await client.PostAsJsonAsync("Library/VirtualFolders/Paths/Update", data, _jsonOptions);
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
@ -96,9 +96,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task RemoveMediaPath_WhiteSpaceName_ReturnsBadRequest()
|
public async Task RemoveMediaPath_WhiteSpaceName_ReturnsBadRequest()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.DeleteAsync("Library/VirtualFolders/Paths?name=+").ConfigureAwait(false);
|
var response = await client.DeleteAsync("Library/VirtualFolders/Paths?name=+");
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
@ -107,9 +107,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task RemoveMediaPath_PathDoesntExist_ReturnsNotFound()
|
public async Task RemoveMediaPath_PathDoesntExist_ReturnsNotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.DeleteAsync("Library/VirtualFolders/Paths?name=none&path=%2Fthis%2Fpath%2Fdoesnt%2Fexist").ConfigureAwait(false);
|
var response = await client.DeleteAsync("Library/VirtualFolders/Paths?name=none&path=%2Fthis%2Fpath%2Fdoesnt%2Fexist");
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@ public sealed class MusicGenreControllerTests : IClassFixture<JellyfinApplicatio
|
||||||
public async Task MusicGenres_FakeMusicGenre_NotFound()
|
public async Task MusicGenres_FakeMusicGenre_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync("MusicGenres/Fake-MusicGenre").ConfigureAwait(false);
|
var response = await client.GetAsync("MusicGenres/Fake-MusicGenre");
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ public class PlaystateControllerTests : IClassFixture<JellyfinApplicationFactory
|
||||||
public async Task DeleteMarkUnplayedItem_NonExistentUserId_NotFound()
|
public async Task DeleteMarkUnplayedItem_NonExistentUserId_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var response = await client.DeleteAsync($"Users/{Guid.NewGuid()}/PlayedItems/{Guid.NewGuid()}").ConfigureAwait(false);
|
using var response = await client.DeleteAsync($"Users/{Guid.NewGuid()}/PlayedItems/{Guid.NewGuid()}");
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ public class PlaystateControllerTests : IClassFixture<JellyfinApplicationFactory
|
||||||
public async Task PostMarkPlayedItem_NonExistentUserId_NotFound()
|
public async Task PostMarkPlayedItem_NonExistentUserId_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var response = await client.PostAsync($"Users/{Guid.NewGuid()}/PlayedItems/{Guid.NewGuid()}", null).ConfigureAwait(false);
|
using var response = await client.PostAsync($"Users/{Guid.NewGuid()}/PlayedItems/{Guid.NewGuid()}", null);
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ public class PlaystateControllerTests : IClassFixture<JellyfinApplicationFactory
|
||||||
public async Task DeleteMarkUnplayedItem_NonExistentItemId_NotFound()
|
public async Task DeleteMarkUnplayedItem_NonExistentItemId_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
var userDto = await AuthHelper.GetUserDtoAsync(client);
|
||||||
|
|
||||||
using var response = await client.DeleteAsync($"Users/{userDto.Id}/PlayedItems/{Guid.NewGuid()}").ConfigureAwait(false);
|
using var response = await client.DeleteAsync($"Users/{userDto.Id}/PlayedItems/{Guid.NewGuid()}");
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,11 @@ public class PlaystateControllerTests : IClassFixture<JellyfinApplicationFactory
|
||||||
public async Task PostMarkPlayedItem_NonExistentItemId_NotFound()
|
public async Task PostMarkPlayedItem_NonExistentItemId_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
var userDto = await AuthHelper.GetUserDtoAsync(client);
|
||||||
|
|
||||||
using var response = await client.PostAsync($"Users/{userDto.Id}/PlayedItems/{Guid.NewGuid()}", null).ConfigureAwait(false);
|
using var response = await client.PostAsync($"Users/{userDto.Id}/PlayedItems/{Guid.NewGuid()}", null);
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ public class SessionControllerTests : IClassFixture<JellyfinApplicationFactory>
|
||||||
public async Task GetSessions_NonExistentUserId_NotFound()
|
public async Task GetSessions_NonExistentUserId_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var response = await client.GetAsync($"Session/Sessions?userId={Guid.NewGuid()}").ConfigureAwait(false);
|
using var response = await client.GetAsync($"Session/Sessions?userId={Guid.NewGuid()}");
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,15 +36,15 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
PreferredMetadataLanguage = "nl"
|
PreferredMetadataLanguage = "nl"
|
||||||
};
|
};
|
||||||
|
|
||||||
using var postResponse = await client.PostAsJsonAsync("/Startup/Configuration", config, _jsonOptions).ConfigureAwait(false);
|
using var postResponse = await client.PostAsJsonAsync("/Startup/Configuration", config, _jsonOptions);
|
||||||
Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
|
||||||
|
|
||||||
using var getResponse = await client.GetAsync("/Startup/Configuration").ConfigureAwait(false);
|
using var getResponse = await client.GetAsync("/Startup/Configuration");
|
||||||
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Application.Json, getResponse.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Application.Json, getResponse.Content.Headers.ContentType?.MediaType);
|
||||||
|
|
||||||
using var responseStream = await getResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
using var responseStream = await getResponse.Content.ReadAsStreamAsync();
|
||||||
var newConfig = await JsonSerializer.DeserializeAsync<StartupConfigurationDto>(responseStream, _jsonOptions).ConfigureAwait(false);
|
var newConfig = await JsonSerializer.DeserializeAsync<StartupConfigurationDto>(responseStream, _jsonOptions);
|
||||||
Assert.Equal(config.UICulture, newConfig!.UICulture);
|
Assert.Equal(config.UICulture, newConfig!.UICulture);
|
||||||
Assert.Equal(config.MetadataCountryCode, newConfig.MetadataCountryCode);
|
Assert.Equal(config.MetadataCountryCode, newConfig.MetadataCountryCode);
|
||||||
Assert.Equal(config.PreferredMetadataLanguage, newConfig.PreferredMetadataLanguage);
|
Assert.Equal(config.PreferredMetadataLanguage, newConfig.PreferredMetadataLanguage);
|
||||||
|
@ -56,12 +56,12 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
|
|
||||||
using var response = await client.GetAsync("/Startup/User").ConfigureAwait(false);
|
using var response = await client.GetAsync("/Startup/User");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
|
||||||
|
|
||||||
using var contentStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
using var contentStream = await response.Content.ReadAsStreamAsync();
|
||||||
var user = await JsonSerializer.DeserializeAsync<StartupUserDto>(contentStream, _jsonOptions).ConfigureAwait(false);
|
var user = await JsonSerializer.DeserializeAsync<StartupUserDto>(contentStream, _jsonOptions);
|
||||||
Assert.NotNull(user);
|
Assert.NotNull(user);
|
||||||
Assert.NotNull(user.Name);
|
Assert.NotNull(user.Name);
|
||||||
Assert.NotEmpty(user.Name);
|
Assert.NotEmpty(user.Name);
|
||||||
|
@ -80,15 +80,15 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
Password = "NewPassword"
|
Password = "NewPassword"
|
||||||
};
|
};
|
||||||
|
|
||||||
var postResponse = await client.PostAsJsonAsync("/Startup/User", user, _jsonOptions).ConfigureAwait(false);
|
var postResponse = await client.PostAsJsonAsync("/Startup/User", user, _jsonOptions);
|
||||||
Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
|
||||||
|
|
||||||
var getResponse = await client.GetAsync("/Startup/User").ConfigureAwait(false);
|
var getResponse = await client.GetAsync("/Startup/User");
|
||||||
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode);
|
||||||
Assert.Equal(MediaTypeNames.Application.Json, getResponse.Content.Headers.ContentType?.MediaType);
|
Assert.Equal(MediaTypeNames.Application.Json, getResponse.Content.Headers.ContentType?.MediaType);
|
||||||
|
|
||||||
var contentStream = await getResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
var contentStream = await getResponse.Content.ReadAsStreamAsync();
|
||||||
var newUser = await JsonSerializer.DeserializeAsync<StartupUserDto>(contentStream, _jsonOptions).ConfigureAwait(false);
|
var newUser = await JsonSerializer.DeserializeAsync<StartupUserDto>(contentStream, _jsonOptions);
|
||||||
Assert.NotNull(newUser);
|
Assert.NotNull(newUser);
|
||||||
Assert.Equal(user.Name, newUser.Name);
|
Assert.Equal(user.Name, newUser.Name);
|
||||||
Assert.NotNull(newUser.Password);
|
Assert.NotNull(newUser.Password);
|
||||||
|
@ -102,7 +102,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
|
|
||||||
var response = await client.PostAsync("/Startup/Complete", new ByteArrayContent(Array.Empty<byte>())).ConfigureAwait(false);
|
var response = await client.PostAsync("/Startup/Complete", new ByteArrayContent(Array.Empty<byte>()));
|
||||||
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
|
|
||||||
using var response = await client.GetAsync("/Startup/User").ConfigureAwait(false);
|
using var response = await client.GetAsync("/Startup/User");
|
||||||
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
|
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,10 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
|
|
||||||
using var response = await client.GetAsync("Users/Public").ConfigureAwait(false);
|
using var response = await client.GetAsync("Users/Public");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
var users = await JsonSerializer.DeserializeAsync<UserDto[]>(
|
var users = await JsonSerializer.DeserializeAsync<UserDto[]>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false), _jsonOpions).ConfigureAwait(false);
|
await response.Content.ReadAsStreamAsync(), _jsonOpions);
|
||||||
// User are hidden by default
|
// User are hidden by default
|
||||||
Assert.NotNull(users);
|
Assert.NotNull(users);
|
||||||
Assert.Empty(users);
|
Assert.Empty(users);
|
||||||
|
@ -55,12 +55,12 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task GetUsers_Valid_Success()
|
public async Task GetUsers_Valid_Success()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
using var response = await client.GetAsync("Users").ConfigureAwait(false);
|
using var response = await client.GetAsync("Users");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
var users = await JsonSerializer.DeserializeAsync<UserDto[]>(
|
var users = await JsonSerializer.DeserializeAsync<UserDto[]>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false), _jsonOpions).ConfigureAwait(false);
|
await response.Content.ReadAsStreamAsync(), _jsonOpions);
|
||||||
Assert.NotNull(users);
|
Assert.NotNull(users);
|
||||||
Assert.Single(users);
|
Assert.Single(users);
|
||||||
Assert.False(users![0].HasConfiguredPassword);
|
Assert.False(users![0].HasConfiguredPassword);
|
||||||
|
@ -71,9 +71,9 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
public async Task Me_Valid_Success()
|
public async Task Me_Valid_Success()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
_ = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
_ = await AuthHelper.GetUserDtoAsync(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -90,10 +90,10 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
Name = TestUsername
|
Name = TestUsername
|
||||||
};
|
};
|
||||||
|
|
||||||
using var response = await CreateUserByName(client, createRequest).ConfigureAwait(false);
|
using var response = await CreateUserByName(client, createRequest);
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
var user = await JsonSerializer.DeserializeAsync<UserDto>(
|
var user = await JsonSerializer.DeserializeAsync<UserDto>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false), _jsonOpions).ConfigureAwait(false);
|
await response.Content.ReadAsStreamAsync(), _jsonOpions);
|
||||||
Assert.Equal(TestUsername, user!.Name);
|
Assert.Equal(TestUsername, user!.Name);
|
||||||
Assert.False(user.HasPassword);
|
Assert.False(user.HasPassword);
|
||||||
Assert.False(user.HasConfiguredPassword);
|
Assert.False(user.HasConfiguredPassword);
|
||||||
|
@ -121,7 +121,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
Name = username!
|
Name = username!
|
||||||
};
|
};
|
||||||
|
|
||||||
using var response = await CreateUserByName(client, createRequest).ConfigureAwait(false);
|
using var response = await CreateUserByName(client, createRequest);
|
||||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
// access token can't be null here as the previous test populated it
|
// access token can't be null here as the previous test populated it
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken!);
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken!);
|
||||||
|
|
||||||
using var response = await client.DeleteAsync($"User/{Guid.NewGuid()}").ConfigureAwait(false);
|
using var response = await client.DeleteAsync($"User/{Guid.NewGuid()}");
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,11 +150,11 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
NewPw = "4randomPa$$word"
|
NewPw = "4randomPa$$word"
|
||||||
};
|
};
|
||||||
|
|
||||||
using var response = await UpdateUserPassword(client, _testUserId, createRequest).ConfigureAwait(false);
|
using var response = await UpdateUserPassword(client, _testUserId, createRequest);
|
||||||
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
||||||
|
|
||||||
var users = await JsonSerializer.DeserializeAsync<UserDto[]>(
|
var users = await JsonSerializer.DeserializeAsync<UserDto[]>(
|
||||||
await client.GetStreamAsync("Users").ConfigureAwait(false), _jsonOpions).ConfigureAwait(false);
|
await client.GetStreamAsync("Users"), _jsonOpions);
|
||||||
var user = users!.First(x => x.Id.Equals(_testUserId));
|
var user = users!.First(x => x.Id.Equals(_testUserId));
|
||||||
Assert.True(user.HasPassword);
|
Assert.True(user.HasPassword);
|
||||||
Assert.True(user.HasConfiguredPassword);
|
Assert.True(user.HasConfiguredPassword);
|
||||||
|
@ -173,11 +173,11 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
|
||||||
CurrentPw = "4randomPa$$word",
|
CurrentPw = "4randomPa$$word",
|
||||||
};
|
};
|
||||||
|
|
||||||
using var response = await UpdateUserPassword(client, _testUserId, createRequest).ConfigureAwait(false);
|
using var response = await UpdateUserPassword(client, _testUserId, createRequest);
|
||||||
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
|
||||||
|
|
||||||
var users = await JsonSerializer.DeserializeAsync<UserDto[]>(
|
var users = await JsonSerializer.DeserializeAsync<UserDto[]>(
|
||||||
await client.GetStreamAsync("Users").ConfigureAwait(false), _jsonOpions).ConfigureAwait(false);
|
await client.GetStreamAsync("Users"), _jsonOpions);
|
||||||
var user = users!.First(x => x.Id.Equals(_testUserId));
|
var user = users!.First(x => x.Id.Equals(_testUserId));
|
||||||
Assert.False(user.HasPassword);
|
Assert.False(user.HasPassword);
|
||||||
Assert.False(user.HasConfiguredPassword);
|
Assert.False(user.HasConfiguredPassword);
|
||||||
|
|
|
@ -25,9 +25,9 @@ public sealed class UserLibraryControllerTests : IClassFixture<JellyfinApplicati
|
||||||
public async Task GetRootFolder_NonExistenUserId_NotFound()
|
public async Task GetRootFolder_NonExistenUserId_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.GetAsync($"Users/{Guid.NewGuid()}/Items/Root").ConfigureAwait(false);
|
var response = await client.GetAsync($"Users/{Guid.NewGuid()}/Items/Root");
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ public sealed class UserLibraryControllerTests : IClassFixture<JellyfinApplicati
|
||||||
public async Task GetRootFolder_UserId_Valid()
|
public async Task GetRootFolder_UserId_Valid()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
_ = await AuthHelper.GetRootFolderDtoAsync(client).ConfigureAwait(false);
|
_ = await AuthHelper.GetRootFolderDtoAsync(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
@ -49,11 +49,11 @@ public sealed class UserLibraryControllerTests : IClassFixture<JellyfinApplicati
|
||||||
public async Task GetItem_NonExistenUserId_NotFound(string format)
|
public async Task GetItem_NonExistenUserId_NotFound(string format)
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client).ConfigureAwait(false);
|
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client);
|
||||||
|
|
||||||
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid(), rootFolderDto.Id)).ConfigureAwait(false);
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, Guid.NewGuid(), rootFolderDto.Id));
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,11 +66,11 @@ public sealed class UserLibraryControllerTests : IClassFixture<JellyfinApplicati
|
||||||
public async Task GetItem_NonExistentItemId_NotFound(string format)
|
public async Task GetItem_NonExistentItemId_NotFound(string format)
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
var userDto = await AuthHelper.GetUserDtoAsync(client);
|
||||||
|
|
||||||
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, userDto.Id, Guid.NewGuid())).ConfigureAwait(false);
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, userDto.Id, Guid.NewGuid()));
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,16 +78,16 @@ public sealed class UserLibraryControllerTests : IClassFixture<JellyfinApplicati
|
||||||
public async Task GetItem_UserIdAndItemId_Valid()
|
public async Task GetItem_UserIdAndItemId_Valid()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
var userDto = await AuthHelper.GetUserDtoAsync(client);
|
||||||
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client, userDto.Id).ConfigureAwait(false);
|
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client, userDto.Id);
|
||||||
|
|
||||||
var response = await client.GetAsync($"Users/{userDto.Id}/Items/{rootFolderDto.Id}").ConfigureAwait(false);
|
var response = await client.GetAsync($"Users/{userDto.Id}/Items/{rootFolderDto.Id}");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
var rootDto = await JsonSerializer.DeserializeAsync<BaseItemDto>(
|
var rootDto = await JsonSerializer.DeserializeAsync<BaseItemDto>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
await response.Content.ReadAsStreamAsync(),
|
||||||
_jsonOptions).ConfigureAwait(false);
|
_jsonOptions);
|
||||||
Assert.NotNull(rootDto);
|
Assert.NotNull(rootDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,16 +95,16 @@ public sealed class UserLibraryControllerTests : IClassFixture<JellyfinApplicati
|
||||||
public async Task GetIntros_UserIdAndItemId_Valid()
|
public async Task GetIntros_UserIdAndItemId_Valid()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
var userDto = await AuthHelper.GetUserDtoAsync(client);
|
||||||
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client, userDto.Id).ConfigureAwait(false);
|
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client, userDto.Id);
|
||||||
|
|
||||||
var response = await client.GetAsync($"Users/{userDto.Id}/Items/{rootFolderDto.Id}/Intros").ConfigureAwait(false);
|
var response = await client.GetAsync($"Users/{userDto.Id}/Items/{rootFolderDto.Id}/Intros");
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
var rootDto = await JsonSerializer.DeserializeAsync<QueryResult<BaseItemDto>>(
|
var rootDto = await JsonSerializer.DeserializeAsync<QueryResult<BaseItemDto>>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
await response.Content.ReadAsStreamAsync(),
|
||||||
_jsonOptions).ConfigureAwait(false);
|
_jsonOptions);
|
||||||
Assert.NotNull(rootDto);
|
Assert.NotNull(rootDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,16 +114,16 @@ public sealed class UserLibraryControllerTests : IClassFixture<JellyfinApplicati
|
||||||
public async Task LocalTrailersAndSpecialFeatures_UserIdAndItemId_Valid(string format)
|
public async Task LocalTrailersAndSpecialFeatures_UserIdAndItemId_Valid(string format)
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var userDto = await AuthHelper.GetUserDtoAsync(client).ConfigureAwait(false);
|
var userDto = await AuthHelper.GetUserDtoAsync(client);
|
||||||
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client, userDto.Id).ConfigureAwait(false);
|
var rootFolderDto = await AuthHelper.GetRootFolderDtoAsync(client, userDto.Id);
|
||||||
|
|
||||||
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, userDto.Id, rootFolderDto.Id)).ConfigureAwait(false);
|
var response = await client.GetAsync(string.Format(CultureInfo.InvariantCulture, format, userDto.Id, rootFolderDto.Id));
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
var rootDto = await JsonSerializer.DeserializeAsync<BaseItemDto[]>(
|
var rootDto = await JsonSerializer.DeserializeAsync<BaseItemDto[]>(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
await response.Content.ReadAsStreamAsync(),
|
||||||
_jsonOptions).ConfigureAwait(false);
|
_jsonOptions);
|
||||||
Assert.NotNull(rootDto);
|
Assert.NotNull(rootDto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ public sealed class VideosControllerTests : IClassFixture<JellyfinApplicationFac
|
||||||
public async Task DeleteAlternateSources_NonExistentItemId_NotFound()
|
public async Task DeleteAlternateSources_NonExistentItemId_NotFound()
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
|
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
|
||||||
|
|
||||||
var response = await client.DeleteAsync($"Videos/{Guid.NewGuid()}").ConfigureAwait(false);
|
var response = await client.DeleteAsync($"Videos/{Guid.NewGuid()}");
|
||||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,9 @@ namespace Jellyfin.Server.Integration.Tests
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
|
|
||||||
var response = await client.GetAsync("Encoder/UrlDecode?" + sourceUrl).ConfigureAwait(false);
|
var response = await client.GetAsync("Encoder/UrlDecode?" + sourceUrl);
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
string reply = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
string reply = await response.Content.ReadAsStringAsync();
|
||||||
Assert.Equal(unencodedUrl, reply);
|
Assert.Equal(unencodedUrl, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ namespace Jellyfin.Server.Integration.Tests
|
||||||
{
|
{
|
||||||
var client = _factory.CreateClient();
|
var client = _factory.CreateClient();
|
||||||
|
|
||||||
var response = await client.GetAsync("Encoder/UrlArrayDecode?" + sourceUrl).ConfigureAwait(false);
|
var response = await client.GetAsync("Encoder/UrlArrayDecode?" + sourceUrl);
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
string reply = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
string reply = await response.Content.ReadAsStringAsync();
|
||||||
Assert.Equal(unencodedUrl, reply);
|
Assert.Equal(unencodedUrl, reply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Jellyfin.Server.Integration.Tests.Middleware
|
||||||
AllowAutoRedirect = false
|
AllowAutoRedirect = false
|
||||||
});
|
});
|
||||||
|
|
||||||
var response = await client.GetAsync("robots.txt").ConfigureAwait(false);
|
var response = await client.GetAsync("robots.txt");
|
||||||
|
|
||||||
Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
|
Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
|
||||||
Assert.Equal("web/robots.txt", response.Headers.Location?.ToString());
|
Assert.Equal("web/robots.txt", response.Headers.Location?.ToString());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user