test(backend): add auth token and security policy tests
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user