style: cargo fmt --all
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use domain::entities::permission::{
|
||||
admin_permissions, contributor_permissions, viewer_permissions,
|
||||
Permission, PermissionAction, ResourceType,
|
||||
Permission, PermissionAction, ResourceType, admin_permissions, contributor_permissions,
|
||||
viewer_permissions,
|
||||
};
|
||||
use domain::entities::{Group, Role, User};
|
||||
use domain::errors::DomainError;
|
||||
@@ -36,8 +36,16 @@ fn role_checks_permission() {
|
||||
|
||||
#[test]
|
||||
fn creates_user_with_unique_id() {
|
||||
let a = User::new("alice", Email::new("a@example.com").unwrap(), PasswordHash::from_hash("h".into()));
|
||||
let b = User::new("bob", Email::new("b@example.com").unwrap(), PasswordHash::from_hash("h".into()));
|
||||
let a = User::new(
|
||||
"alice",
|
||||
Email::new("a@example.com").unwrap(),
|
||||
PasswordHash::from_hash("h".into()),
|
||||
);
|
||||
let b = User::new(
|
||||
"bob",
|
||||
Email::new("b@example.com").unwrap(),
|
||||
PasswordHash::from_hash("h".into()),
|
||||
);
|
||||
assert_ne!(a.id, b.id);
|
||||
assert_eq!(a.username, "alice");
|
||||
assert_eq!(b.username, "bob");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use domain::entities::{Permission, PermissionAction, ResourceType, Role};
|
||||
use domain::entities::permission::{admin_permissions, viewer_permissions};
|
||||
use domain::entities::{Permission, PermissionAction, ResourceType, Role};
|
||||
use domain::services::permission_service::PermissionChecker;
|
||||
|
||||
#[test]
|
||||
@@ -24,8 +24,24 @@ fn viewer_cannot_delete() {
|
||||
|
||||
#[test]
|
||||
fn roles_additive() {
|
||||
let r1 = Role::new("r1", [Permission::new(PermissionAction::ReadAsset, ResourceType::Global)].into(), false);
|
||||
let r2 = Role::new("r2", [Permission::new(PermissionAction::WriteMetadata, ResourceType::Global)].into(), false);
|
||||
let r1 = Role::new(
|
||||
"r1",
|
||||
[Permission::new(
|
||||
PermissionAction::ReadAsset,
|
||||
ResourceType::Global,
|
||||
)]
|
||||
.into(),
|
||||
false,
|
||||
);
|
||||
let r2 = Role::new(
|
||||
"r2",
|
||||
[Permission::new(
|
||||
PermissionAction::WriteMetadata,
|
||||
ResourceType::Global,
|
||||
)]
|
||||
.into(),
|
||||
false,
|
||||
);
|
||||
let eff = PermissionChecker::effective_permissions(&[r1, r2]);
|
||||
assert_eq!(eff.len(), 2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user