cellos-export-http 0.5.1

HTTP ExportSink for CellOS — POSTs per-cell evidence bundles to a configured webhook endpoint.
Documentation
//! Integration smoke test for `cellos-export-http`.
//!
//! Scope: smoke wires only — verifies `HttpExportSink::new` validation,
//! placeholder expansion, and that `from_env` errors when required env vars
//! are absent. The retry loop and CA-bundle plumbing are covered inline.
//
// `from_env` reads process env vars; serialize accesses across smoke tests.

use std::sync::Mutex;

use cellos_core::ports::ExportSink;
use cellos_core::ExportReceiptTargetKind;
use cellos_export_http::HttpExportSink;

static ENV_LOCK: Mutex<()> = Mutex::new(());

fn lock() -> std::sync::MutexGuard<'static, ()> {
    ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner())
}

#[test]
fn smoke_construct_https_sink_succeeds() {
    let _g = lock();
    std::env::remove_var("CELLOS_CA_BUNDLE");
    let sink = HttpExportSink::new("https://example.invalid/upload", "smoke-cell", None, 1, 0)
        .expect("smoke: https base URL must be accepted");
    assert_eq!(sink.target_kind(), Some(ExportReceiptTargetKind::Http));
}

#[test]
fn smoke_destination_hint_expands_placeholders() {
    let _g = lock();
    std::env::remove_var("CELLOS_CA_BUNDLE");
    let sink = HttpExportSink::new(
        "https://example.invalid/{cell_id}/{artifact_name}",
        "smoke-cell",
        None,
        1,
        0,
    )
    .expect("construct sink");
    let hint = sink.destination_hint("smoke.txt").expect("hint");
    assert_eq!(hint, "https://example.invalid/smoke-cell/smoke.txt");
}

#[test]
fn smoke_from_env_errors_when_base_url_missing() {
    let _g = lock();
    std::env::remove_var("CELLOS_EXPORT_HTTP_BASE_URL");
    std::env::remove_var("CELLOS_EXPORT_HTTP_BEARER_TOKEN");
    let err = match HttpExportSink::from_env("smoke-cell") {
        Ok(_) => panic!("smoke: from_env must error when base URL not set"),
        Err(e) => e,
    };
    assert!(
        err.to_string().contains("CELLOS_EXPORT_HTTP_BASE_URL"),
        "expected env-var name in error, got: {err}"
    );
}

// scope: smoke wires only; the retry loop and HTTP transport behaviour are
// exercised by the supervisor integration tests (e.g. supervisor_export_retry).