2024-08-30 15:29:48 +02:00
|
|
|
using System;
|
2021-02-17 11:30:14 +01:00
|
|
|
using Jellyfin.Server.Implementations.Users;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Jellyfin.Server.Implementations.Tests.Users
|
|
|
|
|
{
|
|
|
|
|
public class UserManagerTests
|
|
|
|
|
{
|
|
|
|
|
[Theory]
|
2021-02-17 11:51:15 +01:00
|
|
|
[InlineData("this_is_valid")]
|
|
|
|
|
[InlineData("this is also valid")]
|
|
|
|
|
[InlineData("0@_-' .")]
|
2024-11-03 07:43:27 -07:00
|
|
|
[InlineData("Aa0@_-' .+")]
|
|
|
|
|
[InlineData("thisisa+testemail@test.foo")]
|
|
|
|
|
[InlineData("------@@@--+++----@@--abcdefghijklmn---------@----_-_-___-_ .9foo+")]
|
2021-02-17 11:51:15 +01:00
|
|
|
public void ThrowIfInvalidUsername_WhenValidUsername_DoesNotThrowArgumentException(string username)
|
2021-02-17 11:30:14 +01:00
|
|
|
{
|
|
|
|
|
var ex = Record.Exception(() => UserManager.ThrowIfInvalidUsername(username));
|
2021-02-17 11:51:15 +01:00
|
|
|
Assert.Null(ex);
|
|
|
|
|
}
|
2021-02-17 11:30:14 +01:00
|
|
|
|
2021-02-17 11:51:15 +01:00
|
|
|
[Theory]
|
|
|
|
|
[InlineData(" ")]
|
|
|
|
|
[InlineData("")]
|
|
|
|
|
[InlineData("special characters like & $ ? are not allowed")]
|
2025-02-14 17:49:25 +00:00
|
|
|
[InlineData("thishasaspaceontheend ")]
|
|
|
|
|
[InlineData(" thishasaspaceatthestart")]
|
|
|
|
|
[InlineData(" thishasaspaceatbothends ")]
|
|
|
|
|
[InlineData(" this has a space at both ends and inbetween ")]
|
2021-02-17 11:51:15 +01:00
|
|
|
public void ThrowIfInvalidUsername_WhenInvalidUsername_ThrowsArgumentException(string username)
|
|
|
|
|
{
|
|
|
|
|
Assert.Throws<ArgumentException>(() => UserManager.ThrowIfInvalidUsername(username));
|
2021-02-17 11:30:14 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|