test(backend): add auth token and security policy tests

This commit is contained in:
Rafał Tyński
2026-10-04 02:12:00 +02:00
parent dcaa1a77db
commit c163db3029
2 changed files with 97 additions and 0 deletions
@@ -0,0 +1,34 @@
using TarninaHub.Application.Security;
using TarninaHub.Infrastructure.Auth;
namespace TarninaHub.Tests.Auth;
public class SecurityConstantsTests
{
[Theory]
[InlineData("user", true)]
[InlineData("jst", true)]
[InlineData("operator", true)]
[InlineData("manager", true)]
[InlineData("admin", true)]
[InlineData("guest", false)]
public void RoleNames_IsValid_RecognizesKnownRoles(string role, bool expected)
{
Assert.Equal(expected, RoleNames.IsValid(role));
}
[Fact]
public void AuthSettings_HasUsableSigningKey_RequiresAtLeast32Chars()
{
Assert.False(new AuthSettings { SigningKey = "short" }.HasUsableSigningKey);
Assert.True(new AuthSettings { SigningKey = new string('k', 32) }.HasUsableSigningKey);
}
[Fact]
public void ConsentScopes_ContainsExpectedLevels()
{
Assert.Contains(ConsentScopes.ByConsent, ConsentScopes.All);
Assert.Contains(ConsentScopes.Temporary, ConsentScopes.All);
Assert.Contains(ConsentScopes.Anonymized, ConsentScopes.All);
}
}