use std::sync::Arc; use armonik::{auth, server::AuthServiceExt}; mod common; #[derive(Debug, Clone, Default)] struct Service { failure: Option, wait: Option, } impl armonik::server::AuthService for Service { async fn current_user( self: Arc, _request: auth::current_user::Request, cancellation_token: tokio_util::sync::CancellationToken, ) -> std::result::Result { common::unary_rpc_impl( self.wait.clone(), self.failure.clone(), cancellation_token, || { Ok(auth::current_user::Response { user: auth::User { username: String::from("rpc-current-user-output"), ..Default::default() }, }) }, ) .await } } #[tokio::test] async fn current_user() { let mut client = armonik::Client::with_channel(Service::default().auth_server()).auth(); let response = client.current_user().await.unwrap(); assert_eq!(response.username, "rpc-current-user-output"); }