diff options
| author | Bond-009 <bond.009@outlook.com> | 2023-11-30 17:40:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-30 17:40:06 +0100 |
| commit | cc276838b4edbb67356b805952262c38e9c9cd19 (patch) | |
| tree | 8cb27ed0ba34fdd2d941f43c09ccc2be70c10abb /tests/Jellyfin.Server.Integration.Tests/Controllers | |
| parent | cf80ea25413b75bbeddaef136fbeee33aa882a60 (diff) | |
| parent | e46e3be667c76ff9a242d7499aff83d2d10881ed (diff) | |
Merge pull request #10558 from barronpm/dlna-plugin2
Move DLNA to Plugin (Part 2)
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests/Controllers')
| -rw-r--r-- | tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs | 154 |
1 files changed, 0 insertions, 154 deletions
diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs deleted file mode 100644 index e5d5e785cb..0000000000 --- a/tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using System.Linq; -using System.Net; -using System.Net.Http.Json; -using System.Net.Mime; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; -using Jellyfin.Extensions.Json; -using MediaBrowser.Model.Dlna; -using Xunit; -using Xunit.Priority; - -namespace Jellyfin.Server.Integration.Tests.Controllers -{ - [TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)] - public sealed class DlnaControllerTests : IClassFixture<JellyfinApplicationFactory> - { - private const string NonExistentProfile = "1322f35b8f2c434dad3cc07c9b97dbd1"; - private readonly JellyfinApplicationFactory _factory; - private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options; - private static string? _accessToken; - private static string? _newDeviceProfileId; - - public DlnaControllerTests(JellyfinApplicationFactory factory) - { - _factory = factory; - } - - [Fact] - [Priority(0)] - public async Task GetProfile_DoesNotExist_NotFound() - { - var client = _factory.CreateClient(); - client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client)); - - using var response = await client.GetAsync("/Dlna/Profiles/" + NonExistentProfile); - Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); - } - - [Fact] - [Priority(0)] - public async Task DeleteProfile_DoesNotExist_NotFound() - { - var client = _factory.CreateClient(); - client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client)); - - using var response = await client.DeleteAsync("/Dlna/Profiles/" + NonExistentProfile); - Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); - } - - [Fact] - [Priority(0)] - public async Task UpdateProfile_DoesNotExist_NotFound() - { - var client = _factory.CreateClient(); - client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client)); - - var deviceProfile = new DeviceProfile() - { - Name = "ThisProfileDoesNotExist" - }; - - using var response = await client.PostAsJsonAsync("/Dlna/Profiles/" + NonExistentProfile, deviceProfile, _jsonOptions); - Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); - } - - [Fact] - [Priority(1)] - public async Task CreateProfile_Valid_NoContent() - { - var client = _factory.CreateClient(); - client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client)); - - var deviceProfile = new DeviceProfile() - { - Name = "ThisProfileIsNew" - }; - - using var response = await client.PostAsJsonAsync("/Dlna/Profiles", deviceProfile, _jsonOptions); - Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); - } - - [Fact] - [Priority(2)] - public async Task GetProfileInfos_Valid_ContainsThisProfileIsNew() - { - var client = _factory.CreateClient(); - client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client)); - - using var response = await client.GetAsync("/Dlna/ProfileInfos"); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType); - Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet); - - var profiles = await response.Content.ReadFromJsonAsync<DeviceProfileInfo[]>(_jsonOptions); - - var newProfile = profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsNew", StringComparison.Ordinal)); - Assert.NotNull(newProfile); - _newDeviceProfileId = newProfile!.Id; - } - - [Fact] - [Priority(3)] - public async Task UpdateProfile_Valid_NoContent() - { - var client = _factory.CreateClient(); - client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client)); - - var updatedProfile = new DeviceProfile() - { - Name = "ThisProfileIsUpdated", - Id = _newDeviceProfileId - }; - - using var postResponse = await client.PostAsJsonAsync("/Dlna/Profiles/" + _newDeviceProfileId, updatedProfile, _jsonOptions); - Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode); - - // Verify that the profile got updated - using var response = await client.GetAsync("/Dlna/ProfileInfos"); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType); - Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet); - - var profiles = await response.Content.ReadFromJsonAsync<DeviceProfileInfo[]>(_jsonOptions); - - Assert.Null(profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsNew", StringComparison.Ordinal))); - var newProfile = profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsUpdated", StringComparison.Ordinal)); - Assert.NotNull(newProfile); - _newDeviceProfileId = newProfile!.Id; - } - - [Fact] - [Priority(5)] - public async Task DeleteProfile_Valid_NoContent() - { - var client = _factory.CreateClient(); - client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client)); - - using var deleteResponse = await client.DeleteAsync("/Dlna/Profiles/" + _newDeviceProfileId); - Assert.Equal(HttpStatusCode.NoContent, deleteResponse.StatusCode); - - // Verify that the profile got deleted - using var response = await client.GetAsync("/Dlna/ProfileInfos"); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType); - Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet); - - var profiles = await response.Content.ReadFromJsonAsync<DeviceProfileInfo[]>(_jsonOptions); - - Assert.Null(profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsUpdated", StringComparison.Ordinal))); - } - } -} |
