Moved test project to correct folder
This commit is contained in:
57
tests/HopFrame.Database.Tests/PermissionValidatorTests.cs
Normal file
57
tests/HopFrame.Database.Tests/PermissionValidatorTests.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
namespace HopFrame.Database.Tests;
|
||||
|
||||
public class PermissionValidatorTests {
|
||||
|
||||
[Fact]
|
||||
public void IncludesPermission_Returns_True_For_ExactPermission() {
|
||||
// Arrange
|
||||
var permissions = new [] { "test.permission", "test.permission.exact" };
|
||||
var permission = "test.permission.exact";
|
||||
|
||||
// Act
|
||||
var hasPermission = PermissionValidator.IncludesPermission(permission, permissions);
|
||||
|
||||
// Assert
|
||||
Assert.True(hasPermission);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IncludesPermission_Returns_True_For_GroupPermission() {
|
||||
// Arrange
|
||||
var permissions = new [] { "test.permission.*", "test.permission.exact" };
|
||||
var permission = "test.permission.exact.other";
|
||||
|
||||
// Act
|
||||
var hasPermission = PermissionValidator.IncludesPermission(permission, permissions);
|
||||
|
||||
// Assert
|
||||
Assert.True(hasPermission);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IncludesPermission_Returns_True_For_StarPermission() {
|
||||
// Arrange
|
||||
var permissions = new [] { "test.permission", "test.permission.exact", "*" };
|
||||
var permission = "test.permission.exact.other";
|
||||
|
||||
// Act
|
||||
var hasPermission = PermissionValidator.IncludesPermission(permission, permissions);
|
||||
|
||||
// Assert
|
||||
Assert.True(hasPermission);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IncludesPermission_Returns_False() {
|
||||
// Arrange
|
||||
var permissions = new [] { "test.permission", "test.permission.exact" };
|
||||
var permission = "test.permission.exact.other";
|
||||
|
||||
// Act
|
||||
var hasPermission = PermissionValidator.IncludesPermission(permission, permissions);
|
||||
|
||||
// Assert
|
||||
Assert.False(hasPermission);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user