refactor(tests): reformat code and update dependency management
- Reorganized import statements in adapter tests for better readability - Replaced or_insert_with(Vec::new) with or_default() in test closures - Updated Cargo.lock with new dependency versions and checksums - Added TLS features to tonic dependency configuration - Included sqlx, chrono, and uuid dependencies with specific features - Added jsonwebtoken and arc-swap as project dependencies - Reformatted assertion statements to comply with line length limits - Adjusted base64 import order in engine codec module - Updated protobuf include statement formatting
This commit is contained in:
@@ -36,7 +36,12 @@ impl RedisSessionStore {
|
||||
|
||||
#[async_trait]
|
||||
impl SessionStoreTrait for RedisSessionStore {
|
||||
async fn create(&self, sid: &str, transport: &str, server_id: &str) -> Result<(), SessionError> {
|
||||
async fn create(
|
||||
&self,
|
||||
sid: &str,
|
||||
transport: &str,
|
||||
server_id: &str,
|
||||
) -> Result<(), SessionError> {
|
||||
let key = self.key(sid);
|
||||
let now = now_millis();
|
||||
|
||||
@@ -67,7 +72,8 @@ impl SessionStoreTrait for RedisSessionStore {
|
||||
|
||||
// Use hgetall directly — if the key doesn't exist Redis returns an empty map.
|
||||
// This avoids the TOCTOU race between EXISTS and HGETALL.
|
||||
let values: std::collections::HashMap<String, String> = self.client
|
||||
let values: std::collections::HashMap<String, String> = self
|
||||
.client
|
||||
.hgetall::<std::collections::HashMap<String, String>, _>(&key)
|
||||
.await
|
||||
.map_err(|e| SessionError::Redis(e.to_string()))?;
|
||||
@@ -81,8 +87,14 @@ impl SessionStoreTrait for RedisSessionStore {
|
||||
transport: values.get("transport").cloned().unwrap_or_default(),
|
||||
state: values.get("state").cloned().unwrap_or_default(),
|
||||
server_id: values.get("server_id").cloned().unwrap_or_default(),
|
||||
created_at: values.get("created_at").and_then(|v| v.parse::<u64>().ok()).unwrap_or(0),
|
||||
last_ping: values.get("last_ping").and_then(|v| v.parse::<u64>().ok()).unwrap_or(0),
|
||||
created_at: values
|
||||
.get("created_at")
|
||||
.and_then(|v| v.parse::<u64>().ok())
|
||||
.unwrap_or(0),
|
||||
last_ping: values
|
||||
.get("last_ping")
|
||||
.and_then(|v| v.parse::<u64>().ok())
|
||||
.unwrap_or(0),
|
||||
};
|
||||
|
||||
Ok(Some(info))
|
||||
@@ -154,11 +166,12 @@ impl SessionStoreTrait for RedisSessionStore {
|
||||
async fn exists(&self, sid: &str) -> Result<bool, SessionError> {
|
||||
let key = self.key(sid);
|
||||
|
||||
let exists: bool = self.client
|
||||
let exists: bool = self
|
||||
.client
|
||||
.exists::<bool, _>(&key)
|
||||
.await
|
||||
.map_err(|e| SessionError::Redis(e.to_string()))?;
|
||||
|
||||
Ok(exists)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user