aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2021-02-18 17:52:25 +0100
committerJoshua M. Boniface <joshua@boniface.me>2021-02-21 13:30:32 -0500
commitbd89cdf8d2a27d277cfff1f88062a77916581506 (patch)
treebb8dc573290e128d6edfabfcab2e609ec00e11c4 /tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs
parent557a09186562e20cb9a6cc3dc696663416a0c612 (diff)
Merge pull request #5255 from cvium/fix_renameuser
(cherry picked from commit ae30eaf32055c8c80a7c912e7683527f8713619b) Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
Diffstat (limited to 'tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs')
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs
new file mode 100644
index 0000000000..867dda29d6
--- /dev/null
+++ b/tests/Jellyfin.Server.Implementations.Tests/Users/UserManagerTests.cs
@@ -0,0 +1,28 @@
+using System;
+using Jellyfin.Server.Implementations.Users;
+using Xunit;
+
+namespace Jellyfin.Server.Implementations.Tests.Users
+{
+ public class UserManagerTests
+ {
+ [Theory]
+ [InlineData("this_is_valid")]
+ [InlineData("this is also valid")]
+ [InlineData("0@_-' .")]
+ public void ThrowIfInvalidUsername_WhenValidUsername_DoesNotThrowArgumentException(string username)
+ {
+ var ex = Record.Exception(() => UserManager.ThrowIfInvalidUsername(username));
+ Assert.Null(ex);
+ }
+
+ [Theory]
+ [InlineData(" ")]
+ [InlineData("")]
+ [InlineData("special characters like & $ ? are not allowed")]
+ public void ThrowIfInvalidUsername_WhenInvalidUsername_ThrowsArgumentException(string username)
+ {
+ Assert.Throws<ArgumentException>(() => UserManager.ThrowIfInvalidUsername(username));
+ }
+ }
+}