From a07e8208ad1671876821f14fcbb9cd18b4c6eb1c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 03:04:46 +0000 Subject: [PATCH 1/3] feat: add collection and session sqlite configurations - Added `auth_api_sqlite_collection_file_path` and `auth_api_sqlite_collection_pool_size` - Added `auth_api_sqlite_session_file_path` and `auth_api_sqlite_session_pool_size` - Updated `DpsConfig::new()` to load these from environment variables - Added getters and setters with appropriate defaults - Updated README.md with new properties and environment variable examples - Added unit tests for new properties Co-authored-by: pauldps <1726774+pauldps@users.noreply.github.com> --- README.md | 8 +++ src/lib.rs | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+) diff --git a/README.md b/README.md index 3506786..b7955b3 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,10 @@ Each property has a getter (`get_()`) and a setter (`set_, auth_api_sqlite_main_file_path: Option, auth_api_sqlite_main_pool_size: Option, + auth_api_sqlite_collection_file_path: Option, + auth_api_sqlite_collection_pool_size: Option, + auth_api_sqlite_session_file_path: Option, + auth_api_sqlite_session_pool_size: Option, auth_api_session_secret: Option, auth_api_session_ttl_seconds: Option, } @@ -69,6 +73,10 @@ impl DpsConfig { /// - `DPS_AUTH_API_INSECURE_COOKIE` (use `"Y"` for true) /// - `DPS_AUTH_API_SQLITE_MAIN_FILE_PATH` /// - `DPS_AUTH_API_SQLITE_MAIN_POOL_SIZE` + /// - `DPS_AUTH_API_SQLITE_COLLECTION_FILE_PATH` + /// - `DPS_AUTH_API_SQLITE_COLLECTION_POOL_SIZE` + /// - `DPS_AUTH_API_SQLITE_SESSION_FILE_PATH` + /// - `DPS_AUTH_API_SQLITE_SESSION_POOL_SIZE` /// - `DPS_AUTH_API_SESSION_SECRET` /// - `DPS_AUTH_API_SESSION_TTL_SECONDS` pub fn new() -> Self { @@ -82,6 +90,12 @@ impl DpsConfig { auth_api_insecure_cookie: load_env_bool("DPS_AUTH_API_INSECURE_COOKIE"), auth_api_sqlite_main_file_path: load_env_string("DPS_AUTH_API_SQLITE_MAIN_FILE_PATH"), auth_api_sqlite_main_pool_size: load_env_u16("DPS_AUTH_API_SQLITE_MAIN_POOL_SIZE"), + auth_api_sqlite_collection_file_path: load_env_string( + "DPS_AUTH_API_SQLITE_COLLECTION_FILE_PATH", + ), + auth_api_sqlite_collection_pool_size: load_env_u16("DPS_AUTH_API_SQLITE_COLLECTION_POOL_SIZE"), + auth_api_sqlite_session_file_path: load_env_string("DPS_AUTH_API_SQLITE_SESSION_FILE_PATH"), + auth_api_sqlite_session_pool_size: load_env_u16("DPS_AUTH_API_SQLITE_SESSION_POOL_SIZE"), auth_api_session_secret: load_env_string("DPS_AUTH_API_SESSION_SECRET"), auth_api_session_ttl_seconds: load_env_u32("DPS_AUTH_API_SESSION_TTL_SECONDS"), } @@ -219,6 +233,66 @@ impl DpsConfig { self.auth_api_sqlite_main_pool_size = value; } + /// Returns the SQLite collection database file path for the Auth API or + /// default `"data/collection-development.db"`. + /// + /// Env var: `DPS_AUTH_API_SQLITE_COLLECTION_FILE_PATH` + pub fn get_auth_api_sqlite_collection_file_path(&self) -> String { + self + .auth_api_sqlite_collection_file_path + .clone() + .unwrap_or_else(|| "data/collection-development.db".to_string()) + } + + /// Set the SQLite collection database file path for Auth API. + pub fn set_auth_api_sqlite_collection_file_path(&mut self, value: &str) { + self.auth_api_sqlite_collection_file_path = Some(value.to_string()); + } + + /// Returns the SQLite collection database connection pool size for Auth API. + /// Defaults to `1`. + /// + /// Env var: `DPS_AUTH_API_SQLITE_COLLECTION_POOL_SIZE` + pub fn get_auth_api_sqlite_collection_pool_size(&self) -> u16 { + self.auth_api_sqlite_collection_pool_size.unwrap_or(1) + } + + /// Set the SQLite collection database connection pool size for Auth API. + /// Use `None` to reset to default. + pub fn set_auth_api_sqlite_collection_pool_size(&mut self, value: Option) { + self.auth_api_sqlite_collection_pool_size = value; + } + + /// Returns the SQLite session database file path for the Auth API or default + /// `"data/session-development.db"`. + /// + /// Env var: `DPS_AUTH_API_SQLITE_SESSION_FILE_PATH` + pub fn get_auth_api_sqlite_session_file_path(&self) -> String { + self + .auth_api_sqlite_session_file_path + .clone() + .unwrap_or_else(|| "data/session-development.db".to_string()) + } + + /// Set the SQLite session database file path for Auth API. + pub fn set_auth_api_sqlite_session_file_path(&mut self, value: &str) { + self.auth_api_sqlite_session_file_path = Some(value.to_string()); + } + + /// Returns the SQLite session database connection pool size for Auth API. + /// Defaults to `1`. + /// + /// Env var: `DPS_AUTH_API_SQLITE_SESSION_POOL_SIZE` + pub fn get_auth_api_sqlite_session_pool_size(&self) -> u16 { + self.auth_api_sqlite_session_pool_size.unwrap_or(1) + } + + /// Set the SQLite session database connection pool size for Auth API. + /// Use `None` to reset to default. + pub fn set_auth_api_sqlite_session_pool_size(&mut self, value: Option) { + self.auth_api_sqlite_session_pool_size = value; + } + /// Returns the auth API session secret as an owned `String`, if configured. /// /// Env var: `DPS_AUTH_API_SESSION_SECRET` @@ -330,6 +404,16 @@ mod tests { "data/main-development.db" ); assert_eq!(config.get_auth_api_sqlite_main_pool_size(), 1); + assert_eq!( + config.get_auth_api_sqlite_collection_file_path(), + "data/collection-development.db" + ); + assert_eq!(config.get_auth_api_sqlite_collection_pool_size(), 1); + assert_eq!( + config.get_auth_api_sqlite_session_file_path(), + "data/session-development.db" + ); + assert_eq!(config.get_auth_api_sqlite_session_pool_size(), 1); assert!(config.get_auth_api_port().is_none()); assert!(config.get_auth_api_session_secret().is_none()); assert!(config.get_auth_api_session_secret_bytes().is_none()); @@ -440,6 +524,98 @@ mod tests { std::env::remove_var("DPS_AUTH_API_SQLITE_MAIN_FILE_PATH"); } + #[test] + #[serial] + fn test_auth_api_sqlite_collection_pool_size() { + // Test default and setter + let mut c = DpsConfig::new(); + assert_eq!(c.get_auth_api_sqlite_collection_pool_size(), 1); + c.set_auth_api_sqlite_collection_pool_size(Some(12)); + assert_eq!(c.get_auth_api_sqlite_collection_pool_size(), 12); + c.set_auth_api_sqlite_collection_pool_size(None); + assert_eq!(c.get_auth_api_sqlite_collection_pool_size(), 1); + + // Test env var loading + std::env::set_var("DPS_AUTH_API_SQLITE_COLLECTION_POOL_SIZE", "8"); + let c2 = DpsConfig::new(); + assert_eq!(c2.get_auth_api_sqlite_collection_pool_size(), 8); + std::env::remove_var("DPS_AUTH_API_SQLITE_COLLECTION_POOL_SIZE"); + } + + #[test] + #[serial] + fn test_auth_api_sqlite_collection_file_path() { + // Test default and setter + let mut c = DpsConfig::new(); + assert_eq!( + c.get_auth_api_sqlite_collection_file_path(), + "data/collection-development.db" + ); + c.set_auth_api_sqlite_collection_file_path("data/custom-collection.db"); + assert_eq!( + c.get_auth_api_sqlite_collection_file_path(), + "data/custom-collection.db" + ); + + // Test env var loading + std::env::set_var( + "DPS_AUTH_API_SQLITE_COLLECTION_FILE_PATH", + "data/test-collection.db", + ); + let c2 = DpsConfig::new(); + assert_eq!( + c2.get_auth_api_sqlite_collection_file_path(), + "data/test-collection.db" + ); + std::env::remove_var("DPS_AUTH_API_SQLITE_COLLECTION_FILE_PATH"); + } + + #[test] + #[serial] + fn test_auth_api_sqlite_session_pool_size() { + // Test default and setter + let mut c = DpsConfig::new(); + assert_eq!(c.get_auth_api_sqlite_session_pool_size(), 1); + c.set_auth_api_sqlite_session_pool_size(Some(12)); + assert_eq!(c.get_auth_api_sqlite_session_pool_size(), 12); + c.set_auth_api_sqlite_session_pool_size(None); + assert_eq!(c.get_auth_api_sqlite_session_pool_size(), 1); + + // Test env var loading + std::env::set_var("DPS_AUTH_API_SQLITE_SESSION_POOL_SIZE", "8"); + let c2 = DpsConfig::new(); + assert_eq!(c2.get_auth_api_sqlite_session_pool_size(), 8); + std::env::remove_var("DPS_AUTH_API_SQLITE_SESSION_POOL_SIZE"); + } + + #[test] + #[serial] + fn test_auth_api_sqlite_session_file_path() { + // Test default and setter + let mut c = DpsConfig::new(); + assert_eq!( + c.get_auth_api_sqlite_session_file_path(), + "data/session-development.db" + ); + c.set_auth_api_sqlite_session_file_path("data/custom-session.db"); + assert_eq!( + c.get_auth_api_sqlite_session_file_path(), + "data/custom-session.db" + ); + + // Test env var loading + std::env::set_var( + "DPS_AUTH_API_SQLITE_SESSION_FILE_PATH", + "data/test-session.db", + ); + let c2 = DpsConfig::new(); + assert_eq!( + c2.get_auth_api_sqlite_session_file_path(), + "data/test-session.db" + ); + std::env::remove_var("DPS_AUTH_API_SQLITE_SESSION_FILE_PATH"); + } + #[test] fn test_auth_api_session_secret_bytes() { let mut config = DpsConfig::new(); From fa18de2a77a53a5ef406a72eadb3915a77d2960d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 03:07:47 +0000 Subject: [PATCH 2/3] fix: format code with cargo fmt Co-authored-by: pauldps <1726774+pauldps@users.noreply.github.com> --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 6515b2f..0c3ed4e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -93,7 +93,9 @@ impl DpsConfig { auth_api_sqlite_collection_file_path: load_env_string( "DPS_AUTH_API_SQLITE_COLLECTION_FILE_PATH", ), - auth_api_sqlite_collection_pool_size: load_env_u16("DPS_AUTH_API_SQLITE_COLLECTION_POOL_SIZE"), + auth_api_sqlite_collection_pool_size: load_env_u16( + "DPS_AUTH_API_SQLITE_COLLECTION_POOL_SIZE", + ), auth_api_sqlite_session_file_path: load_env_string("DPS_AUTH_API_SQLITE_SESSION_FILE_PATH"), auth_api_sqlite_session_pool_size: load_env_u16("DPS_AUTH_API_SQLITE_SESSION_POOL_SIZE"), auth_api_session_secret: load_env_string("DPS_AUTH_API_SESSION_SECRET"), From 5fd638b89d06553a9a49d51a2d9a65559a8f08d5 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 03:52:45 +0000 Subject: [PATCH 3/3] feat: add collection and session sqlite configurations - Added collection and session SQLite configurations - Updated README.md - Added tests - Formatted code with cargo fmt Co-authored-by: pauldps <1726774+pauldps@users.noreply.github.com>