aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2021-08-28 20:12:25 +0200
committerBond_009 <bond.009@outlook.com>2021-08-28 20:12:25 +0200
commit69ba539c700c502f189c9067c31860c889aed1f7 (patch)
tree2647aa8b1460bd885fdf2f53d9bde74a04d6588b /tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs
parent909573f2f142ca2f5e1e54093c820b9f9ebb6168 (diff)
Add more tests for LibraryStructureController
Diffstat (limited to 'tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs')
-rw-r--r--tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs41
1 files changed, 39 insertions, 2 deletions
diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs
index 9f189aaab..5855f0266 100644
--- a/tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs
+++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/MediaStructureControllerTests.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
@@ -22,6 +23,42 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
}
[Fact]
+ public async Task RenameVirtualFolder_WhiteSpaceName_ReturnsBadRequest()
+ {
+ var client = _factory.CreateClient();
+ client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
+
+ using var postContent = new ByteArrayContent(Array.Empty<byte>());
+ var response = await client.PostAsync("Library/VirtualFolders/Name?name=+&newName=test", postContent).ConfigureAwait(false);
+
+ Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
+ }
+
+ [Fact]
+ public async Task RenameVirtualFolder_WhiteSpaceNewName_ReturnsBadRequest()
+ {
+ var client = _factory.CreateClient();
+ client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
+
+ using var postContent = new ByteArrayContent(Array.Empty<byte>());
+ var response = await client.PostAsync("Library/VirtualFolders/Name?name=test&newName=+", postContent).ConfigureAwait(false);
+
+ Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
+ }
+
+ [Fact]
+ public async Task RenameVirtualFolder_NameDoesntExist_ReturnsNotFound()
+ {
+ var client = _factory.CreateClient();
+ client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
+
+ using var postContent = new ByteArrayContent(Array.Empty<byte>());
+ var response = await client.PostAsync("Library/VirtualFolders/Name?name=doesnt+exist&newName=test", postContent).ConfigureAwait(false);
+
+ Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
+ }
+
+ [Fact]
public async Task AddMediaPath_PathDoesntExist_ReturnsNotFound()
{
var client = _factory.CreateClient();
@@ -59,12 +96,12 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
}
[Fact]
- public async Task RemoveMediaPath_EmptyName_ReturnsBadRequest()
+ public async Task RemoveMediaPath_WhiteSpaceName_ReturnsBadRequest()
{
var client = _factory.CreateClient();
client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client).ConfigureAwait(false));
- var response = await client.DeleteAsync("Library/VirtualFolders/Paths?name=").ConfigureAwait(false);
+ var response = await client.DeleteAsync("Library/VirtualFolders/Paths?name=+").ConfigureAwait(false);
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
}