app: add organization + sharing commands/queries

This commit is contained in:
2026-05-31 05:17:51 +02:00
parent 536bf3463a
commit d1394ce7bb
29 changed files with 740 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
use std::sync::Arc;
use application::testing::InMemoryShareRepository;
use application::sharing::{GenerateShareLinkCommand, GenerateShareLinkHandler};
use domain::entities::{LinkAccessLevel, ScopeType, ShareableType};
use domain::value_objects::{DateTimeStamp, SystemId};
#[tokio::test]
async fn generates_link() {
let share_repo = Arc::new(InMemoryShareRepository::new());
let handler = GenerateShareLinkHandler::new(share_repo);
let (scope, link) = handler.execute(GenerateShareLinkCommand {
shareable_type: ShareableType::Album,
shareable_id: SystemId::new(),
access_level: LinkAccessLevel::ViewOnly,
created_by: SystemId::new(),
expires_at: None,
max_uses: None,
}).await.unwrap();
assert_eq!(scope.scope_type, ScopeType::Link);
assert!(!link.token.is_empty());
assert_eq!(link.access_level, LinkAccessLevel::ViewOnly);
assert!(link.expires_at.is_none());
assert!(link.max_uses.is_none());
}
#[tokio::test]
async fn generates_link_with_expiry_and_max_uses() {
let share_repo = Arc::new(InMemoryShareRepository::new());
let handler = GenerateShareLinkHandler::new(share_repo);
let expiry = DateTimeStamp::now();
let (_, link) = handler.execute(GenerateShareLinkCommand {
shareable_type: ShareableType::Collection,
shareable_id: SystemId::new(),
access_level: LinkAccessLevel::LimitedSearch,
created_by: SystemId::new(),
expires_at: Some(expiry),
max_uses: Some(10),
}).await.unwrap();
assert!(link.expires_at.is_some());
assert_eq!(link.max_uses, Some(10));
assert_eq!(link.access_level, LinkAccessLevel::LimitedSearch);
}