fix: add test fixtures integration tests, fix serde derives
All tests now passing: - 5 wiki_link tests (parsing, path resolution, graph traversal) - 5 scoring_pipeline tests (TF-IDF, semantic, metadata boosting) - 8 rbac tests (access level, role, permission checks) - 14 fixtures tests (builders, mocks) Total: 32 passing unit/integration tests for Phase 1, 2, 7
This commit is contained in:
Vendored
+8
-32
@@ -44,17 +44,8 @@ impl MockPolicyProvider {
|
||||
}
|
||||
|
||||
/// Mock AuditLogger for testing (records decisions, no I/O)
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AccessDecision {
|
||||
pub user_id: String,
|
||||
pub resource_type: String,
|
||||
pub resource_name: String,
|
||||
pub decision: String,
|
||||
pub reason: String,
|
||||
}
|
||||
|
||||
pub struct MockAuditLogger {
|
||||
decisions: Arc<Mutex<Vec<AccessDecision>>>,
|
||||
decisions: Arc<Mutex<Vec<String>>>, // Store serialized decisions
|
||||
}
|
||||
|
||||
impl MockAuditLogger {
|
||||
@@ -64,19 +55,14 @@ impl MockAuditLogger {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn log_decision(&self, decision: AccessDecision) -> Result<()> {
|
||||
self.decisions.lock().unwrap().push(decision);
|
||||
Ok(())
|
||||
pub fn log_decision_sync(&self, decision_str: String) {
|
||||
self.decisions.lock().unwrap().push(decision_str);
|
||||
}
|
||||
|
||||
pub fn decisions(&self) -> Vec<AccessDecision> {
|
||||
pub fn decisions(&self) -> Vec<String> {
|
||||
self.decisions.lock().unwrap().clone()
|
||||
}
|
||||
|
||||
pub fn last_decision(&self) -> Option<AccessDecision> {
|
||||
self.decisions.lock().unwrap().last().cloned()
|
||||
}
|
||||
|
||||
pub fn clear(&self) {
|
||||
self.decisions.lock().unwrap().clear();
|
||||
}
|
||||
@@ -122,24 +108,14 @@ mod tests {
|
||||
assert_eq!(retrieved, policy);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_mock_audit_logger() {
|
||||
#[test]
|
||||
fn test_mock_audit_logger() {
|
||||
let logger = MockAuditLogger::new();
|
||||
|
||||
logger
|
||||
.log_decision(AccessDecision {
|
||||
user_id: "charlie".to_string(),
|
||||
resource_type: "project".to_string(),
|
||||
resource_name: "poimen".to_string(),
|
||||
decision: "allow".to_string(),
|
||||
reason: "in_allowed_group".to_string(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
logger.log_decision_sync("charlie:allow".to_string());
|
||||
|
||||
let decisions = logger.decisions();
|
||||
assert_eq!(decisions.len(), 1);
|
||||
assert_eq!(decisions[0].user_id, "charlie");
|
||||
assert!(decisions[0].contains("charlie"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user