aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs')
-rw-r--r--tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs b/tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs
index 3b3d03c8b..0cb8d8be6 100644
--- a/tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs
+++ b/tests/Jellyfin.Api.Tests/Auth/CustomAuthenticationHandlerTests.cs
@@ -7,6 +7,7 @@ using AutoFixture;
using AutoFixture.AutoMoq;
using Jellyfin.Api.Auth;
using Jellyfin.Api.Constants;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Net;
using Microsoft.AspNetCore.Authentication;
@@ -83,7 +84,7 @@ namespace Jellyfin.Api.Tests.Auth
a => a.Authenticate(
It.IsAny<HttpRequest>(),
It.IsAny<AuthenticatedAttribute>()))
- .Returns((User?)null);
+ .Returns((Jellyfin.Data.Entities.User?)null);
var authenticateResult = await _sut.AuthenticateAsync();
@@ -124,7 +125,7 @@ namespace Jellyfin.Api.Tests.Auth
var user = SetupUser();
var authenticateResult = await _sut.AuthenticateAsync();
- Assert.True(authenticateResult.Principal.HasClaim(ClaimTypes.Name, user.Name));
+ Assert.True(authenticateResult.Principal.HasClaim(ClaimTypes.Name, user.Username));
}
[Theory]
@@ -135,7 +136,7 @@ namespace Jellyfin.Api.Tests.Auth
var user = SetupUser(isAdmin);
var authenticateResult = await _sut.AuthenticateAsync();
- var expectedRole = user.Policy.IsAdministrator ? UserRoles.Administrator : UserRoles.User;
+ var expectedRole = user.HasPermission(PermissionKind.IsAdministrator) ? UserRoles.Administrator : UserRoles.User;
Assert.True(authenticateResult.Principal.HasClaim(ClaimTypes.Role, expectedRole));
}
@@ -148,10 +149,10 @@ namespace Jellyfin.Api.Tests.Auth
Assert.Equal(_scheme.Name, authenticatedResult.Ticket.AuthenticationScheme);
}
- private User SetupUser(bool isAdmin = false)
+ private Jellyfin.Data.Entities.User SetupUser(bool isAdmin = false)
{
- var user = _fixture.Create<User>();
- user.Policy.IsAdministrator = isAdmin;
+ var user = _fixture.Create<Jellyfin.Data.Entities.User>();
+ user.SetPermission(PermissionKind.IsAdministrator, isAdmin);
_jellyfinAuthServiceMock.Setup(
a => a.Authenticate(