pub const TIMEOUT_RESULT_V1: &str =
"https://schemas.3leaps.dev/sysprims/timeout/v1.0.0/timeout-result.schema.json";
pub const TIMEOUT_RESULT_V1_1: &str =
"https://schemas.3leaps.dev/sysprims/timeout/v1.1.0/timeout-result.schema.json";
pub const PROCESS_INFO_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.1.0/process-info.schema.json";
pub const PROCESS_INFO_SAMPLED_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.1.0/process-info-sampled.schema.json";
pub const PROC_FILTER_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/process-filter.schema.json";
pub const PORT_BINDINGS_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/port-bindings.schema.json";
pub const PORT_FILTER_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/port-filter.schema.json";
pub const FD_SNAPSHOT_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/fd-snapshot.schema.json";
pub const FD_FILTER_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/fd-filter.schema.json";
pub const WAIT_PID_RESULT_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/wait-pid-result.schema.json";
pub const BATCH_KILL_RESULT_V1: &str =
"https://schemas.3leaps.dev/sysprims/signal/v1.0.0/batch-kill-result.schema.json";
pub const TERMINATE_TREE_CONFIG_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/terminate-tree-config.schema.json";
pub const TERMINATE_TREE_RESULT_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/terminate-tree-result.schema.json";
pub const SPAWN_IN_GROUP_CONFIG_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/spawn-in-group-config.schema.json";
pub const SPAWN_IN_GROUP_RESULT_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/spawn-in-group-result.schema.json";
pub const RUN_SETSID_CONFIG_V1: &str =
"https://schemas.3leaps.dev/sysprims/session/v1.0.0/run-setsid-config.schema.json";
pub const RUN_NOHUP_CONFIG_V1: &str =
"https://schemas.3leaps.dev/sysprims/session/v1.0.0/run-nohup-config.schema.json";
pub const SESSION_SPAWN_RESULT_V1: &str =
"https://schemas.3leaps.dev/sysprims/session/v1.0.0/session-spawn-result.schema.json";
pub const DESCENDANTS_RESULT_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/descendants-result.schema.json";
pub const DESCENDANTS_RESULT_SAMPLED_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.1.0/descendants-result-sampled.schema.json";
pub const GUARD_EVENT_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/guard-event.schema.json";
pub const ANCESTORS_RESULT_V1: &str =
"https://schemas.3leaps.dev/sysprims/process/v1.0.0/ancestors-result.schema.json";
pub const SCHEMA_HOST: &str = "https://schemas.3leaps.dev";
pub const SCHEMA_MODULE: &str = "sysprims";
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_schema_ids_are_valid_urls() {
assert!(TIMEOUT_RESULT_V1.starts_with("https://"));
assert!(TIMEOUT_RESULT_V1_1.starts_with("https://"));
assert!(PROCESS_INFO_V1.starts_with("https://"));
assert!(PROCESS_INFO_SAMPLED_V1.starts_with("https://"));
assert!(PROC_FILTER_V1.starts_with("https://"));
assert!(PORT_BINDINGS_V1.starts_with("https://"));
assert!(PORT_FILTER_V1.starts_with("https://"));
assert!(FD_SNAPSHOT_V1.starts_with("https://"));
assert!(FD_FILTER_V1.starts_with("https://"));
assert!(WAIT_PID_RESULT_V1.starts_with("https://"));
assert!(BATCH_KILL_RESULT_V1.starts_with("https://"));
assert!(TERMINATE_TREE_CONFIG_V1.starts_with("https://"));
assert!(TERMINATE_TREE_RESULT_V1.starts_with("https://"));
assert!(SPAWN_IN_GROUP_CONFIG_V1.starts_with("https://"));
assert!(SPAWN_IN_GROUP_RESULT_V1.starts_with("https://"));
assert!(RUN_SETSID_CONFIG_V1.starts_with("https://"));
assert!(RUN_NOHUP_CONFIG_V1.starts_with("https://"));
assert!(SESSION_SPAWN_RESULT_V1.starts_with("https://"));
assert!(DESCENDANTS_RESULT_V1.starts_with("https://"));
assert!(DESCENDANTS_RESULT_SAMPLED_V1.starts_with("https://"));
assert!(GUARD_EVENT_V1.starts_with("https://"));
assert!(ANCESTORS_RESULT_V1.starts_with("https://"));
}
#[test]
fn test_schema_ids_use_3leaps_host() {
let expected_prefix = "https://schemas.3leaps.dev/sysprims/";
assert!(
TIMEOUT_RESULT_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
PROCESS_INFO_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
PROCESS_INFO_SAMPLED_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
PROC_FILTER_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
PORT_BINDINGS_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
PORT_FILTER_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
FD_SNAPSHOT_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
FD_FILTER_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
WAIT_PID_RESULT_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
BATCH_KILL_RESULT_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
TERMINATE_TREE_CONFIG_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
TERMINATE_TREE_RESULT_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
SPAWN_IN_GROUP_CONFIG_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
SPAWN_IN_GROUP_RESULT_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
RUN_SETSID_CONFIG_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
RUN_NOHUP_CONFIG_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
SESSION_SPAWN_RESULT_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
DESCENDANTS_RESULT_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
DESCENDANTS_RESULT_SAMPLED_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
GUARD_EVENT_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
assert!(
ANCESTORS_RESULT_V1.starts_with(expected_prefix),
"Expected 3leaps.dev host"
);
}
#[test]
fn test_schema_ids_follow_canonical_uri_pattern() {
assert!(TIMEOUT_RESULT_V1.ends_with(".schema.json"));
assert!(PROCESS_INFO_V1.ends_with(".schema.json"));
assert!(PROCESS_INFO_SAMPLED_V1.ends_with(".schema.json"));
assert!(PROC_FILTER_V1.ends_with(".schema.json"));
assert!(PORT_BINDINGS_V1.ends_with(".schema.json"));
assert!(PORT_FILTER_V1.ends_with(".schema.json"));
assert!(FD_SNAPSHOT_V1.ends_with(".schema.json"));
assert!(FD_FILTER_V1.ends_with(".schema.json"));
assert!(WAIT_PID_RESULT_V1.ends_with(".schema.json"));
assert!(BATCH_KILL_RESULT_V1.ends_with(".schema.json"));
assert!(TERMINATE_TREE_CONFIG_V1.ends_with(".schema.json"));
assert!(TERMINATE_TREE_RESULT_V1.ends_with(".schema.json"));
assert!(SPAWN_IN_GROUP_CONFIG_V1.ends_with(".schema.json"));
assert!(SPAWN_IN_GROUP_RESULT_V1.ends_with(".schema.json"));
assert!(RUN_SETSID_CONFIG_V1.ends_with(".schema.json"));
assert!(RUN_NOHUP_CONFIG_V1.ends_with(".schema.json"));
assert!(SESSION_SPAWN_RESULT_V1.ends_with(".schema.json"));
assert!(DESCENDANTS_RESULT_V1.ends_with(".schema.json"));
assert!(DESCENDANTS_RESULT_SAMPLED_V1.ends_with(".schema.json"));
assert!(GUARD_EVENT_V1.ends_with(".schema.json"));
assert!(ANCESTORS_RESULT_V1.ends_with(".schema.json"));
assert!(PROCESS_INFO_V1.contains("/v1.1.0/"));
assert!(PROCESS_INFO_SAMPLED_V1.contains("/v1.1.0/"));
assert!(DESCENDANTS_RESULT_SAMPLED_V1.contains("/v1.1.0/"));
assert!(TIMEOUT_RESULT_V1.contains("/v1.0.0/"));
assert!(PROC_FILTER_V1.contains("/v1.0.0/"));
assert!(PORT_BINDINGS_V1.contains("/v1.0.0/"));
assert!(PORT_FILTER_V1.contains("/v1.0.0/"));
assert!(FD_SNAPSHOT_V1.contains("/v1.0.0/"));
assert!(FD_FILTER_V1.contains("/v1.0.0/"));
assert!(WAIT_PID_RESULT_V1.contains("/v1.0.0/"));
assert!(BATCH_KILL_RESULT_V1.contains("/v1.0.0/"));
assert!(TERMINATE_TREE_CONFIG_V1.contains("/v1.0.0/"));
assert!(TERMINATE_TREE_RESULT_V1.contains("/v1.0.0/"));
assert!(SPAWN_IN_GROUP_CONFIG_V1.contains("/v1.0.0/"));
assert!(SPAWN_IN_GROUP_RESULT_V1.contains("/v1.0.0/"));
assert!(RUN_SETSID_CONFIG_V1.contains("/v1.0.0/"));
assert!(RUN_NOHUP_CONFIG_V1.contains("/v1.0.0/"));
assert!(SESSION_SPAWN_RESULT_V1.contains("/v1.0.0/"));
assert!(DESCENDANTS_RESULT_V1.contains("/v1.0.0/"));
assert!(GUARD_EVENT_V1.contains("/v1.0.0/"));
assert!(ANCESTORS_RESULT_V1.contains("/v1.0.0/"));
}
#[test]
fn test_schema_ids_have_correct_topics() {
assert!(
TIMEOUT_RESULT_V1.contains("/timeout/"),
"timeout schema should have timeout topic"
);
assert!(
PROCESS_INFO_V1.contains("/process/"),
"process-info schema should have process topic"
);
assert!(
PROCESS_INFO_SAMPLED_V1.contains("/process/"),
"process-info-sampled schema should have process topic"
);
assert!(
PROC_FILTER_V1.contains("/process/"),
"process-filter schema should have process topic"
);
assert!(
PORT_BINDINGS_V1.contains("/process/"),
"port-bindings schema should have process topic"
);
assert!(
PORT_FILTER_V1.contains("/process/"),
"port-filter schema should have process topic"
);
assert!(
FD_SNAPSHOT_V1.contains("/process/"),
"fd-snapshot schema should have process topic"
);
assert!(
FD_FILTER_V1.contains("/process/"),
"fd-filter schema should have process topic"
);
assert!(
WAIT_PID_RESULT_V1.contains("/process/"),
"wait-pid-result schema should have process topic"
);
assert!(
BATCH_KILL_RESULT_V1.contains("/signal/"),
"batch-kill-result schema should have signal topic"
);
assert!(
TERMINATE_TREE_CONFIG_V1.contains("/process/"),
"terminate-tree-config schema should have process topic"
);
assert!(
TERMINATE_TREE_RESULT_V1.contains("/process/"),
"terminate-tree-result schema should have process topic"
);
assert!(
SPAWN_IN_GROUP_CONFIG_V1.contains("/process/"),
"spawn-in-group-config schema should have process topic"
);
assert!(
SPAWN_IN_GROUP_RESULT_V1.contains("/process/"),
"spawn-in-group-result schema should have process topic"
);
assert!(
RUN_SETSID_CONFIG_V1.contains("/session/"),
"run-setsid-config schema should have session topic"
);
assert!(
RUN_NOHUP_CONFIG_V1.contains("/session/"),
"run-nohup-config schema should have session topic"
);
assert!(
SESSION_SPAWN_RESULT_V1.contains("/session/"),
"session-spawn-result schema should have session topic"
);
assert!(
DESCENDANTS_RESULT_V1.contains("/process/"),
"descendants-result schema should have process topic"
);
assert!(
DESCENDANTS_RESULT_SAMPLED_V1.contains("/process/"),
"descendants-result-sampled schema should have process topic"
);
assert!(
GUARD_EVENT_V1.contains("/process/"),
"guard-event schema should have process topic"
);
assert!(
ANCESTORS_RESULT_V1.contains("/process/"),
"ancestors-result schema should have process topic"
);
}
#[test]
fn test_schema_ids_are_unique() {
let ids = [
TIMEOUT_RESULT_V1,
PROCESS_INFO_V1,
PROCESS_INFO_SAMPLED_V1,
PROC_FILTER_V1,
PORT_BINDINGS_V1,
PORT_FILTER_V1,
FD_SNAPSHOT_V1,
FD_FILTER_V1,
WAIT_PID_RESULT_V1,
BATCH_KILL_RESULT_V1,
TERMINATE_TREE_CONFIG_V1,
TERMINATE_TREE_RESULT_V1,
SPAWN_IN_GROUP_CONFIG_V1,
SPAWN_IN_GROUP_RESULT_V1,
RUN_SETSID_CONFIG_V1,
RUN_NOHUP_CONFIG_V1,
SESSION_SPAWN_RESULT_V1,
DESCENDANTS_RESULT_V1,
DESCENDANTS_RESULT_SAMPLED_V1,
GUARD_EVENT_V1,
ANCESTORS_RESULT_V1,
];
for (i, a) in ids.iter().enumerate() {
for (j, b) in ids.iter().enumerate() {
if i != j {
assert_ne!(a, b, "Schema IDs must be unique");
}
}
}
}
#[test]
fn test_schema_host_constants() {
assert_eq!(SCHEMA_HOST, "https://schemas.3leaps.dev");
assert_eq!(SCHEMA_MODULE, "sysprims");
let prefix = format!("{}/{}/", SCHEMA_HOST, SCHEMA_MODULE);
assert!(TIMEOUT_RESULT_V1.starts_with(&prefix));
assert!(PROCESS_INFO_V1.starts_with(&prefix));
assert!(PROCESS_INFO_SAMPLED_V1.starts_with(&prefix));
assert!(PROC_FILTER_V1.starts_with(&prefix));
assert!(PORT_BINDINGS_V1.starts_with(&prefix));
assert!(PORT_FILTER_V1.starts_with(&prefix));
assert!(FD_SNAPSHOT_V1.starts_with(&prefix));
assert!(FD_FILTER_V1.starts_with(&prefix));
assert!(WAIT_PID_RESULT_V1.starts_with(&prefix));
assert!(BATCH_KILL_RESULT_V1.starts_with(&prefix));
assert!(TERMINATE_TREE_CONFIG_V1.starts_with(&prefix));
assert!(TERMINATE_TREE_RESULT_V1.starts_with(&prefix));
assert!(SPAWN_IN_GROUP_CONFIG_V1.starts_with(&prefix));
assert!(SPAWN_IN_GROUP_RESULT_V1.starts_with(&prefix));
assert!(RUN_SETSID_CONFIG_V1.starts_with(&prefix));
assert!(RUN_NOHUP_CONFIG_V1.starts_with(&prefix));
assert!(SESSION_SPAWN_RESULT_V1.starts_with(&prefix));
assert!(DESCENDANTS_RESULT_V1.starts_with(&prefix));
assert!(DESCENDANTS_RESULT_SAMPLED_V1.starts_with(&prefix));
assert!(GUARD_EVENT_V1.starts_with(&prefix));
assert!(ANCESTORS_RESULT_V1.starts_with(&prefix));
}
}