product-os-server 0.0.55

Product OS : Server provides a full functioning advanced server capable of acting as a web server, command and control distributed network, authentication server, crawling server and more. Fully featured with high level of flexibility.
Documentation
//! End-to-end integration tests for pure `framework_flow`.
//!
//! Run with:
//!   cargo test --test framework_flow_e2e --no-default-features --features "framework_flow,core,executor_tokio,tls,ws,sse,cors,compression"

#![cfg(all(
    feature = "framework_flow",
    not(feature = "framework_axum"),
    not(feature = "flow_axum_compat"),
    feature = "core",
    feature = "executor_tokio",
    feature = "ws",
    feature = "sse",
    feature = "cors",
    feature = "compression",
))]

mod common;

use common::{
    build_server, build_server_https, free_port, install_crypto_provider,
    run_test_suite, run_extended_test_suite, run_cors_test_suite,
    run_https_test_suite, run_sse_test_suite, run_ws_test_suite,
    start_http_server, start_https_server,
};

const FW: &str = "framework_flow";

#[tokio::test]
async fn http_basic() {
    install_crypto_provider();
    let port = free_port();
    let mut server = build_server(port, FW);
    start_http_server(&mut server).await;
    tokio::time::sleep(std::time::Duration::from_millis(500)).await;
    run_test_suite(port, FW).await;
}

#[tokio::test]
async fn http_extended() {
    install_crypto_provider();
    let port = free_port();
    let mut server = build_server(port, FW);
    start_http_server(&mut server).await;
    tokio::time::sleep(std::time::Duration::from_millis(500)).await;
    run_extended_test_suite(port, FW).await;
}

#[tokio::test]
async fn http_cors() {
    install_crypto_provider();
    let port = free_port();
    let mut server = build_server(port, FW);
    start_http_server(&mut server).await;
    tokio::time::sleep(std::time::Duration::from_millis(500)).await;
    run_cors_test_suite(port, FW, "http").await;
}

#[tokio::test]
async fn http_sse() {
    install_crypto_provider();
    let port = free_port();
    let mut server = build_server(port, FW);
    start_http_server(&mut server).await;
    tokio::time::sleep(std::time::Duration::from_millis(500)).await;
    run_sse_test_suite(port, FW).await;
}

#[tokio::test]
async fn http_websocket() {
    install_crypto_provider();
    let port = free_port();
    let mut server = build_server(port, FW);
    start_http_server(&mut server).await;
    tokio::time::sleep(std::time::Duration::from_millis(500)).await;
    run_ws_test_suite(port, FW).await;
}

#[tokio::test]
async fn https_suite() {
    install_crypto_provider();
    let port = free_port();
    let mut server = build_server_https(port, FW);
    start_https_server(&mut server).await;
    tokio::time::sleep(std::time::Duration::from_millis(500)).await;
    run_https_test_suite(port, FW).await;
}

#[tokio::test]
async fn connect_info() {
    install_crypto_provider();
    let port = free_port();
    let mut config = common::test_config(port);
    config.network.connect_info = true;

    let mut server: common::TestServer =
        product_os_server::ProductOSServer::new_with_config(config);

    use product_os_server::ClientAddr;

    server.add_get(
        "/connect-info",
        |ClientAddr(addr): ClientAddr| async move {
            addr.to_string()
        },
    );

    start_http_server(&mut server).await;
    tokio::time::sleep(std::time::Duration::from_millis(500)).await;

    let resp = reqwest::Client::new()
        .get(format!("http://127.0.0.1:{}/connect-info", port))
        .send()
        .await
        .expect("GET /connect-info failed");
    assert_eq!(resp.status(), 200);
    let body = resp.text().await.expect("read body");
    assert!(
        body.starts_with("127.0.0.1:"),
        "ConnectInfo should contain client addr, got: {}",
        body
    );
}