qssh 0.0.2-alpha

Experimental quantum-safe SSH using post-quantum crypto. Research project - NOT for production. See LIMITATIONS.md
Documentation
//! Integration tests for QSSH client/server

use qssh::{QsshConfig, QsshClient, QsshServer, PqAlgorithm};
use qssh::server::QsshServerConfig;
use std::sync::Arc;
use tokio::time::{timeout, Duration};

#[tokio::test]
async fn test_client_server_handshake() {
    let _ = env_logger::try_init();
    
    // Create server config
    let mut server_config = QsshServerConfig::new("127.0.0.1:0").unwrap(); // Random port
    
    // Start server in background
    let server = Arc::new(QsshServer::new(server_config.clone()));
    let server_handle = {
        let server = server.clone();
        tokio::spawn(async move {
            // Server will run until test ends
            let _ = server.start().await;
        })
    };
    
    // Give server time to start
    tokio::time::sleep(Duration::from_millis(100)).await;
    
    // Create client config
    let client_config = QsshConfig {
        server: server_config.listen_addr.clone(),
        username: "testuser".to_string(),
        password: None,
        port_forwards: vec![],
        use_qkd: false, // No QKD in tests
        pq_algorithm: PqAlgorithm::Falcon512,
        key_rotation_interval: 3600,
    };
    
    // This test is simplified - in reality we'd need:
    // 1. Server to actually bind and get its port
    // 2. Proper authentication setup
    // 3. Mock or real PTY allocation
    
    // For now, just verify components compile and basic structure works
    let mut client = QsshClient::new(client_config);
    
    // Can't actually connect without running server
    // assert!(client.connect().await.is_ok());
    
    // Clean shutdown
    server_handle.abort();
}

#[tokio::test]
async fn test_vault_integration() {
    let config = QsshConfig::default();
    
    // Create client with vault
    let client = QsshClient::new(config)
        .with_vault(b"test-master-key")
        .await
        .unwrap();
    
    // Vault should be initialized
    // In real usage, vault would store host keys, session keys, etc.
}

#[test]
fn test_config_defaults() {
    let config = QsshConfig::default();
    
    assert_eq!(config.server, "localhost:22222");
    assert_eq!(config.username, "user");
    assert!(!config.use_qkd);
    assert_eq!(config.pq_algorithm, PqAlgorithm::Falcon512);
    assert_eq!(config.key_rotation_interval, 3600);
}

#[test]
fn test_quantum_capabilities() {
    use qssh::QuantumCapabilities;
    
    let caps = QuantumCapabilities {
        supports_qkd: true,
        supports_sphincs: true,
        supports_kyber: false, // We use Falcon instead
        supports_falcon: true,
        qkd_endpoints: vec![
            "qkd://alice.quantum.net".to_string(),
            "qkd://bob.quantum.net".to_string(),
        ],
    };
    
    assert!(caps.supports_qkd);
    assert!(caps.supports_falcon);
    assert_eq!(caps.qkd_endpoints.len(), 2);
}