monaco-sdk 0.8.8

Typed Rust client for the Monaco REST API — generated from the OpenAPI specification
Documentation
mod common;

use common::{authed_client, authenticate, client};

#[tokio::test]
#[ignore = "requires running API server + rust-sdk request signing"]
async fn auth_flow_and_profile() {
    let (session_key, address, _signer) = authenticate().await;

    let authed = authed_client(&session_key);
    let profile = authed.get_user_profile().await.unwrap().into_inner();

    let profile_addr = profile.address.unwrap();
    assert_eq!(profile_addr.to_lowercase(), address.to_lowercase());
}

/// `get_user_profile` must reject calls without valid session signature headers.
#[tokio::test]
#[ignore = "requires running API server"]
async fn unauthenticated_profile_call_is_rejected() {
    let resp = client().get_user_profile().await;
    let Err(err) = resp else {
        panic!("expected 401 from get_user_profile without auth, got Ok");
    };
    match err {
        monaco_sdk::Error::ErrorResponse(r) => {
            assert_eq!(r.status().as_u16(), 401, "expected HTTP 401, got {r:?}");
        }
        other => panic!("expected ErrorResponse(401), got {other:?}"),
    }
}