2021-02-17 10:30:14 +00:00
|
|
|
|
using System;
|
|
|
|
|
using Jellyfin.Server.Implementations.Users;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Jellyfin.Server.Implementations.Tests.Users
|
|
|
|
|
{
|
|
|
|
|
public class UserManagerTests
|
|
|
|
|
{
|
|
|
|
|
[Theory]
|
2021-02-17 10:51:15 +00:00
|
|
|
|
[InlineData("this_is_valid")]
|
|
|
|
|
[InlineData("this is also valid")]
|
|
|
|
|
[InlineData("0@_-' .")]
|
|
|
|
|
public void ThrowIfInvalidUsername_WhenValidUsername_DoesNotThrowArgumentException(string username)
|
2021-02-17 10:30:14 +00:00
|
|
|
|
{
|
|
|
|
|
var ex = Record.Exception(() => UserManager.ThrowIfInvalidUsername(username));
|
2021-02-17 10:51:15 +00:00
|
|
|
|
Assert.Null(ex);
|
|
|
|
|
}
|
2021-02-17 10:30:14 +00:00
|
|
|
|
|
2021-02-17 10:51:15 +00:00
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData(" ")]
|
|
|
|
|
[InlineData("")]
|
|
|
|
|
[InlineData("special characters like & $ ? are not allowed")]
|
|
|
|
|
public void ThrowIfInvalidUsername_WhenInvalidUsername_ThrowsArgumentException(string username)
|
|
|
|
|
{
|
|
|
|
|
Assert.Throws<ArgumentException>(() => UserManager.ThrowIfInvalidUsername(username));
|
2021-02-17 10:30:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|