auth_framework/tenant/
mod.rs1pub mod context;
8pub mod registry;
9
10pub use context::{TenantContext, TenantId, TenantMetadata};
11pub use registry::{TenantRegistry, TenantRegistryError};
12
13use crate::config::AuthConfig;
14
15pub struct TenantRegistryBuilder {
17 default_config: AuthConfig,
18}
19
20impl TenantRegistryBuilder {
21 pub fn new() -> Self {
23 Self {
24 default_config: AuthConfig::default(),
25 }
26 }
27
28 pub fn with_config(mut self, config: AuthConfig) -> Self {
30 self.default_config = config;
31 self
32 }
33
34 pub fn build(self) -> TenantRegistry {
36 TenantRegistry::new(self.default_config)
37 }
38}
39
40impl Default for TenantRegistryBuilder {
41 fn default() -> Self {
42 Self::new()
43 }
44}
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[tokio::test]
51 async fn test_tenant_registry_builder() {
52 let registry = TenantRegistryBuilder::new().build();
53 assert_eq!(registry.tenant_count().await, 0);
54 }
55}