2024-03-31 15:02:21 +00:00
|
|
|
mod error;
|
|
|
|
mod session;
|
|
|
|
|
|
|
|
pub use session::Session;
|
2024-03-31 10:13:56 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
2024-03-31 15:55:53 +00:00
|
|
|
use std::str::FromStr;
|
|
|
|
use uuid::Uuid;
|
2024-03-31 10:13:56 +00:00
|
|
|
|
2024-03-31 15:02:21 +00:00
|
|
|
#[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();
|
2024-03-31 15:55:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[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!");
|
2024-03-31 15:02:21 +00:00
|
|
|
|
2024-03-31 15:55:53 +00:00
|
|
|
let mut session = Session::new(&host, None).await.unwrap();
|
|
|
|
session
|
2024-03-31 16:12:37 +00:00
|
|
|
.auth_with_credentials(Uuid::from_str(&userid).unwrap(), "test")
|
2024-03-31 15:55:53 +00:00
|
|
|
.await
|
|
|
|
.unwrap()
|
2024-03-31 10:13:56 +00:00
|
|
|
}
|
|
|
|
}
|