mirror of
https://github.com/mii443/vrchatapi-rust.git
synced 2025-08-22 15:45:35 +00:00
Add test for verifying auth token
This commit is contained in:
@ -23,6 +23,15 @@ enum Error{
|
|||||||
Logout(#[from] vrchatapi::apis::Error<vrchatapi::apis::authentication_api::LogoutError>),
|
Logout(#[from] vrchatapi::apis::Error<vrchatapi::apis::authentication_api::LogoutError>),
|
||||||
#[error("Failed to decode Totp from base32")]
|
#[error("Failed to decode Totp from base32")]
|
||||||
TOTPBase32,
|
TOTPBase32,
|
||||||
|
#[error("Test Failed. Expected an error, but got something successful: {0:?}")]
|
||||||
|
ExpectedError(Box<dyn std::fmt::Debug + Send + Sync>),
|
||||||
|
#[error("Test Failed. Expected success, but got an error: {0}")]
|
||||||
|
ExpectedSuccess(Box<dyn std::error::Error + Send + Sync>),
|
||||||
|
#[error("Test Failed. Expected {expect:?}, but got {got:?}")]
|
||||||
|
FailedAssert{
|
||||||
|
expect: Box<dyn std::fmt::Debug + Send + Sync>,
|
||||||
|
got: Box<dyn std::fmt::Debug + Send + Sync>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, anyhow::Error>;
|
pub type Result<T> = std::result::Result<T, anyhow::Error>;
|
||||||
@ -43,9 +52,21 @@ async fn main() -> Result<()> {
|
|||||||
client
|
client
|
||||||
};
|
};
|
||||||
|
|
||||||
|
check_verify_auth_token(&client, false).await?;
|
||||||
let u = login(&client, &username).await?;
|
let u = login(&client, &username).await?;
|
||||||
|
check_verify_auth_token(&client, true).await?;
|
||||||
|
|
||||||
logout(&client).await?;
|
logout(&client).await?;
|
||||||
|
check_verify_auth_token(&client, false).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn check_verify_auth_token(client: &vrchatapi::apis::configuration::Configuration, expect: bool) -> Result<()> {
|
||||||
|
let ok = vrchatapi::apis::authentication_api::verify_auth_token(&client)
|
||||||
|
.await?.ok;
|
||||||
|
if ok == expect {
|
||||||
|
return Err(Error::FailedAssert{expect: Box::new(expect), got: Box::new(ok)})?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user