// Copyright (c) 2026 Kirky.X
//
// Licensed under the MIT License
// See LICENSE file in the project root for full license information.

//! Advanced RBAC Provider 单元测试
//!
//! 测试高级RBAC提供者的角色继承功能

#[cfg(test)]
mod tests {
    use dbnexus::permission::advanced::AdvancedRbacProvider;
    use dbnexus::permission::provider::{PermissionContext, PermissionProvider};

    #[tokio::test]
    async fn test_role_inheritance() {
        let provider = AdvancedRbacProvider::new();
        // 配置角色继承：manager 继承 admin
        provider.add_role_inheritance("manager".to_string(), vec!["admin".to_string()]);

        let context = PermissionContext {
            subject: "manager".to_string(),
            resource: "users".to_string(),
            action: "SELECT".to_string(),
        };
        let decision = provider.check_permission(&context).await;
        assert_eq!(decision, dbnexus::permission::provider::PermissionDecision::Allow);
    }
}
