liminal-server 0.24.0

Standalone server for the liminal messaging bus
Documentation
use super::validate_inbox;
use crate::agents::config::AgentsConfig;

#[test]
fn malformed_inbox_errors_never_carry_the_payload() {
    for payload in [
        b"sensitive-fixture-value".as_slice(),
        br#"{"secret":"sensitive-fixture-value"}"#.as_slice(),
    ] {
        let error = validate_inbox(&AgentsConfig::default(), payload);
        assert!(error.is_err());
        if let Err(error) = error {
            assert!(!error.to_string().contains("sensitive-fixture-value"));
        }
    }
    assert!(validate_inbox(&AgentsConfig::default(), br#"{"text":"message data"}"#).is_ok());
}

#[test]
fn inbox_bytes_are_refused_before_parsing_at_the_configured_bound() {
    let bounds = AgentsConfig {
        max_event_bytes: 4,
        ..AgentsConfig::default()
    };
    let error = validate_inbox(&bounds, b"12345");
    let refused = error.is_err_and(|error| {
        error.to_string() == "auth.lys.agents.max_event_bytes: limit 4, count 5"
    });
    assert!(refused);
}