icrc/client/src/lib.rs

37 lines
1.1 KiB
Rust
Raw Normal View History

pub mod error;
pub mod session;
pub mod storage;
pub use session::Session;
#[cfg(test)]
mod tests {
use super::*;
use std::str::FromStr;
use uuid::Uuid;
#[tokio::test]
async fn authorized_session() {
let host = std::env::var("ICRC_TEST_HOST")
.expect("The environment variable ICRC_TEST_HOST needs to be set!");
let token = std::env::var("ICRC_TEST_AUTH")
.expect("The environment variable ICRC_TEST_AUTH needs to be set!");
let session = Session::new(&host, Some(token)).await.unwrap();
}
#[tokio::test]
async fn authenticate() {
let host = std::env::var("ICRC_TEST_HOST")
.expect("The environment variable ICRC_TEST_HOST needs to be set!");
let userid = std::env::var("ICRC_TEST_USER")
.expect("The environment variable ICRC_TEST_USER needs to be set!");
let mut session = Session::new(&host, None).await.unwrap();
session
.auth_with_credentials(Uuid::from_str(&userid).unwrap(), "test")
.await
.unwrap()
}
}