scim-server 0.4.0

A comprehensive SCIM 2.0 server library for Rust with multi-tenant support and type-safe operations
Documentation
//! Integration Tests for Multi-Tenant SCIM Provider Ecosystem
//!
//! This module contains comprehensive integration tests for the multi-tenant SCIM server
//! implementation. The tests are organized into logical stages to drive development
//! incrementally using a test-driven approach.
//!
//! ## Test Organization
//!
//! ### Stage 1: Core Multi-Tenant Foundation (`multi_tenant/core.rs`)
//! - RequestContext with tenant information
//! - TenantResolver trait and implementations
//! - ScimServer tenant validation
//! - Basic tenant isolation errors
//! - Cross-tenant access prevention
//!
//! ### Stage 2: Provider Trait Multi-Tenancy (`multi_tenant/provider_trait.rs`)
//! - Updated ResourceProvider trait with tenant parameters
//! - Tenant-scoped resource operations
//! - Provider-agnostic multi-tenant behavior
//! - Resource isolation verification
//!
//! ### Stage 3: Provider Implementations (`providers/`)
//! - InMemoryProvider with tenant isolation (`providers/in_memory.rs`)
//! - DatabaseProvider with isolation strategies (`providers/database.rs`)
//! - Provider-specific multi-tenant features
//! - Performance testing with multiple tenants
//!
//! ### Stage 4: Advanced Multi-Tenant Features (`multi_tenant/advanced.rs`)
//! - Tenant-specific schema customization
//! - Bulk operations with tenant isolation
//! - Advanced security scenarios
//! - Migration and tenant lifecycle management
//!
//! ## Test Principles
//!
//! 1. **Isolation Verification**: Every test must verify that tenants cannot access each other's data
//! 2. **Comprehensive Coverage**: Test all CRUD operations with tenant context
//! 3. **Error Scenarios**: Test unauthorized access attempts extensively
//! 4. **Real-world Scenarios**: Test typical SaaS usage patterns
//! 5. **Performance**: Ensure tenant isolation doesn't severely impact performance
//!
//! ## Running Tests
//!
//! ```bash
//! # Run all integration tests
//! cargo test --test integration
//!
//! # Run specific stages
//! cargo test integration::multi_tenant::core
//! cargo test integration::providers::in_memory
//!
//! # Run with output for debugging
//! cargo test --test integration -- --nocapture
//! ```

// pub mod end_to_end; // Disabled until implemented
pub mod conditional_operations;
pub mod etag_comprehensive;

pub mod multi_tenant;
pub mod patch;
pub mod permission_enforcement;
pub mod providers;
pub mod scim_multi_tenant;
pub mod scim_protocol;
pub mod version_operations;

// Re-export commonly used test utilities
pub use crate::common::{
    TestScenarios, UnifiedTestHarness, create_multi_tenant_context, create_single_tenant_context,
    create_test_user,
};

#[cfg(test)]
mod integration_suite_meta {

    /// Meta-test to verify integration test setup
    #[test]
    fn integration_test_suite_setup() {
        println!("\n🏗️  Multi-Tenant SCIM Integration Test Suite");
        println!("=============================================");
        println!("This suite tests the multi-tenant provider ecosystem with");
        println!("comprehensive tenant isolation and security verification.\n");

        println!("📋 Test Stages:");
        println!("  Stage 1: Core Multi-Tenant Foundation ✅");
        println!("  Stage 2: Provider Trait Multi-Tenancy ✅");
        println!("  Stage 3: Provider Implementations ✅");
        println!("  Stage 4: Advanced Multi-Tenant Features ✅");
        println!("  Stage 5: SCIM PATCH Operations 🚧");
        println!("  Stage 6: Configuration Management 🚧\n");

        println!("🔒 Security Focus:");
        println!("  • Cross-tenant data isolation");
        println!("  • Unauthorized access prevention");
        println!("  • Tenant context validation");
        println!("  • Resource scoping verification\n");

        println!(
            "🎯 Current Status: Implementing SCIM PATCH operations with comprehensive test coverage"
        );
    }

    /// Verify test fixtures are available
    #[test]
    fn test_fixtures_available() {
        // Verify test fixtures are available
        use crate::common::{
            create_multi_tenant_context, create_single_tenant_context, create_test_user,
        };

        let _single_context = create_single_tenant_context();
        let _multi_context = create_multi_tenant_context("test_tenant");

        let user = create_test_user("testuser");
        assert_eq!(user["userName"], "testuser");

        // Note: TestScenarios now requires a provider parameter
        // let _harness = TestScenarios::basic_two_tenant(provider);
        // assert_eq!(_harness.contexts.len(), 2);

        println!("✅ Test fixtures are working correctly");
    }
}