aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2026-07-05 15:59:14 +0200
committerGitHub <noreply@github.com>2026-07-05 15:59:14 +0200
commit8433773fadefbf61e2e5a852f8b3e88262e47496 (patch)
tree24c6130eed1f0eb0044167d45b7090d38759e9e7
parent381bf181616c2294b739b97df6c0fa062dbd25c9 (diff)
parent482cf4b8c3e78463b61cac01c0f3a38fe2045a5c (diff)
Allow changing capitalization of usernames (#17229)
Fixes #17195 Adds a regression test
-rw-r--r--Jellyfin.Server.Implementations/Users/UserManager.cs2
-rw-r--r--tests/Jellyfin.Server.Integration.Tests/Controllers/UserControllerTests.cs29
2 files changed, 29 insertions, 2 deletions
diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.cs
index 9be2eac4a1..80722af106 100644
--- a/Jellyfin.Server.Implementations/Users/UserManager.cs
+++ b/Jellyfin.Server.Implementations/Users/UserManager.cs
@@ -170,7 +170,7 @@ namespace Jellyfin.Server.Implementations.Users
{
ThrowIfInvalidUsername(newName);
- if (oldName.Equals(newName, StringComparison.OrdinalIgnoreCase))
+ if (oldName.Equals(newName, StringComparison.Ordinal))
{
throw new ArgumentException("The new and old names must be different.");
}
diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/UserControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/UserControllerTests.cs
index 7ea56be731..4e01282dcf 100644
--- a/tests/Jellyfin.Server.Integration.Tests/Controllers/UserControllerTests.cs
+++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/UserControllerTests.cs
@@ -1,6 +1,5 @@
using System;
using System.Globalization;
-using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
@@ -164,5 +163,33 @@ namespace Jellyfin.Server.Integration.Tests.Controllers
using var response = await UpdateUserPassword(client, _testUserId, createRequest);
Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
}
+
+ [Fact]
+ [Priority(2)]
+ public async Task UpdateUser_UsernameCaseDifference_Success()
+ {
+ var client = _factory.CreateClient();
+
+ client.DefaultRequestHeaders.AddAuthHeader(_accessToken!);
+
+ using var response = await client.GetAsync("Users/" + _testUserId, TestContext.Current.CancellationToken);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ var userDto = await response.Content.ReadFromJsonAsync<UserDto>(JsonDefaults.Options, TestContext.Current.CancellationToken);
+ Assert.NotNull(userDto);
+
+ userDto.Name = userDto.Name.ToLowerInvariant();
+
+ using var response2 = await client.PostAsJsonAsync($"Users?userId={_testUserId}", userDto, _jsonOptions, TestContext.Current.CancellationToken);
+ Assert.Equal(HttpStatusCode.NoContent, response2.StatusCode);
+
+ using var response3 = await client.GetAsync("Users/" + _testUserId, TestContext.Current.CancellationToken);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ var newUserDto = await response3.Content.ReadFromJsonAsync<UserDto>(JsonDefaults.Options, TestContext.Current.CancellationToken);
+ Assert.NotNull(newUserDto);
+ Assert.Equal(userDto.Name, newUserDto.Name);
+
+ // Sanity check, make sure we're testing something
+ Assert.NotEqual(TestUsername, userDto.Name);
+ }
}
}