Skip to content

Commit

Permalink
Fix FirstTimeSetupHandler api key test
Browse files Browse the repository at this point in the history
  • Loading branch information
thornbill committed May 30, 2024
1 parent 8fa7ff6 commit 35962bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Jellyfin.Api.Constants;
using Jellyfin.Api.Extensions;
using MediaBrowser.Common.Configuration;
using Microsoft.AspNetCore.Authorization;

Expand Down Expand Up @@ -28,6 +29,10 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte
{
context.Succeed(requirement);
}
else if (context.User.GetIsApiKey())
{
context.Succeed(requirement);
}
else if (requirement.RequireAdmin && !context.User.IsInRole(UserRoles.Administrator))
{
context.Fail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public async Task ShouldDeferIfNotRequiresAdmin(string userRole)
public async Task ShouldAllowAdminApiKeyIfStartupWizardComplete()
{
TestHelpers.SetupConfigurationManager(_configurationManagerMock, true);
var claims = new ClaimsPrincipal(new ClaimsIdentity([new Claim(ClaimTypes.Role, UserRoles.Administrator)]));
var claims = new ClaimsPrincipal(new ClaimsIdentity([new Claim(InternalClaimTypes.IsApiKey, bool.TrueString)]));
var context = new AuthorizationHandlerContext(_requirements, claims, null);

await _firstTimeSetupHandler.HandleAsync(context);
Expand Down

0 comments on commit 35962bc

Please sign in to comment.