diff options
| author | Bond_009 <bond.009@outlook.com> | 2024-08-30 16:23:11 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2024-08-30 16:23:11 +0200 |
| commit | 1082f20c20a67d3ec149b5ff9b7f40627db83d92 (patch) | |
| tree | ea590d55ef1210ac867a6df87041fc83cacc08f8 /tests/Jellyfin.Server.Integration.Tests/Controllers/PluginsControllerTests.cs | |
| parent | 9644e894f0f6e1206f68a2b23aeb8065a565f9bf (diff) | |
Add PluginsController tests
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests/Controllers/PluginsControllerTests.cs')
| -rw-r--r-- | tests/Jellyfin.Server.Integration.Tests/Controllers/PluginsControllerTests.cs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/PluginsControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/PluginsControllerTests.cs new file mode 100644 index 000000000..547bfcc0f --- /dev/null +++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/PluginsControllerTests.cs @@ -0,0 +1,45 @@ +using System.Net; +using System.Net.Http.Json; +using System.Net.Mime; +using System.Text; +using System.Threading.Tasks; +using Jellyfin.Extensions.Json; +using MediaBrowser.Model.Plugins; +using Xunit; + +namespace Jellyfin.Server.Integration.Tests.Controllers; + +public sealed class PluginsControllerTests : IClassFixture<JellyfinApplicationFactory> +{ + private readonly JellyfinApplicationFactory _factory; + private static string? _accessToken; + + public PluginsControllerTests(JellyfinApplicationFactory factory) + { + _factory = factory; + } + + [Fact] + public async Task GetPlugins_Unauthorized_ReturnsUnauthorized() + { + var client = _factory.CreateClient(); + + var response = await client.GetAsync("/Plugins"); + + Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); + } + + [Fact] + public async Task GetPlugins_Authorized_ReturnsCorrectResponse() + { + var client = _factory.CreateClient(); + client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client)); + + var response = await client.GetAsync("/Plugins"); + + 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); + _ = await response.Content.ReadFromJsonAsync<PluginInfo[]>(JsonDefaults.Options); + } +} |
