klieo-workflow-api 3.2.0

Embeddable Axum run-service router fronting klieo-workflow (submit / poll declarative workflows).
Documentation
//! Per-route scope binding: each route denies a token missing its scope.

mod common;

use std::time::Duration;

use axum::http::StatusCode;
use common::*;
use klieo_workflow::test_support::const_subflow;
use klieo_workflow::Registry;
use tower::ServiceExt;

const GENEROUS_TIMEOUT: Duration = Duration::from_secs(5);
const HIGH_CAP: usize = 8;

#[tokio::test]
async fn post_runs_with_read_only_scope_is_forbidden() {
    let registry = Registry::new().with_subflow("echo", const_subflow("OK"));
    let router = build_router_with_auth(
        read_only_authenticator(),
        registry,
        GENEROUS_TIMEOUT,
        HIGH_CAP,
    )
    .await;
    let response = router
        .oneshot(submit_request(
            single_subflow_def("echo"),
            serde_json::json!({}),
        ))
        .await
        .unwrap();
    assert_eq!(response.status(), StatusCode::FORBIDDEN);
}

#[tokio::test]
async fn get_run_with_run_only_scope_is_forbidden() {
    let router = build_router_with_auth(
        run_only_authenticator(),
        Registry::new(),
        GENEROUS_TIMEOUT,
        HIGH_CAP,
    )
    .await;
    let response = router.oneshot(get_request("any-run-id")).await.unwrap();
    assert_eq!(response.status(), StatusCode::FORBIDDEN);
}